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 Übersetzung C++ -> Delphi Probleme (https://www.delphipraxis.net/33772-uebersetzung-c-delphi-probleme.html)

sieppl 12. Nov 2004 11:57


Übersetzung C++ -> Delphi Probleme
 
Hallo!

Ich versuche Funktionen der _ISource30.dll zu wrappen.
ImageSource Webpage

Hier sind Auszüge aus dem C++ Header:

Code:
_IS3EXP_   BOOL IS3CALL _IS3GetJPGDimsEx(HISSRC hSource, UINT32 *puWidth, UINT32 *puHeight, UINT32 *puBitDepth, UINT32 *puColorSpace, ISDPIStruct *pDPIStruct);

// structure used to set DPI to files
#ifndef IS_DPI_STRUCT_DEF
#define IS_DPI_STRUCT_DEF
typedef struct ISDPIStruct_t
{
   UINT32 uDPIX;
   UINT32 uDPIY;
   UINT32 uDPIUnits;
} ISDPIStruct;
#endif
Hier ein bisschen Delphi-Code:
Delphi-Quellcode:
implementation

type
  TDpiStruct = packed record
   DPiX: DWORD;
   DPiY: DWORD;
   DPIUnits: DWORD;
  end;

  PDpiStruct = ^TDpiStruct;

function IS3GetJPGDims(Source: THandle; Width, Height, BitDepth, ColorSpace: DWORD; DpiStruct:PDpiStruct): Bool; stdcall;
..

interface
..
function IS3GetJPGDims; external IS3Dll name '_IS3GetJPGDims';


function ISJPGCMYK(const Filename: string): Boolean;
var
  Width, Height, BitDepth, ColorSpace: DWORD;
  DpiStruct: TDpiStruct;
  Handle: THandle;
  Error: DWord;
begin
  IS3Initialize(PChar('{key}'));
  Result := False;
  FillMemory(@DpiStruct, Sizeof(DpiStruct), 0);
  try
    Handle := IS3OpenFileSource(PAnsiChar(Filename));
    if Handle = 0 then
    begin
      Error := IS3GetLastError;
      Result := Boolean(Error);
      Exit;
    end;
    IS3GetJPGDims(Handle, Width, Height, BitDepth, ColorSpace, @DpiStruct); //Hier knallt es.
  finally
    IS3CloseSource(Handle);
  end;
end;
Den Handle bekomme ich ohne Probleme. Wenn ich nun 'IS3GetJPGDims' in 'ISJPGCMYK' aufrufe knallt es. Ich denke es liegt an den Typen.
Es sind meine ersten Versuche eine dll zu übersetzen, wäre cool wenn ich Starthilfe bekomme.

Grüße

Sebastian

btw: _ISource30.dll ist eine sehr mächtige Sammlung von Tools zur Bildbearbeitung. Für 50 Euro wird dann auch das fette Kreuz aus den Bildern entfernt, wenn man nicht registriert ist. ;)

[edit:]
:oops: äh, ja pointer sollte man nicht ohne sie allozieren in eine funktion geben.
Ich habe 'Width, Height, BitDepth, ColorSpace' jetzt mal mit '0' initialisiert.
Es knallt nicht mehr, aber Ergebnisse bekomme ich nicht zurück. :(

jim_raynor 12. Nov 2004 12:14

Re: Übersetzung C++ -> Delphi Probleme
 
Das * bei Parametern

_IS3EXP_ BOOL IS3CALL _IS3GetJPGDimsEx(HISSRC hSource, UINT32 *puWidth, UINT32 *puHeight, UINT32 *puBitDepth, UINT32 *puColorSpace, ISDPIStruct *pDPIStruct);

das diese Parameter als var oder mittels Pointern übergeben werden müssen.

function IS3GetJPGDims(Source: THandle; var Width, Height, BitDepth, ColorSpace: DWORD; DpiStruct:PDpiStruct): Bool; stdcall;

DPIStruct ist richtig, da es ja als Pointer übergeben wird.

:duck: Keine Garantie für irgendwas ;)

sieppl 12. Nov 2004 12:31

Re: Übersetzung C++ -> Delphi Probleme
 
bingo! danke!

btw: cooles spiel. freue mich schon auf die final version.. ;)


Alle Zeitangaben in WEZ +1. Es ist jetzt 21:39 Uhr.

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