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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

PowerPoint High Resolution Images from PowerPoint 0
Draw and image vertically 5
Transparent BackGround 11
Scroll picture box 2
Use of resource images 3
Developing Application like Photoshop 2
Help reading exif info 2
Merging Bitmaps 6

Back
Top