Power BI

Content by Charles Sterling

Adding Watermarks and saving images

Had a question from the NZ DL:


I would like to add text directly into a image and save the new image

back to file.


I am currently creating a Graphic object, this works when displaying to a screen,  but I need to beable to save back to a new image file the results:


Bitmap myBitmap = new Bitmap(filename);

myGraphic = new BuildGraphic(myBitmap);

Font drawFont = new Font(myFont, myFontSize);

StringFormat drawFormat = new StringFormat();

SolidBrush drawBrush = new SolidBrush(Color.Black);

myGraphics.DrawString(“The text I am adding”, drawFont, drawBrush, myX, myY, drawFormat);




This person is SO close!!! Just missing one line!





For those of us who code in VB i have included the same code below.


Dim myBitmap As Bitmap = New Bitmap(“c:\test.bmp”)

        Dim myGraphics As Graphics

        myGraphics = Graphics.FromImage(myBitmap)

        myGraphics.DrawString(“The text I am adding”, New Font(“Arial”, 24), Brushes.DarkBlue, 10, 10)



        ‘Assuming a Windows Form app

        myGraphics = Me.CreateGraphics

        myGraphics.DrawImage(myBitmap, 1, 1)




If this is for Web applications contention will be a huge issue and http handlers should be used as outlined at: