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 : Thursday, November 11, 2010 1:21:03 AM(UTC)

Noufal  
Noufal

Groups: Registered
Posts: 21


                        Hello... I am doing project in c# with leadtool16... I have loaded one transparent ".png" image into rasterViewer, but its look different from the original image...How can i solve this problem? pls help me quick..
 

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 : Thursday, November 11, 2010 5:49:50 AM(UTC)

Basel  
Guest

Groups: Guests
Posts: 3,022

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

By default, our paint functions do not take the alpha channel into consideration. This is different from some programs, such as the Microsoft viewer, but similar to some other programs such Microsoft Paint.

If you want to change the behavior, you can do it in more than one way:
1. You could use the GDI+ paint engine. To do that, use RasterPaintProperties.PaintEngine = RasterPaintEngine.GdiPlus (Preferences => Print using GDI+ menu);

I tested using this code and it worked:
RasterCodecs.Startup();
RasterCodecs codecs = new RasterCodecs();
RasterImage rasterImage = codecs.Load(@"With Alpha No Transparent.png", 32, CodecsLoadByteOrder.Bgr, 1, 1);

RasterPaintProperties paintProperties = RasterPaintProperties.Default;
paintProperties.PaintEngine = RasterPaintEngine.GdiPlus;
paintProperties.RasterOperation = RasterPaintProperties.SourceCopy;
Graphics graphics = pictureBox1.CreateGraphics();
int width = rasterImage.Width;
int height = rasterImage.Height;
Rectangle rectangle = new Rectangle(0, 0, width, height);
rasterImage.Paint(graphics, rectangle, paintProperties);

2. If you want to paint a background image in the transparent parts of the image, you can combine the main image with the background image with the alpha channel as a mixing mask using the FeatherAlphaBlendCommand Class.
 
#3 Posted : Thursday, November 11, 2010 8:12:40 PM(UTC)

Noufal  
Noufal

Groups: Registered
Posts: 21


Hello..  what is picturebox1..is it simply picturebox? need any loading image to this?
 
#4 Posted : Thursday, November 11, 2010 11:08:11 PM(UTC)

Noufal  
Noufal

Groups: Registered
Posts: 21


  pls give one sample ..........
 
#5 Posted : Sunday, November 14, 2010 12:12:04 AM(UTC)

Basel  
Guest

Groups: Guests
Posts: 3,022

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

yes, it's the Windows Control PictureBox. It's used to create the GDI+ Graphics.

What is the sample you exactly need? Can you please give me details?
 
#6 Posted : Monday, November 22, 2010 10:56:20 PM(UTC)

Noufal  
Noufal

Groups: Registered
Posts: 21


   Hello.. i have merged the same code with my project, but its not working..  I created a sample application , which is attached here..you please correct it....
File Attachment(s):
LoadTransImage.rar (21kb) downloaded 42 time(s).
 
#7 Posted : Tuesday, November 23, 2010 4:46:59 AM(UTC)

Basel  
Guest

Groups: Guests
Posts: 3,022

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

I have updated the project to display an alpha image in a simpler way. I'm attaching the project.
File Attachment(s):
LoadTransImageMOD.zip (23kb) downloaded 52 time(s).
 
#8 Posted : Tuesday, November 23, 2010 6:39:38 PM(UTC)

Noufal  
Noufal

Groups: Registered
Posts: 21


  Thanx...Its working good... but in this case it load only transparent images, it can not load normal images..actually i wana to load both transparent and normal images with same function... pls help me soon...
 
#9 Posted : Wednesday, November 24, 2010 2:41:55 AM(UTC)

Noufal  
Noufal

Groups: Registered
Posts: 21


      Hello.. I have solved the loading image problem , but i am using InteractiveRegion in my project (Rectangle, Ellips..)
.when i drawing interactive region on the rasterimageviewer ,it shows the error " Only GDI paint engine supported in this method"..can i able to draw interactiveregion(rectangle,ellips) with 'Gdi plus' paintproperties in the rasterviewer?
 
#10 Posted : Wednesday, November 24, 2010 4:57:00 AM(UTC)

Basel  
Guest

Groups: Guests
Posts: 3,022

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

For this, you will need to check if the image is 32-bit or not to use GDI+ engine. Here's this code from our Main CS Demo:

// If we are loading a 32-bit image and the paint engine is GDI
// Ask if the user wants to switch to GDI+2. GDI engine does not support alpha.
if(info.Image != null && info.Image.BitsPerPixel == 32 && _paintProperties.PaintEngine == RasterPaintEngine.Gdi)
{
string message = "You are trying to view a 32-bits/pixel image while the current paint engine is set to RasterPaintEngine.Gdi. Switching to RasterPaintEngine.GdiPlus will enable you to view any alpha channel data stored in this image.\n\nDo you want to switch to RasterPaintEngine.GdiPlus now?";
if(Messager.ShowQuestion(
this,
message,
MessageBoxButtons.YesNo) == DialogResult.Yes)
{
_paintProperties.PaintEngine = RasterPaintEngine.GdiPlus;
.....
}
}

Regions with GDI+ are also implemented in our demo. Please see the demo source code here:
[C:\Program Files\LEAD Technologies\LEADTOOLS 16.5\Examples\DotNet\CS\MainDemo]

 
#11 Posted : Wednesday, October 24, 2012 2:19:42 AM(UTC)
bnvelarde

Groups: Registered
Posts: 34


Hi i want to try this approach.

Can I have an updated one and in a VB.net language?

Thanks a lot [:)]
 
#12 Posted : Wednesday, October 24, 2012 4:19:53 AM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

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

There is a VB.Net project on the following forum post:
http://support.leadtools.com/CS/forums/41814/ShowPost.aspx

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
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.118 seconds.