Source of problem:
, - , . , . - PNG, . , Out of system resources, , TBitmapInfoHeader, . :

, , , 169478669 * 218103808 21060 B , 778.5 EB (exabytes) : -)
:
, , ( :-) , PNG , PNG . , , - , PNG signature 8 , PNG, , PNG-, TIcon.
ImageListAddIconEx . 8 , PNG , , PNG . , TIcon. , , -1 :
uses
PNGImage;
type
TIconDirEntry = packed record
bWidth: Byte;
bHeight: Byte;
bColorCount: Byte;
bReserved: Byte;
wPlanes: Word;
wBitCount: Word;
dwBytesInRes: DWORD;
dwImageOffset: DWORD;
end;
TIconDir = packed record
idReserved: Word;
idType: Word;
idCount: Word;
idEntries: array[0..255] of TIconDirEntry;
end;
PIconDir = ^TIconDir;
function ImageListAddIconEx(AImageList: TCustomImageList;
AIconStream: TMemoryStream): Integer;
var
I: Integer;
Data: PByte;
Icon: TIcon;
IconHeader: PIconDir;
Bitmap: TBitmap;
PNGImage: TPNGImage;
PNGStream: TMemoryStream;
const
PNGSignature: array[0..7] of Byte = ($89, $50, $4E, $47, $0D, $0A, $1A, $0A);
begin
Result := -1;
IconHeader := AIconStream.Memory;
for I := 0 to IconHeader.idCount - 1 do
begin
if (IconHeader.idEntries[I].bWidth = AImageList.Width) and
(IconHeader.idEntries[I].bHeight = AImageList.Height) then
begin
Data := AIconStream.Memory;
Inc(Data, IconHeader.idEntries[I].dwImageOffset);
if CompareMem(Data, @PNGSignature[0], 8) then
begin
Bitmap := TBitmap.Create;
try
PNGImage := TPNGImage.Create;
try
PNGStream := TMemoryStream.Create;
try
AIconStream.Position := IconHeader.idEntries[I].dwImageOffset;
PNGStream.CopyFrom(AIconStream,
IconHeader.idEntries[I].dwBytesInRes);
PNGStream.Position := 0;
PNGImage.LoadFromStream(PNGStream);
finally
PNGStream.Free;
end;
Bitmap.Assign(PNGImage);
finally
PNGImage.Free;
end;
Bitmap.AlphaFormat := afIgnored;
Result := AImageList.Add(Bitmap, nil);
finally
Bitmap.Free;
end;
end
else
begin
AIconStream.Position := 0;
Icon := TIcon.Create;
try
Icon.LoadFromStream(AIconStream);
Result := AImageList.AddIcon(Icon);
finally
Icon.Free;
end;
end;
Break;
end;
end;
end;
:
procedure TForm1.Button1Click(Sender: TObject);
var
Index: Integer;
Stream: TMemoryStream;
begin
Stream := TMemoryStream.Create;
try
Stream.LoadFromFile('d:\Icon.ico');
Index := ImageListAddIconEx(ImageList1, Stream);
if (Index <> -1) then
ImageList1.Draw(Canvas, 8, 8, Index);
finally
Stream.Free;
end;
end;
:
, Microsoft PNG ( Windows Vista), ReadIcon Graphics.pas, .
- :