아마 메모리 스트림에 어떻게 든? 이 경우이미지 크기를 더 빨리 변경할 수있는 방법이 있습니까?
private void satellitesToolStripMenuItem_Click(object sender, EventArgs e)
{
file_array_satellite = Directory.GetFiles(UrlsPath, "RainImage*.*");
for (int i = 0; i < file_array_satellite.Length; i++)
{
Image s = new Bitmap(file_array_satellite[i]);
s = resizeImage(s, new Size(100, 100));
s.Save(UrlsPath + "Changed" + i.ToString("D6") + ".jpg");
}
file_array_satellite = Directory.GetFiles(UrlsPath, "Changed*.*");
if (file_array_satellite.Length > 0)
{
DateTime[] creationTimes8 = new DateTime[file_array_satellite.Length];
for (int i = 0; i < file_array_satellite.Length; i++)
creationTimes8[i] = new FileInfo(file_array_satellite[i]).CreationTime;
Array.Sort(creationTimes8, file_array_satellite);
file_indxs_satellite = 0;
file_indxs_satellite = file_array_satellite.Length - 1;
timer1.Enabled = true;
}
}
public static Image resizeImage(Image imgToResize, Size size)
{
return (Image)(new Bitmap(imgToResize, size));
}
private void pictureBox1_MouseEnter(object sender, EventArgs e)
{
file_array_satellite = Directory.GetFiles(UrlsPath, "RainImage*.*");
for (int i = 0; i < file_array_satellite.Length; i++)
{
Image s = new Bitmap(file_array_satellite[i]);
s = resizeImage(s, new Size(500, 500));
}
this.pictureBox1.Size = new Size(500, 500);
pictureBox1.Location = new Point(this.Bounds.Width/3,
this.Bounds.Height/3);
this.pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
pictureBox1.BringToFront();
}
난의 이미지를 도시하고있어 PictureBox를 그래서이 100,100으로 이미지 크기를 변경하고있는 PictureBox에 표시 100,100 의 크기이다. 그런 다음 그림 상자가 pictureBox 영역 위로 마우스를 이동하면 그림 상자가 양식의 가운데로 이동하고 pictureBox의 크기를 500,500으로 조정하고 이미지 크기를 500,500으로 다시 변경하고 pictureBox에 표시합니다.
하드 디스크의 이미지 크기를 변경하거나 변환 할 때마다 매 3-5 초 정도 걸립니다.
더 빠른 방법으로 크기를 변환 할 수 있습니까?
편집 **
은 현재 디스플레이 이미지 크기를 조정하려고 코드를 변경하지만 pictureBox1의 이미지가 지금 같은 크기에없는과 내가있는 PictureBox에서 애니메이션을 볼 수 없습니다.
private void timer1_Tick(object sender, EventArgs e)
{
try
{
Image s = new Bitmap(file_array_satellite[file_indxs_satellite]);
s = resizeImage(s, new Size(100, 100));
pictureBox1.Load(file_array_satellite[file_indxs_satellite]);
file_indxs_satellite = file_indxs_satellite - 1;
if (file_indxs_satellite < 0)
{
file_indxs_satellite = file_array_satellite.Length - 1;
}
}
catch
{
timer1.Enabled = false;
}
}
private void satellitesToolStripMenuItem_Click(object sender, EventArgs e)
{
file_array_satellite = Directory.GetFiles(UrlsPath, "RainImage*.*");
if (file_array_satellite.Length > 0)
{
DateTime[] creationTimes8 = new DateTime[file_array_satellite.Length];
for (int i = 0; i < file_array_satellite.Length; i++)
creationTimes8[i] = new FileInfo(file_array_satellite[i]).CreationTime;
Array.Sort(creationTimes8, file_array_satellite);
file_indxs_satellite = 0;
file_indxs_satellite = file_array_satellite.Length - 1;
timer1.Enabled = true;
}
}
public static Image resizeImage(Image imgToResize, Size size)
{
return (Image)(new Bitmap(imgToResize, size));
}
미리 이미지를 메모리에로드하십시오. –
이것이 더 빠르면 잘 모르겠지만 더 간단 할 수도 있습니다 ... Image.GetThumbnailImage(); – series0ne
그림 상자에 이미지 파일 중 하나만 표시 할 수있는 경우 전체 디렉터리에 이미지 파일을 반복하고 크기를 조정하는 이유는 분명하지 않습니다. 이것은 느릴 것으로 예상됩니다. 똑똑한 코드를 작성하고 표시된 이미지의 크기 만 조절하십시오. –