1
C#을 사용하여 큰 이미지를 작은 사각형으로 표시하려고합니다. 문제는 사각형 크기와 이미지를 조정하지 않으면 매번 이미지의 절반 만 표시된다는 것입니다. 정의 된 범위 내에서 이미지를 완전히 인쇄 할 수있는 방법이 있습니까? 내 말은 이미지가 사각형 크기에 맞게 크기를 조정할 수 있다는 뜻입니까?큰 이미지 표시 C#
int imagePrintHeight = this.PaperSize.Width - this.PrintMargins.Top - this.PrintMargins.Bottom;
int imagePrintWidth = this.PaperSize.Height - this.PrintMargins.Left - this.PrintMargins.Right;
Size DatestoPrintSize = TextRenderer.MeasureText(DatestoPrint, new Font(this.Font.FontFamily, 10));
y = y + descriptionSize.Height + DatestoPrintSize.Height;
imagePrintHeight = imagePrintHeight - descriptionSize.Height - DatestoPrintSize.Height;
e.Graphics.DrawString(objCurrentPrintJob.sDescription, new Font(this.Font.FontFamily, 10), new SolidBrush(Color.Black), x + (imagePrintWidth - descriptionSize.Width)/2, this.PrintMargins.Top);
e.Graphics.DrawString(DatestoPrint, new Font(this.Font.FontFamily, 10), new SolidBrush(Color.Black), x + (imagePrintWidth - DatestoPrintSize.Width)/2, this.PrintMargins.Top + descriptionSize.Height);
}
decimal ratio = Math.Round(decimal.Divide(imagetoPrint.Width, imagetoPrint.Height), 4);
int tempimagePrintWidth = (int)(Math.Round(imagePrintHeight * ratio, 4));
x += (int)((imagePrintWidth - tempimagePrintWidth)/2);
난 내가 제대로 이해하면, 당신이 사용할 수있는 페이지 크기로 이미지에 맞게하려고하는 것 같다
e.Graphics.DrawImage(imagetoPrint, new Rectangle(x,y ,tempimagePrintWidth,imagePrintHeight));
답변이 도움이 되었습니까? 이 경우이를 수락하거나 문제가 계속되면 더 많은 정보를 제공하십시오. – ekholm
@ekholm 제공된 대답으로 내 문제가 해결되지 않습니다. – abdul
그래, 어쩌면 내가 그 질문에 대해 오해했거나 틀린 다른 것이있다. 여전히 도움이 필요하면 문제가 무엇인지 명확히하십시오. – ekholm