What sense does this make

  • Thread starter Thread starter Steve S
  • Start date Start date
S

Steve S

First heres the process...
- Draw bitmap
- Draw text to it
- Save Bitmap
- Print Bitmap

Now, if I place this inside the PrintPage event, program either freezes or
causes arthmetic errors (on Win98 machines only). However if I just copy
the same code to a KeyPress event and print the bitamp by hitting lets say
F11...it works fine.
 
Thats what I think....it ONLY happens when I print. Heres the offending
code...

try

{

Trace.IndentLevel=0;

Trace.WriteLine("Saving image to File");

const float fLeft = 2.77f;

const float fTop = 2.77f;

RectangleF destRect = new Rectangle(0, 0, 1700, 2800);

Bitmap bFile;

Graphics g;


bFile = new Bitmap(1700,2800);

g = Graphics.FromImage(bFile);

//FontFamily[] families = FontFamily.GetFamilies();

Font f = new Font("Arial",10,FontStyle.Bold);



//CODE TO DRAW

g.DrawImage(new Bitmap(sLargeImage), destRect);

//ADD TEXT

foreach(TextBox t in oTemp.Controls)

{

if(t.Text!="")

{

if(t.Visible==true)

{

g.DrawString(t.Text,

f,

Brushes.DarkRed,

t.Left*fLeft,

t.Top*fTop);

}

}

}

if(this.sCurrPage=="Back")

{

foreach(CheckBox c in oTemp.Controls)

{

if(c.Checked == true)

{

Pen myPen = new Pen(Brushes.Red,3);

g.DrawLine(myPen,

c.Left*fLeft,

(c.Top*fTop+2),

c.Left*fLeft+c.Width,

(c.Top*fTop+2)+c.Height);

}

}

}

g.Dispose();

//SAVE FILE

bFile.Save(Application.StartupPath+"\\Temp\\temp.jpg",System.Drawing.Imaging
..ImageFormat.Jpeg);

Trace.IndentLevel= 1;

Trace.WriteLine("Image Saved");

}

catch(Exception e)

{

MessageBox.Show(e.Message);

Trace.IndentLevel= 1;

Trace.WriteLine("Error Saving Image:" + e.StackTrace);

}
 
Back
Top