![]() |
AW: IThumbnailCache - Thumbnail ermitteln
Mit TBitmap.Dormant := True kann ich jetzt auf das Bild auch außerhalb der GetThumbFromCache-Funktion zugreifen. Leider bekomme ich eine Zugriffsverletzung in der Zeile bs := P1[j]; der procedure FlipBitmap:
Zitat:
P1 $3F00 i 0 j 0 p2 nil BytesPerLine 256 bs E2171 Auf Variable 'bs' kann wegen Optimierung nicht zugegriffen werden Funktioniert FlipBitmap bei dir? Was könnte der Fehler sein? |
AW: IThumbnailCache - Thumbnail ermitteln
"Mit TBitmap.Dormant := True kann ich jetzt auf das Bild auch außerhalb der GetThumbFromCache-Funktion zugreifen".
Das nuss ausgeführt werden, solange das Handle gültig ist, also innerhalb von GetThumbFromCache |
AW: IThumbnailCache - Thumbnail ermitteln
Zitat:
Delphi-Quellcode:
Mit folgendes Funktion kann ich das Bild drehen, die soll allerdings langsam sein:
function TForm2.GetThumbFromCache(AFileName: string; out Bmp: TBitmap; AMaxSize: Integer = 120): HRESULT;
var thumbcache: IThumbnailCache; sharedbmp: ISharedBitmap; shellitem: IShellItem; thumbflags: PWTS_CACHEFLAGS; thumbid: PWTS_THUMBNAILID; thumbsize: TSize; hBmp: HBITMAP; begin if not Assigned(Bmp) then Exit; Result := CoInitialize(Nil); Result := CoCreateInstance( CLSID_LocalThumbnailCache, nil, CLSCTX_INPROC, IThumbnailCache, thumbcache ); if Succeeded(Result) then begin Result := SHCreateItemFromParsingName( PChar(AFileName), nil, IShellItem, shellitem ); if Succeeded(Result) then begin Result := thumbcache.GetThumbnail( shellitem, AMaxSize, WTS_EXTRACT, sharedbmp, nil, //thumbflags, nil //thumbid ); if Succeeded(Result) then begin sharedbmp.GetSize(thumbsize); Result := sharedbmp.GetSharedBitmap(hBmp); if Succeeded(Result) then begin bmp.SetSize(thumbsize.cx, thumbsize.cy); bmp.Handle := hBmp; bmp.Dormant; //FlipBmp(bmp); MirrorVertical(Bmp); end; end; CoUninitialize; end; end; end;
Delphi-Quellcode:
Procedure MirrorVertical(var Picture: TBitmap);
var BMP: TBitmap; i,j: integer; begin BMP := TBitmap.Create; BMP.Assign(Picture); for i := 0 to BMP.Height-1 do for j := 0 to BMP.Width-1 do Picture.canvas.Pixels[j, BMP.Height-i-1] := BMP.canvas.Pixels[j, i]; BMP.free; end; |
AW: IThumbnailCache - Thumbnail ermitteln
Ja, da war noch ein Fehler (X koordinate wurde doppelt hochgezählt) drin, keine Ahnung wieso der Code bei mir damals ging.
Wobei auch die Korrektur fehlschlug. Nach setzen auf Pixelformat pf24bit, läuft er heute wieder bei mir.
Delphi-Quellcode:
procedure FlipBitmap(VAr BitmapToFlip: Tbitmap);
var i, j: integer; P1, p2: Pbytearray; bs: byte; BytesPerLine: integer; begin BitmapToFlip.PixelFormat := pf24bit; BytesPerLine := 3 * BitmapToFlip.Width; for I := 0 to BitmapToFlip.Height div 2 - 1 do begin P1 := BitmapToFlip.ScanLine[i]; P2 := BitmapToFlip.ScanLine[BitmapToFlip.Height - 1 - i]; for j := 0 to BytesPerLine - 1 do begin bs := P1[j]; P1[j] := P2[j]; P2[j] := bs; end; end; end; |
AW: IThumbnailCache - Thumbnail ermitteln
Die überarbeitete Version funktioniert :thumb:
Danke für eure Hilfe :dp: |
Alle Zeitangaben in WEZ +1. Es ist jetzt 11: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