Jump to content

Modify a BMP

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
Blaze

Blaze

    Programmer

  • Members
  • PipPipPipPip
  • 117 posts
I'm working on a project where I have to print text over an image. I have this code so far but it doesn't print anything. Not even the image. Can someone take a look at my code and see why it isn't printing antyhing:


System.Drawing.Image bgimage = System.Drawing.Image.FromFile("c:\\image.bmp");

            Bitmap bmp = new Bitmap(1,1);

            Graphics g = Graphics.FromImage(bmp);


            // Set the color of our object

			Brush br = new SolidBrush(Color.Black);

            Pen pr = new Pen(Color.Black);



#2
Guest_Jordan_*

Guest_Jordan_*
  • Guests
You need a PrintPageEventArgs passed through the function and then do:

// Draw a picture 
e.Graphics.DrawImage(Image.FromFile("C:\\pic.bmp"), e.Graphics.VisibleClipBounds);

After that you can use pens, brushes, drawlines and the whole thing on the image.

#3
Guest_NeedHelp_*

Guest_NeedHelp_*
  • Guests
Or you can use

e.Graphics.DrawImage(Image.FromFile("C:\\pic.bmp"), 0,0,500,500); 

Replace 500/500 with your own width and height.

#4
Blaze

Blaze

    Programmer

  • Members
  • PipPipPipPip
  • 117 posts
Thank you, that is exactly what I needed. That was the only place I was being held back. I have all my data already crated using code like:

g.DrawString(m_Parent.shipTo1.Text, m_LargeFont, br, 11, 24);
            g.DrawString(m_Parent.shipTo2.Text, m_LargeFont, br, 11, 41);