Image Modofication

  • Thread starter Thread starter Samuel Shulman
  • Start date Start date
S

Samuel Shulman

Hi everyone,

I would like to implement the following functionality

Program to read image file, add a layer on top (partially transparent), then
save the images with these changes

How can that be achieved?

Thank you,
Samuel
 
Samuel Shulman said:
Program to read image file, add a layer on top (partially transparent),
then save the images with these changes

How can that be achieved?

Check out the 'System.Drawing.Bitmap' class.
 
Addendum:

I forgot to mention the 'Graphics' class, which can be used to draw another
bitmap onto your bitmap using its 'DrawImage' method. A 'Graphics' object
for a bitmap can be obtained using 'Graphics.FromImage'.
 
This is the code

Note that the original image can't be used!

Thanks,
Samuel
Public Shared Sub AddTextToImage(ByVal sImageFilePath As String)

Dim org As Bitmap = Image.FromFile(sImageFilePath)

Dim bm As Bitmap = New Bitmap(org.Width, org.Height) ') '; << Can specify
optional pixel format but defaults to 32bppArgb

Dim g As Graphics = Graphics.FromImage(bm)

g.DrawImage(org, 0, 0, org.Width, org.Height)





Dim objFont As System.Drawing.Font

g.TextRenderingHint = TextRenderingHint.AntiAlias

'//Draw other stuff on g here...

objFont = New Font("Comic Sans MS", 75, FontStyle.Bold)

' Write out the text

g.DrawString("Sold", objFont, Brushes.CornflowerBlue, 28, 100)





org.Dispose()

g.Dispose()

'delete the previous file

IO.File.Delete(sImageFilePath)

bm.Save(sImageFilePath, Imaging.ImageFormat.Jpeg)

bm.Dispose()

End Sub
 
Back
Top