Rank: Advanced Member
  Groups: Guest
 Joined: 1/31/2005(UTC) Posts: 458
  Was thanked: 5 time(s) in 5 post(s)
  
 
     | 
	
    
        
            
	      
                Dear San, There is no universal way to implement this task when your templates have no alpha channel. For images which are similar to the sample, which you have posted, I can suggest the following decision:   convert image to Argb32 format, cut through alpha channel at the placeholder areas using FloodFill transform.  The following code sample illustrates key points of the approach:Code:    Private Sub CutThroughPlaceholder(ByVal image As Aurigma.GraphicsMill.Bitmap, ByVal startPoint As System.Drawing.PointF)
        Dim floodFill As New Aurigma.GraphicsMill.Transforms.FloodFill
        floodFill.Point = startPoint
        floodFill.Tolerance = 0.20000000000000001
        floodFill.TargetColor = CType(image.GetPixel(startPoint.X, startPoint.Y).Clone(), Aurigma.GraphicsMill.Color)
        floodFill.FillColor = Aurigma.GraphicsMill.RgbColor.FromArgb(0, 0, 0, 0)
        floodFill.PreserveAlpha = False
        floodFill.ProcessHalftones = True
        floodFill.ApplyTransform(image)
    End Sub
                    
                
    Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim template As New Aurigma.GraphicsMill.Bitmap
        Dim photo As New Aurigma.GraphicsMill.Bitmap
	
        'Load source images
        template.Load("Y:\Tests\Birthday6.jpg")
        photo.Load("Y:\Tests\smallCat.jpg")
	
        'Cut through placeholders in the template. 
        'They are hard-coded in the sample, in real application they
        'can be read from template information or can be requested from user.
        template.ColorManagement.Convert(Aurigma.GraphicsMill.PixelFormat.Format32bppArgb)
        Dim placeholderCenter As New System.Drawing.PointF(350, 100)
        CutThroughPlaceholder(template, placeholderCenter)
	
        'Merge all images into result one.
        Dim canvas As New Aurigma.GraphicsMill.Bitmap(template.Width, template.Height, Aurigma.GraphicsMill.PixelFormat.Format24bppRgb)
	
        'Also you should decide how to output your photos. The code below calculates destination 
        'coordinates of the photos to place its center to the placeholder 
        'center specified in the previous step. Resize transformation has not been applied.
	
        'Place photo
        Dim dstX, dstY As Integer
        dstX = CInt(placeholderCenter.X - photo.Width / 2)
        dstY = CInt(placeholderCenter.Y - photo.Height / 2)
        photo.Draw(canvas, dstX, dstY, photo.Width, photo.Height, Aurigma.GraphicsMill.Transforms.CombineMode.Copy,
                1.0F, Aurigma.GraphicsMill.Transforms.InterpolationMode.HighSpeed)
	
        'Overlay template 
        template.Draw(canvas, 0, 0, template.Width, template.Height, Aurigma.GraphicsMill.Transforms.CombineMode.Alpha,
                 1.0F, Aurigma.GraphicsMill.Transforms.InterpolationMode.HighSpeed)
	
        'Save the result
        canvas.Save("y:/Tests/Result.jpg")
    End Sub 
 Edited by user Tuesday, January 1, 2008 5:01:26 AM(UTC)
 | Reason: Not specified    |