Einzelnen Beitrag anzeigen

Benutzerbild von Neutral General
Neutral General

Registriert seit: 16. Jan 2004
Ort: Bendorf
5.219 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#1

OleLoadPicture Spiegelverkehrt

  Alt 9. Okt 2007, 11:59
Hi,

Hab im Forum danach gesucht wie man nonvcl Bilder laden kann.. Vorallem jpgs. Bin Dann auf diese ActiveX Methode gestoßen und es funktioniert bisher auch. Also die Dateien werden geladen und ich kann sie auch darstellen. Zeichen tu ich die Bilder so:


Delphi-Quellcode:
procedure TNVCLImage.DoPaint;
var cr: TRect;
    dc: HDC;
    w,h: Integer;
begin
  if not Assigned(FPicture) then
    exit;
  dc := GetDC(FHandle);
  cr := Rect(FLeft,FTop,FWidth,FHeight);
  w := MulDiv(Picture.Width, GetDeviceCaps(dc, LOGPIXELSX), 2540); //Picture.Width = FPicture.get_Width
  h := MulDiv(Picture.Height, GetDeviceCaps(dc, LOGPIXELSX), 2540);
  FPicture.Render(dc,0,0,w,h,0,0,picture.Width,picture.Height,cr); // <---
  ReleaseDC(FHandle,dc);
end;
In der markierten Zeile wird das Bild letztendlich gemalt.
Hier die Definition:

Delphi-Quellcode:
HRESULT Render(
  HDC hdc, //Handle of device context on which to render the image
  long x, //Horizontal position of image in hdc
  long y, //Vertical position of image in hdc
  long cx, //Horizontal dimension of destination rectangle
  long cy, //Vertical dimension of destination rectangle
  OLE_XPOS_HIMETRIC xSrc,
           //Horizontal offset in source picture
  OLE_YPOS_HIMETRIC ySrc,
           //Vertical offset in source picture
  OLE_XSIZE_HIMETRIC cxSrc,
           //Amount to copy horizontally in source picture
  OLE_YSIZE_HIMETRIC cySrc,
           //Amount to copy vertically in source picture
  LPCRECT prcWBounds
           //Pointer to position of destination for a metafile hdc
);
Im Internet und auch hier hab ich oft Aufrufe der Art gefunden:

Delphi-Quellcode:
Picture.get_Height(hmHeight);
Picture.get_Width(hmWidth);
nWidth := MulDiv(hmWidth,GetDeviceCaps(DC,LOGPIXELSX),2540);
nHeight := MulDiv(hmHeight,GetDeviceCaps(DC,LOGPIXELSY),2540);

pPic.Render(DC,0,0,nWidth,nHeight,0,hmHeight,hmWidth, -hmHeight,rc);
Aber das liefert bei mir komische Ergebnisse und ich finde diese Aufruf total unlogisch. Mein Problem ist jetzt das mein Bild sowohl horizontal als auch vertikal spiegelverkehrt gezeichnet wird. Was mach ich dagegen? Kann man das ändern indem man Render anders aufruft? Also ich hab schon alles Mögliche versucht aber es hat nichts genutzt..

Gruß
Neutral General
Michael
"Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."
  Mit Zitat antworten Zitat