Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi OleLoadPicture Spiegelverkehrt (https://www.delphipraxis.net/101169-oleloadpicture-spiegelverkehrt.html)

Neutral General 9. Okt 2007 11:59


OleLoadPicture Spiegelverkehrt
 
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


Alle Zeitangaben in WEZ +1. Es ist jetzt 06:34 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz