![]() |
AW: Array of Integer und crash
Versuch doch mal so (value ist doch ein Pointer auf den Datenbereich):
Delphi-Quellcode:
CopyMemory(@Prop[0], PropItem.value, PropItem.length);
|
AW: Array of Integer und crash
Zitat:
gruss |
AW: Array of Integer und crash
Das sieht aber immer noch nicht so aus, wie ich das gezeigt hatte:
Delphi-Quellcode:
var
p: Pointer; //############### // Bytearray dimensionieren p := @PropItem; GetMem(p, PropSize); SetLength(Prop, (PropItem.length - 1)); CopyMemory(@Prop[0], @PropItem.value, PropItem.length); FreeMem(p); So sollte es auch mit dem Prop-Array gehen:
Delphi-Quellcode:
PropSize: UINT;
PropItem: PPropertyItem; // dynamischer Pointer auf Record, deswegen PPropertyItem und nicht TPropertyItem if GDIP_GetPropertyItemSize(InGifImage, PropertyTagFrameDelay, PropSize) = S_OK then begin GetMem(PropItem, PropSize); // Record in passender Größe bereitstellen // Daten auslesen if GetPropertyItem(InGifImage, PropertyTagFrameDelay, PropSize, PropItem^) = S_OK then begin SetLength(Prop, PropItem.length); // nix -1 !!! CopyMemory(@Prop[0], PropItem.value, PropItem.length); ... end; FreeMem(PropItem); // Delphi merkt sich die Size intern |
AW: Array of Integer und crash
Zitat:
Sorry das mit GetMem funktioniert nicht. GetMem erwartet einen Pointer PropItem ist aber als TPropertyItem definiert. Was aber korrekt ist ich muss den Speicher vor GetPropertyItem allokieren ich habe es nachher gemacht. EDIT: OK hab dich verstanden funktioniert jetzt ;) Danke für deine Mühe und Zeit. Habe wieder einiges gelernt. :) So soll es sein das Ergebniss.. jedes Frame läuft 80ms. Hier nochmal das gesamt Ergebnis vielleicht kann es ja mal jemand brauchen.
Delphi-Quellcode:
gruss
procedure TAnimateGif.GetGifFrameDelays(GifImage: Cardinal; FrameCount: UINT;
var FrameDelay: TFrameDelay); var ISize: integer; PropSize: UINT; Prop: TProp; PropCount: integer; begin ISize := 0; // Datengröße vom EXIF-Tag PropertyTagFrameDelay ermitteln if GDIP_GetPropertyItemSize(GifImage, PropertyTagFrameDelay, PropSize) = S_OK then begin // Speicher allokieren GetMem(PropItem, PropSize); // Daten auslesen if GetPropertyItem(GifImage, PropertyTagFrameDelay, PropSize, PropItem) = S_OK then begin // Bytearray dimensionieren SetLength(Prop, (PropItem.length + 1)); CopyMemory(@Prop[0], PropItem.value, PropItem.length); // PropertyTyp ermitteln case PropItem.type_ of PropertyTagTypeByte: ISize := 1; PropertyTagTypeShort: ISize := 2; PropertyTagTypeLong: ISize := 4; end; // Array zur Aufnahme der Pausenzeiten dimensionieren SetLength(FrameDelay, FrameCount); // Pausenzeiten der einzelnen Bilder aus Bytearray kopieren for PropCount := 0 to (FrameCount - 1) do begin CopyMemory(@FrameDelay[PropCount], @Prop[PropCount * ISize], ISize); FrameDelay[PropCount] := FrameDelay[PropCount] * 10; end; end; FreeMem(PropItem); end; end; |
AW: Array of Integer und crash
Muss das nochmal aufgreifen..
Habe das Projekt nach 64 Bit umgelegt bekomme aber jetzt fortlaufend "Inaccessible value"
Delphi-Quellcode:
function TAnimateGif.GetPropertyItem(GifImage: LONG_PTR; PropertyID: ULONG; PropertyItemSize: UINT;
var PropertyItemData: PPropertyItem): GPSTATUS; begin // Daten auslesen Result := GDIP_GetPropertyItem(GifImage, PropertyID, PropertyItemSize, PropertyItemData); end;
Delphi-Quellcode:
bevor GdipGetPropertyItem aufgerufen wird ist der Buffer gefüllt.
function GDIP_GetPropertyItem(Img: LONG_PTR; propId: PROPID; propSize: UINT;
var buffer: PPROPERTYITEM ): GPSTATUS; stdcall; begin result := GdipGetPropertyItem(Img, propId, propSize, buffer); end; Nach dem Aufruf von GdipGetPropertyItem ist der buffer Inaccessible. Wie immer tritt nur unter 64 Bit auf. Die Funktion ist diese.
Delphi-Quellcode:
GdipGetPropertyItem: function(Image: LONG_PTR; propId: PROPID; propSize: UINT; var buffer: PPROPERTYITEM): GPSTATUS; stdcall;
Und der Record der..
Delphi-Quellcode:
es kracht dann hier
PropertyItem = record // NOT PACKED !!
id : PROPID; // ID of this property length : ULONG; // Length of the property value, in bytes type_ : WORD; // Type of the value, as one of TAG_TYPE_XXX value : Pointer; // property value end; TPropertyItem = PropertyItem; PPropertyItem = ^TPropertyItem;
Delphi-Quellcode:
weil PropItem bzw. vorher schon PropertyItemData nicht zugänglich ist.
// Daten auslesen
if GetPropertyItem(GifImage, PropertyTagFrameDelay, PropSize, FPropItem) = OK then begin // Bytearray dimensionieren SetLength(Prop, PropItem.Length); CopyMemory(@Prop[0], PropItem.value, PropItem.Length); PS: Es hat nichts mit dem setzen der Optimierung zu tun! gruss |
AW: Array of Integer und crash
Zitat:
|
AW: Array of Integer und crash
Zitat:
Und ja das gleiche tue ich auch unter 32 Bit ohne Probleme.. Danke. Der Fehler den ich bekomme ist EInOutError.. zudem es ist ein Property
Delphi-Quellcode:
property PropItem: PPropertyItem read FPropItem write FPropItem;
FPropItem liest und weist das Result PropItem zu beide haben also den gleichen Wert. gruss |
AW: Array of Integer und crash
Reservierst du denn vorher Speicher von der Größe, die dir GdipGetPropertyItemSize liefert, für deine Membervariable FPropItem bzw. für das dahinterliegende Record?
|
AW: Array of Integer und crash
Zitat:
Delphi-Quellcode:
gruss
// Datengröße vom EXIF-Tag PropertyTagFrameDelay ermitteln
if GDIP_GetPropertyItemSize(GifImage, PropertyTagFrameDelay, PropSize) = OK then begin // Speicher allokieren GetMem(FPropItem, PropSize); |
AW: Array of Integer und crash
Ein kleines 20-50 Zeilenprogramm zum nachvollziehen und selber kompilieren?
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 17:18 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