By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,550 Members | 908 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,550 IT Pros & Developers. It's quick & easy.

Merge Images

P: n/a
Hi

I want to write an application that can merge two images with a bit of
re-sizing and changing of opacity thrown in for good measure.

I have a backdrop that can be in any format and an overlay image that will
be a 48x48 png file.

I want to take the overlay image, resize it to about 130x130, set the
opacity to 20% and then place this image onto the back drop about 30px the
edges in the bottom left corner. The final task would be to save this image
to disk.

Does anyone have any ideas/concepts on the best way to achieve this?

Regards, Carl Gilbert
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi

Drawing Transparent Images and Shapes using Alpha Blending
http://www.vbdotnetheaven.com/Code/Aug2003/2149.asp

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim bgImg As New Bitmap("Back.png")
'Because FromImage did not support all format, we need to convert it first.
bgImg.Save("c:\test.jpg", ImageFormat.Jpeg)
bgImg = Image.FromFile("c:\test.jpg")
Dim g As Graphics = Graphics.FromImage(bgImg)
Dim fgImg As New Bitmap("mario.jpg")

Dim ptsArray As Single()() = {New Single() {1, 0, 0, 0, 0}, New
Single() {0, 1, 0, 0, 0}, New Single() {0, 0, 1, 0, 0}, New Single() {0, 0,
0, 0.5F, 0}, New Single() {0, 0, 0, 0, 1}}
Dim clrMatrix As New ColorMatrix(ptsArray)
Dim imgAttributes As New ImageAttributes
imgAttributes.SetColorMatrix(clrMatrix, ColorMatrixFlag.Default,
ColorAdjustType.Bitmap)
g.DrawImage(fgImg, New Rectangle(0, 0, 100, 100), 0, 0,
fgImg.Width, fgImg.Height, GraphicsUnit.Pixel, imgAttributes)
Me.PictureBox1.Image = bgImg
' Or Save the bgImg directly
End Sub

For the detailed information about ColorMatrix, you may take a look at the
link below.
Using a Color Matrix to Set Alpha Values in Images
http://msdn.microsoft.com/library/de...us/gdicpp/GDIP
lus/usingGDIPlus/alphablendinglinesandfills/usingacolormatrixtosetalphavalue
sinimages.asp
Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #2

P: n/a


Thanks for the reply Peter. Your code worked just fine. Thats saved me
hours of messing about in Photoshop all the time.

*** Sent via Developersdex http://www.developersdex.com ***
Nov 21 '05 #3

P: n/a
Hi Carl,

Thanks for your quickly reply!
I am glad that my suggestion helps you.
Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.