Bildposition berechnen
-
Ich lade ein Bild und füge es über Gdi in ein Image ein. Ziel soll sein es mittig zu positionieren. Jedoch sind alle Bilder eine ganze Ecke nach rechts versetzt, was mir aber nicht einleuchtet. Hat jemand eine Idee, was falsch ist ?
int iw = image.GetWidth(); // = 188 int ih = image.GetHeight(); // = 487 if (iw < ImageZiel->Width) // ImageZiel->Width = 561 { iXPos = ((ImageZiel->Width - iw) / 2); // iXPos = 186 } Gdiplus::Rect destRect(iXPos, 0, iw, ih); graphics.DrawImage(&image, destRect);
-
Das dürfte damt was zu tun haben
if (iw < ImageZiel->Width) // ImageZiel->Width = 561 { iXPos = ((ImageZiel->Width - iw) / 2); // iXPos = 186 }