Embed an Image into another Image
-
Friday, April 18, 2008 10:23 PMHi,
I want ot embed an image into another image. Can anyone suggest me regarding this...
Suppose I want to embed a company logo onto an image.
Regards
RaiderZ
All Replies
-
Saturday, April 19, 2008 1:57 AM
The following code shows how to load an image from a file, overlay another image on it, and then save the results to a file. The overlay file should probably be a format that supports transparency, such as PNG, for good results.
VB:
Code SnippetDim bmp As Bitmap = Bitmap.FromFile(initialFileName)
'This draws another image as an overlay on top of bmp in memory.
'There are additional forms of DrawImage; there are ways to fully specify the 'source and destination rectangles. Here, we just draw the overlay at position (0,0).
Using g As Graphics = Graphics.FromImage(bmp)
End Usingg.DrawImage(Bitmap.FromFile(overlayFileName), 0, 0)
bmp.Save(saveAsFileName, System.Drawing.Imaging.ImageFormat.Png)
C#:
Code SnippetBitmap bmp = Bitmap.FromFile(initialFileName);
// This draws another image as an overlay on top of bmp in memory. // There are additional forms of DrawImage; there are ways to fully specify the // source and destination rectangles. Here, we just draw the overlay at position (0,0).
using (Graphics g = Graphics.FromImage(bmp)){
Bitmap.FromFile(overlayFileName), 0, 0);g.DrawImage(
}
bmp.Save(saveAsFileName, System.Drawing.Imaging.
ImageFormat.Png); -
Monday, April 21, 2008 2:52 PMThanks Binary Coder. Really appreciate your help.


