Einzelnen Beitrag anzeigen

TiGü

Registriert seit: 6. Apr 2011
Ort: Berlin
3.062 Beiträge
 
Delphi 10.4 Sydney
 
#8

AW: JPEG CompressionQuality ermitteln

  Alt 17. Okt 2017, 12:44
Schade, mit GDI+ komm ich auch nicht ran.

Delphi-Quellcode:
function GdipCheck(const AResult: GPSTATUS): Boolean;
begin
  Result := AResult = GPSTATUS.Ok;
end;

function GdiPlusGetJpegCompression(const AJpegFilename: string): USHORT;
var
  token: ULONG;
  Input: TGdiplusStartupInput;
  Output: TGdiplusStartupOutput;
  status: GPSTATUS;
  image: GpImage;
  size: UINT;
  propertyItemID:PROPID;
  propertyItem: TPropertyItem;
begin
  Result := 0;
  FillChar(Input, SizeOf(Input), 0);
  Input.GdiplusVersion := 1;
  FillChar(Output, SizeOf(Output), 0);
  GdiplusStartup(token, @Input, @Output);
  try
    status := GdipCreateBitmapFromFile(PChar(AJpegFilename), image);
    if GdipCheck(status) then
    begin
      propertyItemID := PropertyTagJPEGQuality; // PropertyTagCompression
      status := GdipGetPropertyItemSize(image, propertyItemID, size);
      if GdipCheck(status) then
      begin
        ZeroMemory(@propertyItem, SizeOf(propertyItem));
        status := GdipGetPropertyItem(nil, propertyItemID, size, @propertyItem);
        if GdipCheck(status) then
        begin
          Result := PWORD(propertyItem.value)^;
        end;
      end;
    end;
  finally
    GdiplusShutdown(token);
  end;
end;
  Mit Zitat antworten Zitat