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, November 21, 2011 5:26:28 PM(UTC)

MartinT  
MartinT

Groups: Registered
Posts: 10


I'm trying to work out how to update an existing (possibly multi-page) tif image. I want to simulate a label being added to the image. I want to:

1) Create a (relatively small) rectangle with a black border and white internal area. This should be non-transparent so that it blocks out the underlying image.

2) Add some text within the rectangle.

3) Apply the rectangle (and text) to the image.

4) Resave the image as a tif file.

The 'label' should only appear on the first page.

I thought Annotations were the solution, but using the demo, I create an annotation and save it, but the Image itself still looks the same.

Can you point me towards a sample or give me a starting code snippet?

FYI - I'm using .NET and V17.5

Thanks,

MartinT

 

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 : Tuesday, November 22, 2011 1:03:22 AM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

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

MartinT,
If you want the change to be done in the image's pixels (modify the data itself and not add an annotation on top of it), you can create a new raster image and draw a string on it then combine it with the original image. Drawing string is done by using the following code:
+-------------+
// Load the image
RasterImage srcImage = codecs.Load(imageFileName, 0, CodecsLoadByteOrder.BgrOrGray, 1, 1);

// Creates a new image in memory with dimensions equal to the required rectangle
RasterImage img = new RasterImage(
RasterMemoryFlags.Conventional,
150, //width
70, //height
srcImage.BitsPerPixel,
srcImage.Order,
srcImage.ViewPerspective,
srcImage.GetPalette(),
IntPtr.Zero,
0);

RasterImageGdiPlusGraphicsContainer container = new RasterImageGdiPlusGraphicsContainer(img);

container.Graphics.DrawString(
writeString,
new System.Drawing.Font("Ariel", fontSize, FontStyle.Bold),
new SolidBrush(System.Drawing.Color.Black),
x, y);
+-------------+

After drawing the string on the new image, you need to combine the new image with the source image by using the CombineFastCommand Class.
For more information, please see the following help topics in the LEADTOOLS .Net documentation:
- RasterImageGdiPlusGraphicsContainer Class
- CombineFastCommand Class

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#3 Posted : Tuesday, November 22, 2011 12:44:12 PM(UTC)

MartinT  
MartinT

Groups: Registered
Posts: 10


Thanks for the quick response - I'll give it a go.
 
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.071 seconds.