오늘 수업에서 이미지/퍼즐을 만들기 시작해야만했습니다. 내 이미지가 그대로 유지되거나 자체적으로 크기가 조정되는 것을 제외하고는 괜찮 았습니다.왜 내 이미지의 크기가 자동으로 조정됩니까?
이미지 자체는 300 * 300이지만 이미지 자체 크기를 사용하여 크기를 선언하더라도 코드를 실행하면 192 * 192가됩니다. 당신이 볼 수있는, 그것은 사각형의 크기의 비트 맵 크기를합니다, 그래서 300 * 300를 표시하지 정상적으로
public partial class Form1 : Form
{
private Bitmap Bmp;
private Point BmpLoc;
int x = 0, y = 0;
public Form1()
{
InitializeComponent();
this.Paint += new System.Windows.Forms.PaintEventHandler(Form1_Paint);
}
private void showButton_Click(object sender, EventArgs e)
{
Bmp = new Bitmap("C:\\Users\\Admin\\Desktop\\img.png");
BmpLoc = new Point(0, 0);
Rectangle R = new Rectangle(BmpLoc, Bmp.Size);
int noot = Bmp.Size.Height;
label3.Text = noot.ToString();
this.Invalidate(R);
}
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
if (Bmp != null)
{
e.Graphics.DrawImage(Bmp, BmpLoc);
}
}
:
코드는 다음과 같이 구성?
미리 답변 해 주셔서 감사합니다.
흠. 그 화면에서 192px로 끝나는 것을 어떻게 확인합니까? 스크린 샷? 런타임시 Bmp.Size 란 무엇입니까? – usr
@usr 지그 소 퍼즐 과제의 일부는 커서의 위치를 추가하는 것이므로 커서가 어떤 픽셀인지 볼 수 있습니다. Screenshot : http://imageshack.us/a/img9/7690/37798533.png 흰색 숫자는 BMP의 높이입니다 –