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 : Wednesday, December 15, 2010 1:17:17 PM(UTC)
Stereo3dGuy

Groups: Registered
Posts: 5


I'm new to V17 (upgrading from V13), but I'm having an issue with using the AlphaBlendCommand. Here's the Code I'm using:

Public Sub AlphaBlendCommandExample()
RasterCodecs.Startup()
Dim codecs As New RasterCodecs()
codecs.ThrowExceptionsOnInvalidImages = True

Dim leadImage As RasterImage = codecs.Load("d:\TestImage-Black.jpg")

' Prepare the command
Dim SrcImage As RasterImage
SrcImage = codecs.Load("d:\TestImage.jpg")

Dim command As AlphaBlendCommand = New AlphaBlendCommand
'Combine SrcImage with image, with half opacity.
' command.DestinationRectangle = New LeadRect(leadImage.Width \ 8, leadImage.Height \ 8, leadImage.Width, leadImage.Height)
command.DestinationRectangle = New LeadRect(10, 10, leadImage.Width, leadImage.Height)

command.SourceImage = SrcImage
command.Opacity = 255
command.Run(leadImage)
codecs.Save(leadImage, "d:\alphaResult.jpg", RasterImageFormat.Jpeg, 24)

RasterCodecs.Shutdown()
End Sub

In my result, no matter what size image I use, The top 100 pixels are always clipped off anf the height of the image is short by 100 pixels. Placement is correct, but missing some of the image. Any ideas what I might be doing wrong here?
Thanks!
 

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, December 16, 2010 1:16:16 AM(UTC)

Adnan Ismail  
Guest

Groups: Guests
Posts: 3,022

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

Please attach a ZIP or RAR file with 3 things in it:
1. A sample source image.
2. A sample target image before combining.
3. The expected result (correct) that you want to achieve.
 
#3 Posted : Thursday, December 16, 2010 7:07:21 AM(UTC)
Stereo3dGuy

Groups: Registered
Posts: 5


Here is the attached file with your requested items, plus one additional item:

1. A sample source image. - TestImage.jpg
2. A sample target image before combining. - TestImage-Black.jpg
3. The expected result (correct) that you want to achieve. - ExpectedResult.jpg
4. Actula Result. - AlphaResult.jpg
File Attachment(s):
testFiles.zip (81kb) downloaded 28 time(s).
 
#4 Posted : Friday, December 17, 2010 12:16:23 PM(UTC)

Walter  
Walter

Groups: Tech Support
Posts: 366

Thanks: 1 times
Was thanked: 4 time(s) in 4 post(s)

Hello,

Based on your sample images, you're not really looking to blend these images together, but rather combine one on top of the other. The AlphaBlendCommand uses transparency to combine the two images together. I see that you get around this though by setting the Opacity to 0%.

I've corrected your sample code in the attached demo, and I've also illustrated in the code how you can accomplish the same thing with the CombineCommand. For the AlphaBlendCommand, I also set the SourcePoint property.
File Attachment(s):
VB.NET_CombineTest.zip (60kb) downloaded 28 time(s).
Walter Bates
Senior Support Engineer
LEAD Technologies, Inc.
LEAD Logo
 
#5 Posted : Friday, December 17, 2010 1:11:54 PM(UTC)
Stereo3dGuy

Groups: Registered
Posts: 5


Thank you so much. I had just found the CombineCommand and was just starting to work with it. I now see how it is the proper way to do what I am trying to accomplish.
Thanks again.
 
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.117 seconds.