Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Monday, April 3, 2006 4:53:36 AM(UTC)
ibflyfishin

Groups: Registered
Posts: 6


Howdy,

I am using Raster Imaging Pro v14 and am looking to add the words "Uncertified" diagonally across the page in a "faint" print behind tif images as they are printed.  What would be the best way to do this?

thanks

dbl

 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Wednesday, April 5, 2006 10:59:45 PM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

Was thanked: 1 time(s) in 1 post(s)

Hello,

Before printing the TIFF images, you will need to do the following for each TIFF file that you want to print:
- Load the TIFF image on the image viewer control.
- Create a bitmap on a different control with the same dimensions (width and height) of the original image. Then fill the created image with white color.
- Set drawing properties for the second image (the white image), and then draw the text that you want on the image.
- Combine the two images (the original TIFF image and the created white image) using the alphablend function to implement the transparency (opacity).
- Print the result combined image.

Please try the above instructions and let me know how it goes.

Regards,
Maen Badwan
LEADTOOLS Technical Support
 
#3 Posted : Friday, April 28, 2006 7:13:55 AM(UTC)
ibflyfishin

Groups: Registered
Posts: 6


Thank you Maen,

I understand the combining of the two images but I am curious if there is a way to get the "word" diagonally across the page.  The function that I looked at would do it across or down but not diagonally.  This may be a stupid question and I just didn't see it in the documentation but I thought I would ask anyway.

Thanks

dbl

 
#4 Posted : Tuesday, May 2, 2006 4:42:59 AM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

Was thanked: 1 time(s) in 1 post(s)

Hello,

You may try to use the Draw text function to draw the text that you want with a specific angle on the image.
The details depend on the programming interface that you use.
However, if you are using the LEAD Main OCX programming interface, you can use the LEAD1.DrawText method to draw the text.
The code will be something like follows:
+-----------------------------+
Private Sub Command2_Click()
   LEAD1.CreateBitmap 600, 800, 24
   LEAD1.Fill RGB(255, 255, 255)

   'Text location
   LEAD1.TextTop = 10
   LEAD1.TextLeft = 10
   LEAD1.TextWidth = 550
   LEAD1.TextHeight = 550
   LEAD1.Font.Size = 10
   LEAD1.Font.Name = "Arial"
   LEAD1.Font.Bold = True
   'Text alignment and angle
   LEAD1.TextAlign = 0
   LEAD1.TextAngle = 450
   'Enable word wrap
   LEAD1.TextWordWrap = True
   LEAD1.DrawPersistence = True
   'Draw a header
   LEAD1.DrawText "Header", 0

   LEAD1.TextTop = 30
   LEAD1.TextLeft = 30
   LEAD1.TextWidth = 550
   LEAD1.TextHeight = 550
   LEAD1.Font.Bold = False
End Sub
+-----------------------------+

Please try the above instructions and let me know if this helps.

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#5 Posted : Wednesday, June 21, 2006 1:34:06 PM(UTC)
ibflyfishin

Groups: Registered
Posts: 6


Hello,

I have finally gotten around to implementing this watermark function and I thought I had it working well until I started combining with images that had a large amount of Black background.  When I did you can tell that they are getting "blended" with white dots.

Here is my Watermark function,  can you tell me what I am doing wrong?

 

void WatermarkImage(char *psFileName, char *psWatermarkText, char *psWatermarkFontName, int iWatermarkFontSize, int iWatermarkAngle)

{

const char *psModuleName = "WatermarkImage";

long lRC = 0;

BITMAPHANDLE TiffHandle;

BITMAPHANDLE WatermarkHandle;

FILEINFO FileInfo;

HDC hdcImage;

HDC hdcWatermark;

long lRet = 0;

FileInfo.Flags = 0;

msOutput.Format("%s - Opening File for Watermark**", psModuleName);

UpdateLog(msOutput, false);

lRet = L_LoadBitmap(psFileName, &TiffHandle, sizeof(BITMAPHANDLE), 0, ORDER_BGRORGRAY, NULL, &FileInfo);

if (lRet != SUCCESS)

{

msOutput.Format("%s Error - Error %d Loading %s file**", psModuleName, lRet, &psFileName[0]);

UpdateLog(msOutput, true);

lRC = -1;

}

else

{

msOutput.Format("%s - File Opened for Watermark. Height:%d, Width:%d**", psModuleName, FileInfo.Height, FileInfo.Width);

UpdateLog(msOutput, false);

hdcImage = L_CreateLeadDC(&TiffHandle);

lRC = L_CreateBitmap (&WatermarkHandle,

sizeof(BITMAPHANDLE),

TYPE_CONV,

FileInfo.Width,

FileInfo.Height,

FileInfo.BitsPerPixel,

FileInfo.Order,

NULL,

BOTTOM_LEFT,

NULL, 0);

lRC = L_CopyBitmapPalette(&WatermarkHandle, &TiffHandle);

hdcWatermark = L_CreateLeadDC(&WatermarkHandle);

UINT nOptions = 0;//DT_CENTER;

RECT rect = {0,0,FileInfo.Width, FileInfo.Height};

LOGFONT lf;

memset(&lf, 0, sizeof(lf));

lstrcpy(lf.lfFaceName, psWatermarkFontName);

lf.lfHeight = iWatermarkFontSize * -20;

lf.lfEscapement = iWatermarkAngle * 10;

lf.lfOrientation = lf.lfEscapement;

lf.lfClipPrecision = CLIP_LH_ANGLES || CLIP_TT_ALWAYS;

lf.lfWeight = FW_THIN;

DrawRotatedText(hdcWatermark, psWatermarkText, &rect, lf, iWatermarkAngle, nOptions);

BLENDFUNCTION bfImage;

memset(&bfImage, 0, sizeof(bfImage));

bfImage.BlendOp = AC_SRC_OVER;

bfImage.BlendFlags = 0;

bfImage.SourceConstantAlpha = 70;

bfImage.AlphaFormat = 0; // AC_SRC_ALPHA

BOOL bRC = false;

L_AlphaBlendBitmap(&TiffHandle, 0, 0, FileInfo.Width, FileInfo.Height, &WatermarkHandle, 0, 0, 35);

msOutput.Format("%s - Saving File:%s, bRC:%d**", psModuleName, psFileName, bRC);

UpdateLog(msOutput, false);

lRet = L_SaveBitmap(psFileName, &TiffHandle, FILE_TIFX_FAX_G4, 0, PQ1, NULL);

if (lRet != SUCCESS)

{

msOutput.Format("%s Error - Error %d saving %s file**", psModuleName, lRet, &psFileName[0]);

UpdateLog(msOutput, true);

lRC = -1;

}

else

{

msOutput.Format("%s - saved %s file**", psModuleName, &psFileName[0]);

UpdateLog(msOutput, false);

}

L_FreeBitmap (&TiffHandle);

lRC = 0;

}

}

 
#6 Posted : Sunday, June 25, 2006 6:10:50 AM(UTC)

Amin  
Amin

Groups: Manager, Tech Support
Posts: 367

Was thanked: 1 time(s) in 1 post(s)

You are saving to a format that only supports 1-bit black-and-white images. This means the resulting image cannot contain colors or shades of gray. That's probably why the resulting image contains a 'dithered' pattern of black and white dots.
If that's not the problem you're facing, can you send a sample source image that shows the problem to support@leadtools.com or post it here? If you send or post files, please put them in a ZIP file first.

Amin Dodin

Senior Support Engineer
LEAD Technologies, Inc.
LEAD Logo
 
#7 Posted : Sunday, June 25, 2006 7:08:05 AM(UTC)
ibflyfishin

Groups: Registered
Posts: 6


"You are saving to a format that only supports 1-bit black-and-white images. This means the resulting image cannot contain colors or shades of gray. That's probably why the resulting image contains a 'dithered' pattern of black and white dots."

I don't need colors or shades of gray.  I need to put a watermark on the image without affecting the rest of the image.

I am attaching the original and the result.  Please let me know what I can do to fix this.

Thanks

Dbl

File Attachment(s):
19050060.zip (261kb) downloaded 34 time(s).
 
#8 Posted : Tuesday, June 27, 2006 3:33:57 AM(UTC)

Amin  
Amin

Groups: Manager, Tech Support
Posts: 367

Was thanked: 1 time(s) in 1 post(s)

I think you want to prevent the 'dithering' effect that took place in the image, but obtain a 'dithered' or dotted watermark text just like in the result image. Is this correct?
If yes, change your code to do the following:
1. Load the TIFF image as 1-bit, but don't create a LeadDC for it.
2. Create the Watermark image as 8-bit grayscale. Draw the text on it (using Windows GDI for example), but using a light color or light shade of gray.
3. Use L_ColorResBitmap to convert the watermark image to 1-bit and use one of the dither flags with it.
4. Use L_CombineBitmap with a flag value of CB_OP_AND to move the black pixels from the watermark to the destination image.

Amin Dodin

Senior Support Engineer
LEAD Technologies, Inc.
LEAD Logo
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.187 seconds.