This topic and its replies were posted before the current version of LEADTOOLS was released and may no longer be applicable.
#1
Posted
:
Monday, July 12, 2010 5:44:44 AM(UTC)
Groups: Registered
Posts: 9
In an app I've been working on I display a tiff in a rasterimagelist. When an image is 'used' I draw a semi-transparent gray rectangle over the top of it (code below). Does anyone know of a better way to do this without going using CreateGdiPlusGraphics?
private static RasterImage GetRasterImageInternal(byte[] imageBytes, int bitDepth, bool touched)
{
RasterImage retval;
using (var stream = new MemoryStream(imageBytes))
using (var codecs = new RasterCodecs())
{
retval = codecs.Load(stream, bitDepth, CodecsLoadByteOrder.BgrOrGray, 1, 1);
if (touched)
{
var g = retval.CreateGdiPlusGraphics().Graphics;
var rectangle = new RectangleF(0, 0, retval.Width, retval.Height);
var solidBrush = new SolidBrush(Color.FromArgb(40, 0, 0, 0));
g.FillRectangle(solidBrush, rectangle);
}
retval.ResizeToDefault();
}
return retval;
}
#2
Posted
:
Tuesday, July 13, 2010 5:36:47 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
You can use FillCommand Property, to fill a region you set on the RasterImage. Please see this help topic:
http://www.leadtools.com/help/leadtools/v16/dh/l/Leadtools~Leadtools.ImageProcessing.FillCommand.html
#3
Posted
:
Tuesday, July 13, 2010 10:31:09 AM(UTC)
Groups: Registered
Posts: 9
Nope, that doesn't do it. With the code I presented you can still see image underneath the gray. Using a FillCommand I end up with a totally black image (when using the color I provided in the code).
#4
Posted
:
Wednesday, July 14, 2010 5:58:54 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
I tested your code and knew what you exactly need to do. You can do that as follows:
1. Create a new RasterImage with the desired width and height.
2. Fill the image using FillCommand. You can use this code to give Alpha to the black color:
Leadtools.RasterColor clr2 = new Leadtools.RasterColor(40, 0, 0, 0);
3. Combine these two images using CombineCommand Class.
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.