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 : Sunday, August 20, 2006 5:27:32 PM(UTC)
san

Rank: Member

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

dear Alex,

Plz provide me code for combine two image , combine the image according to the location provide and it looks like a frame within another image,

thanks

san

Alex Kon  
#2 Posted : Monday, August 21, 2006 1:09:15 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,

No problem - the article "Overlaying images" in knowledge base covers the issue. It also contains the code sample which you can use as start point.

Edited by user Monday, October 27, 2008 11:07:18 PM(UTC)  | Reason: Not specified

san  
#3 Posted : Wednesday, August 23, 2006 1:15:04 PM(UTC)
san

Rank: Member

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

Dear Alex ,

i m sending a sample picture whcich show my requirement to merge the two image.

i m not geting that how to merge with Overlay method,

Hope for propmt reply

san attached the following image(s):
10. Greeting Cards 4.jpg
Alex Kon  
#4 Posted : Wednesday, August 23, 2006 2:03:48 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

The screenshot is rather pretty, but it contains too little information. The simplest way I can suggest is to draw the original "photo" image over the "frame". In such case you need following input data:

1) frame & photo bitmaps

2) left-top corner coordinates of the destination area on the frame.

So, you just call the draw method:

Code:
photo.Draw(frame, destLocation.X, destLocation.Y, photo.Width, photo.Height,
      Transforms.CombineMode.Copy, 1.0F, Transforms.InterpolationMode.HighQuality)
If your photo should be cropped (as I can see on the screenshot) you should also take into account crop rectangle. I suppose that it will be something like that:
Code:
Dim cropRect As New System.Drawing.Rectangle
... <obtaining real value of the crop rect> ... 
photo.Draw(frame, destLocation.X, destLocation.Y, cropRect.Width, cropRect.Height, cropRect.X, cropRect.Y,
      cropRect.Width, cropRect.Height, Transforms.CombineMode.Copy, 1.0f, Transforms.InterpolationMode.HighQuality)
Another scenario is if your frame images have alpha-channel with holes used as placeholders for photos. In such case you should combine images in reverse order - draw frame over photo with CombineMode.Alpha. And there are also many other alternative ways to implement this task. Their choice is only your decision.

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

san  
#5 Posted : Wednesday, August 23, 2006 7:21:17 PM(UTC)
san

Rank: Member

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

Dear Alex,

Thanx ,

that code is working fne , another requirement is , How to add text into the image in specified location depends upon the user click means text will be inserted at the mouse click,

Reply ASAP,

Thanx & regards

san

Alex Kon  
#6 Posted : Wednesday, August 23, 2006 7:48:19 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,

No problem again ;) - look this article if you want use GdiGraphics (and, GDI text rendering subsystem accordingly). If you prefer GDI+ text renderer - you should obtain System.Drawing.Graphics object by calling GetGdiplusGraphics method of the Aurigma.GraphicsMill.Bitmap class. The next step is to draw text as usual with System.Drawing.Graphics.DrawString(...) method.

To get user click coordinates you may handle WorkspaceMouseDown event of the Aurigma.GraphicsMill.BitmapViewer control.

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

san  
#7 Posted : Friday, September 1, 2006 5:37:38 PM(UTC)
san

Rank: Member

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

Dear Alex

PLs give the code advie t set the image in this template (attached sample template named-birthday6.jpg).

Here there is two space to fit two image .

And another query is ,if the place holder is in Heart shape or circle then how set the square image rectanle to that area?

PLZ reply ASAP,

thanx

san

san attached the following image(s):
birthday6.jpg
Alex Kon  
#8 Posted : Sunday, September 3, 2006 5:43:02 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)
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

    Users browsing this topic
    Guest
    Similar Topics
    Combine Two Image With combiner Class (Discussions – Graphics Mill)
    by san 9/7/2006 12:13:42 AM(UTC)
    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.