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, July 12, 2010 5:44:44 AM(UTC)
hturnage

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;
}
 

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, July 13, 2010 5:36:47 AM(UTC)

Basel  
Guest

Groups: Guests
Posts: 3,028

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)
hturnage

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)

Basel  
Guest

Groups: Guests
Posts: 3,028

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.

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