G
Hi,
Ich habe eine Liste in der die Dateinamen mehrerer Bilder stehen. Wenn ich einen Dateinamen auswähle wird das Bild von der Feastplatte geladen und in einem Vorschaufenster angezeigt (langsam bei großen Bildern).
Wie kann ich die Bilder vorladen um schneller darauf zugreifen zu können (RAM spielt keine Rolle ;-)).
Hier ist mein bisheriger Weg:
// Method to load an image in the preview field of the main dialog
void CMyImagePreview::LoadImage(CString csFileName)
{
m_pImage = new Gdiplus::Bitmap(CStringW(csFileName));
int iImageWidth = m_pImage->GetWidth();
int iImageHeight = m_pImage->GetHeight();
CRect aRect;
this->GetClientRect(aRect);
double hf = (double)aRect.Width() / (double)iImageWidth;
double vf = (double)aRect.Height() / (double)iImageHeight;
m_ScaleFactor = MyMin(hf,vf);
this->Invalidate();
this->UpdateWindow();
}
void CMyImagePreview::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
CRect aRect;
this->GetClientRect(&aRect);
dc.FillSolidRect(&aRect, RGB(0, 0, 0));
dc.SetROP2(R2_NOT);
if(m_pImage == NULL)
return;
Gdiplus::Graphics aGraphics(this->GetSafeHwnd());
if(m_pImage != NULL)
{
int iNewWidth = (int)(m_pImage->GetWidth() * m_ScaleFactor);
int iNewHeight = (int)(m_pImage->GetHeight() * m_ScaleFactor);
int iDx = (aRect.Width() - iNewWidth) / 2;
int iDy = (aRect.Height() - iNewHeight) / 2;
aGraphics.DrawImage(m_pImage, iDx, iDy, iNewWidth, iNewHeight);
}
// Do not call CStatic::OnPaint() for painting messages
}
Greetz,
gomo