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
template.Load("Y:\Tests\Birthday6.jpg")
photo.Load("Y:\Tests\smallCat.jpg")
template.ColorManagement.Convert(Aurigma.GraphicsMill.PixelFormat.Format32bppArgb)
Dim placeholderCenter As New System.Drawing.PointF(350, 100)
CutThroughPlaceholder(template, placeholderCenter)
Dim canvas As New Aurigma.GraphicsMill.Bitmap(template.Width, template.Height, Aurigma.GraphicsMill.PixelFormat.Format24bppRgb)
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)
template.Draw(canvas, 0, 0, template.Width, template.Height, Aurigma.GraphicsMill.Transforms.CombineMode.Alpha,
1.0F, Aurigma.GraphicsMill.Transforms.InterpolationMode.HighSpeed)
canvas.Save("y:/Tests/Result.jpg")
End Sub
Edited by user 17 years ago
| Reason: Not specified |