![]() |
Abmessungen von Bilddateien per GDI+ ermitteln
Dieser kleine Tipp beschreibt wie man mit Hilfe von
![]()
Delphi-Quellcode:
type
GDIPlusStartupInput = record GdiPlusVersion: integer; DebugEventCallback: integer; SuppressBackgroundThread: integer; SuppressExternalCodecs: integer; end; var hGDIP: Cardinal; StartUpInfo: GDIPlusStartupInput; GdiplusStartup: function(var token: Integer; var lpInput: GDIPlusStartupInput; lpOutput: Integer): Integer; stdcall; GdiplusShutdown: function(var token: Integer): Integer; stdcall; GdipLoadImageFromFile: function(FileName: PWideString; var image: Integer): Integer; stdcall; GdipGetImageDimension: function(image: Integer; var Width, Height: Single): Integer; stdcall; GdipDisposeImage: function(image: Integer): Integer; stdcall; GdipToken: Integer; hImg: Integer; ImgWidth, ImgHeight: Single; UnicodeFileName: WideString;
Delphi-Quellcode:
[edit=Chakotay1308]Delphi-Style und -Tags korrigiert. Mfg, Chakotay1308[/edit]
hGDIP := LoadLibrary('gdiplus.dll');
if hGDIP <> 0 then begin GdiplusStartup := GetProcAddress(hGDIP, 'GdiplusStartup'); if Assigned(GdiplusStartup) then begin FillChar(StartUpInfo, SizeOf(StartUpInfo), 0); StartUpInfo.GdiPlusVersion := 1; if GdiplusStartup(GdipToken, StartUpInfo, 0) = 0 then begin GdiplusShutdown := GetProcAddress(hGDIP, 'GdiplusShutdown'); GdipLoadImageFromFile := GetProcAddress(hGDIP, 'GdipLoadImageFromFile'); GdipGetImageDimension := GetProcAddress(hGDIP, 'GdipGetImageDimension'); GdipDisposeImage := GetProcAddress(hGDIP, 'GdipDisposeImage'); UnicodeFileName := 'YOUR IMAGE FILE HERE'; if GdipLoadImageFromFile(PWideString(UnicodeFileName), hImg) = 0 then begin GdipGetImageDimension(hImg, ImgWidth, ImgHeight); // Do something with the results here! MessageBox(FloatToStr(ImgWidth) + 'x' + FloatToStr(ImgHeight), 'Bildgröße'); GdipDisposeImage(hImg); end; GdiplusShutdown(GdipToken); end; end; FreeLibrary(hGDIP); end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:02 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