This forum contains outdated content and is available for reading only. Please contact technical support if you have any questions.
Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
san  
#1 Posted : Thursday, September 7, 2006 12:13:42 AM(UTC)
san

Rank: Member

Groups: Member
Joined: 8/1/2006(UTC)
Posts: 33

Daer Alex,

We have the requirement of combining two images with following details.

One image needs to go to the background.

The other image has some transparent area in it and this transparent area should get the image from the background image.

We tried to use the Combiner class for achieving this but in that case we are not getting the desired results. Also we have tried to use the CombineMode = Behind which should work but still it doesn’t solve our requirements.

Please provide us with help on this as it is very urgent for us now.

Alex Kon  
#2 Posted : Thursday, September 7, 2006 12:41:56 PM(UTC)
Alex Kon

Rank: Advanced Member

Groups: Member
Joined: 1/31/2005(UTC)
Posts: 458

Was thanked: 5 time(s) in 5 post(s)
Hello San,

CombineMode.Behind is not appropriate combine mode for your task. The following code sample shows how to use Combiner class to get the described behaviour:

Code:
Dim bgImage As New Aurigma.GraphicsMill.Bitmap
Dim fgImage As New Aurigma.GraphicsMill.Bitmap
		
bgImage.Load("X:\AllFormats\24bppRgb_LancerEvo.jpg")
fgImage.Load("X:\AllFormats\32bppArgb.png")
		
Dim combiner As New Aurigma.GraphicsMill.Transforms.Combiner
combiner.CombineMode = Aurigma.GraphicsMill.Transforms.CombineMode.Alpha
combiner.SourceBitmap = fgImage
combiner.SourceRectangle = New System.Drawing.RectangleF(0, 0, fgImage.Width, fgImage.Height)
combiner.DestinationRectangle = New System.Drawing.RectangleF(100, 100, fgImage.Width, fgImage.Height)
combiner.ApplyTransform(bgImage)
		
bgImage.Save("Y:\Result.png")
The another way is described in the "Overlaying Images" article. Code sample introduced in this article solves the same task of drawing transparent image on the another one.

Edited by user Wednesday, October 29, 2008 1:14:08 PM(UTC)  | Reason: Not specified

gurdevs  
#3 Posted : Friday, September 8, 2006 4:40:51 AM(UTC)
gurdevs

Rank: Member

Groups: Member
Joined: 9/8/2006(UTC)
Posts: 1

Alex,

We tried to use the below written code to mask the user selected image using ApplyMaskTransform method of the combiner class. We used one masked bitmap to get the required area from the image selected by user.

Please look into this code as this is not producing the expected results and we need the solution very urgently.

Code:
        Dim maskImage As New Aurigma.GraphicsMill.Bitmap()
        Dim userImage As New Aurigma.GraphicsMill.Bitmap()

        maskImage.Load("d:\test\mask.bmp") 'this is the mask bitmap with black pixels to be used for masking
        userImage.Load("d:\test\userimage.jpg") 'this is the user selected image

        maskImage.ColorManagement.Convert(PixelFormat.Format8bppGrayScale)
        Dim combiner As New Aurigma.GraphicsMill.Transforms.Combiner
        combiner.CombineMode = Aurigma.GraphicsMill.Transforms.CombineMode.Alpha
        combiner.SourceBitmap = userImage
        combiner.Opacity = 1
        'combiner.SourceRectangle = New System.Drawing.RectangleF(0, 0, maskImage.Width, maskImage.Height)
        'combiner.DestinationRectangle = New System.Drawing.RectangleF(0, 0, maskImage.Width, maskImage.Height)
        combiner.ApplyMaskTransform(userImage, maskImage) 'we expect that only the masked area will get the image from user image
        userImage.Save("d:\test\Result1.png")

Thanks in advance.

Regards,

Gurdev Singh

Edited by user Wednesday, December 19, 2007 2:40:43 PM(UTC)  | Reason: Not specified

Alex Kon  
#4 Posted : Friday, September 8, 2006 5:14:09 PM(UTC)
Alex Kon

Rank: Advanced Member

Groups: Member
Joined: 1/31/2005(UTC)
Posts: 458

Was thanked: 5 time(s) in 5 post(s)
Hello,

I'm not sure that I have completely understood desired result of the posted code. As I understood, you want to make some areas of user image transparent depending on specified mask. If so, the following code sample implements the described behaviour.

Code:
Dim userImage As New Aurigma.GraphicsMill.Bitmap("X:\AllFormats\24bppRgb_LancerEvo.jpg")
Dim maskImage As New Aurigma.GraphicsMill.Bitmap(userImage.Width, userImage.Height, Aurigma.GraphicsMill.PixelFormat.Format24bppRgb)
Dim resultImage As New Aurigma.GraphicsMill.Bitmap(userImage.Width, userImage.Height, Aurigma.GraphicsMill.PixelFormat.Format32bppArgb)
				
'Prepare user's selection mask (For simplicity, let user selected [x = 100, y = 100, width = 400, height = 600] ellipse):
Dim maskRect As New System.Drawing.RectangleF(100, 100, 400, 600)
Dim g As System.Drawing.Graphics = maskImage.GetGdiplusGraphics()
Try
	g.FillEllipse(System.Drawing.Brushes.White, maskRect)
Finally
	g.Dispose()
End Try
maskImage.ColorManagement.Convert(Aurigma.GraphicsMill.PixelFormat.Format8bppGrayScale)
maskImage.Save("Y:\Mask.tif")
				
'Apply combine transform with specified mask
Dim combiner As New Aurigma.GraphicsMill.Transforms.Combiner
combiner.CombineMode = Aurigma.GraphicsMill.Transforms.CombineMode.Copy
combiner.SourceBitmap = userImage
combiner.SourceRectangle = New System.Drawing.RectangleF(0, 0, userImage.Width, userImage.Height)
combiner.DestinationRectangle = New System.Drawing.RectangleF(0, 0, userImage.Width, userImage.Height)
combiner.ApplyMaskTransform(resultImage, maskImage)
				
resultImage.Save("Y:\Result.tif")

Edited by user Wednesday, December 19, 2007 2:42:58 PM(UTC)  | Reason: Not specified

Users browsing this topic
Forum Jump  
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.