Click here to Skip to main content
15,902,447 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
my code is
C#
DataSet ds = new DataSet();
string strsql = "select * from clue where  id=" + Convert.ToInt32(textBox1.Text);
SqlConnection con = new SqlConnection(strcon);
con.Open();

SqlDataAdapter strada = new SqlDataAdapter(strsql, con);
strada.Fill(ds, "clue");
byte[] MyData = new byte[0];

DataRow myRow;
myRow = ds.Tables["clue"].Rows[0];
MyData = (byte[])myRow["Pic"];
MemoryStream stream = new MemoryStream(MyData);
pictureBox1.Image = Image.FromStream(stream);
con.Close();

// click print button
PrintDocument tmpDoc = new PrintDocument();
tmpDoc.PrintPage += new PrintPageEventHandler(Tmpdoc_Print);
PrintPreviewDialog tmpPpd = new PrintPreviewDialog();
tmpPpd.Document = tmpDoc;
tmpPpd.ShowDialog();
        
private void Tmpdoc_Print(Object sender, PrintPageEventArgs e)
{
   e.Graphics.DrawImage(pictureBox1.Image , 0,0);
}

but print picture with small size not really size
i want print picture with really size
Posted
Updated 29-Oct-12 9:19am
v3
Comments
Sergey Alexandrovich Kryukov 29-Oct-12 15:24pm    
This is not a question. And the problem is not clear. Each picture size is stored in image metadata, so you know the size when you load the bitmap.
--SA

1 solution

Please see my comment to the question. You are using correct DrawImage method, which prints the image with its original size in pixels:
http://msdn.microsoft.com/en-us/library/558kfzex.aspx[^].

It may be possible that your original pictures are that small, or they were re-sampled down before string them. You did not show this code, so check it up. Also, using the class PictureBox might be pointless here. In your code, it does nothing; you use the image itself for printing, not the control. However, you might really want to use this control if you also want to show the image on screen in the simplest way.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900