type
PropertyTagType = (
PropertyTagTypeByte = 1,
PropertyTagTypeASCII = 2,
PropertyTagTypeShort = 3,
PropertyTagTypeLong = 4,
PropertyTagTypeRational = 5,
PropertyTagTypeUndefined = 7,
PropertyTagTypeSLong = 9,
PropertyTagTypeSRational = 10
);
TPropertyTagType = PropertyTagType;
PropertyItem =
record
id : PROPID;
length : ULONG;
type_ : TPropertyTagType;
value : Pointer;
end;
TPropertyItem = PropertyItem;
PPropertyItem = ^TPropertyItem;
const
PropertyTagFrameDelay: ULONG = $5100;
FrameDimensionTime: TGUID = '
{6aedbd6d-3fb5-418a-83a6-7f45229dc872}';
// Start!
//#######################################
AnimateGif := TAnimateGif.Create(
nil);
constructor TAnimateGif.Create(AOwner: TComponent);
begin
LoadGif;
end;
procedure TAnimateGif.LoadGif;
var
FrameCount: UINT;
FrameDelay: TOutFrameDelay;
begin
FrameCount := 0;
if GetGifFrameCount(gp.GifImage, FrameCount) = S_OK
then
begin
If (FrameCount - 1) = 0
then
begin
SetLength(FrameDelay, 0);
end
else
begin
GetGifFrameDelays(gp.GifImage, FrameCount, FrameDelay);
end;
end;
end;
function TAnimateGif.GetGifFrameCount(GifImage: Cardinal;
var OutFrameCount: UINT): integer;
begin
Result := GDIP_ImageGetFrameCount(GifImage, @FrameDimensionTime, OutFrameCount);
end;
procedure TAnimateGif.GetGifFrameDelays(InGifImage: Cardinal; InFrameCount: UINT;
var OutFrameDelay: TOutFrameDelay);
var
PROP: TProp;
PropCount: integer;
Size: integer;
PropSize: UINT;
PropItem: TPropertyItem;
begin
Size := 0;
// Datengröße vom EXIF-Tag
// "PropertyTagFrameDelay" ermitteln
if GDIP_GetPropertyItemSize(InGifImage, PropertyTagFrameDelay, PropSize) = S_OK
then
begin
// Daten auslesen
if GetPropertyItem(InGifImage, PropertyTagFrameDelay, PropSize, PropItem) = S_OK
then
begin
// PropertyTyp ermitteln
case PropItem.type_
of
PropertyTagTypeByte:
Size := 1;
PropertyTagTypeShort:
Size := 2;
PropertyTagTypeLong:
Size := 4;
end;
// Array zur Aufnahme der
// Pausenzeiten dimensionieren
SetLength(OutFrameDelay, (InFrameCount - 1));
end;
end;
end;
function TAnimateGif.GetPropertyItem(InGifImage: Cardinal; PropertyID: ULONG;
PropertyItemSize: UINT;
var PropertyItemData: TPropertyItem): integer;
begin
// Daten auslesen
Result := GDIP_GetPropertyItem(InGifImage, PropertyID, PropertyItemSize, @PropertyItemData);
end;
// API
//#######################################
function GDIP_GetPropertyItem(image: Cardinal; propId: PROPID; propSize: UINT;
buffer: PPROPERTYITEM): integer;
stdcall;
external dllfile;
function GDIP_GetPropertyItem(Img: Cardinal; propId: PROPID; propSize: UINT;
var buffer: PPROPERTYITEM): GPSTATUS;
stdcall;
begin
result := GdipGetPropertyItem(Img, propId, propSize, buffer);
end;
function GdipGetPropertyItem(
image: Cardinal;
propId: PROPID;
propSize: UINT;
var buffer: PPROPERTYITEM
): GPSTATUS;
stdcall;
external LibGdiPlus;