PDA

View Full Version : سوال: تغییر اندازه عکس در چاپ



sohrabi1383
جمعه 06 دی 1392, 16:19 عصر
وقتی با استفاده از pictureBox یک عکس را چاپ می کنم اندازه اش خیلی بزرگ است چگونه می توانیم آن را تغییر اندازه دهیم فایل ضمیمه فرستاده شده



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Drawing.Printing;

namespace print4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}// public Form1()
private void button1_Click(object sender, EventArgs e)
{
PrintDocument objPrintDocument = new PrintDocument();
objPrintDocument.DocumentName = "student";
printDialog1.AllowPrintToFile = false;
printDialog1.AllowSelection = false;
printDialog1.AllowSomePages = false;
printDialog1.Document = objPrintDocument;
if (printDialog1.ShowDialog() == DialogResult.OK)
{
objPrintDocument.PrintPage += new PrintPageEventHandler(prtPage);
objPrintDocument.Print();
}//if (printDialog1.ShowDialog() == DialogResult.OK)
}// private void button1_Click(object sender, EventArgs e)
private void prtPage(object sender, PrintPageEventArgs e)
{
string drawString = "من به مدرسه رفتم.";
SolidBrush drawBrush = new SolidBrush(Color.Black);
Font drawFont = new System.Drawing.Font("Arail", 10);
RectangleF recAtZero = new RectangleF(0, 0, e.PageBounds.Width, e.PageBounds.Height );
StringFormat drawFormat = new StringFormat();
drawFormat.FormatFlags = StringFormatFlags.DirectionRightToLeft;
e.Graphics.DrawString(drawString, drawFont, drawBrush, recAtZero, drawFormat);
RectangleF recAtGreaterThantZero = new RectangleF(300, 0, e.PageBounds.Width, e.PageBounds.Height );
e.Graphics.DrawString(drawString, drawFont, drawBrush, recAtGreaterThantZero, drawFormat);
//چاپ با دستور زیر انجام می گیرد ولی تصویر خیلی بزرگ است می خواهم آن را تغییر اندازه دهم
e.Graphics.DrawImage(pictureBox1.Image,0,0);

}//private void prtPage(object sender, PrintPageEventArgs e)
}// public partial class Form1 : Form
}//namespace print4

sohrabi1383
دوشنبه 09 دی 1392, 21:39 عصر
یعنی هیچ کس تغییر اندازه عکس را بلد نیست.

sohrabi1383
سه شنبه 17 دی 1392, 21:43 عصر
خودم فهمیدم با ید


e.Graphics.DrawImage(pictureBox1.Image,0,0,52,63);


بنویسیم که 52 و 63 ارتفاع و طول عکس در چاپ هستند.