mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-14 10:29:42 +01:00
* Enabled alphadescription for icons
git-svn-id: trunk@11907 -
This commit is contained in:
parent
8e8e62be00
commit
0e764d0c33
@ -481,7 +481,6 @@ type
|
|||||||
private
|
private
|
||||||
FImage: TLazIntfImage;
|
FImage: TLazIntfImage;
|
||||||
FReadingScanlines: Boolean;
|
FReadingScanlines: Boolean;
|
||||||
procedure SetAlphaDescription;
|
|
||||||
protected
|
protected
|
||||||
procedure HandleAlpha; override;
|
procedure HandleAlpha; override;
|
||||||
procedure HandleScanLine (const y : integer; const ScanLine : PByteArray); override;
|
procedure HandleScanLine (const y : integer; const ScanLine : PByteArray); override;
|
||||||
@ -640,6 +639,23 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure CheckAlphaDescription(AImage: TFPCustomImage);
|
||||||
|
var
|
||||||
|
Desc: TRawImageDescription;
|
||||||
|
begin
|
||||||
|
if not (AImage is TLazIntfImage) then Exit;
|
||||||
|
|
||||||
|
Desc := TLazIntfImage(AImage).DataDescription;
|
||||||
|
if Desc.AlphaPrec >= 8 then Exit;
|
||||||
|
|
||||||
|
if not AddAlphaToDescription(Desc, 8)
|
||||||
|
then Desc.Init_BPP32_B8G8R8A8_BIO_TTB(Desc.Width, Desc.Height);
|
||||||
|
|
||||||
|
TLazIntfImage(AImage).DataDescription := Desc;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
procedure ReadRawImageBits_1_2_4_BIO(TheData: PByte;
|
procedure ReadRawImageBits_1_2_4_BIO(TheData: PByte;
|
||||||
const Position: TRawImagePosition;
|
const Position: TRawImagePosition;
|
||||||
@ -3490,21 +3506,6 @@ var
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure CheckAlphaDescription;
|
|
||||||
var
|
|
||||||
Desc: TRawImageDescription;
|
|
||||||
begin
|
|
||||||
if not (TheImage is TLazIntfImage) then Exit;
|
|
||||||
|
|
||||||
Desc := TLazIntfImage(TheImage).DataDescription;
|
|
||||||
if Desc.AlphaPrec >= 8 then Exit;
|
|
||||||
|
|
||||||
if not AddAlphaToDescription(Desc, 8)
|
|
||||||
then Desc.Init_BPP32_B8G8R8A8_BIO_TTB(Desc.Width, Desc.Height);
|
|
||||||
|
|
||||||
TLazIntfImage(TheImage).DataDescription := Desc;
|
|
||||||
end;
|
|
||||||
|
|
||||||
var
|
var
|
||||||
IntArray: PInteger;
|
IntArray: PInteger;
|
||||||
begin
|
begin
|
||||||
@ -3520,7 +3521,7 @@ begin
|
|||||||
HasAlpha := False;
|
HasAlpha := False;
|
||||||
ReadPalette(IntArray);
|
ReadPalette(IntArray);
|
||||||
if HasAlpha
|
if HasAlpha
|
||||||
then CheckAlphaDescription;
|
then CheckAlphaDescription(TheImage);
|
||||||
//FPixelToColorTree.ConsistencyCheck;
|
//FPixelToColorTree.ConsistencyCheck;
|
||||||
ReadPixels(IntArray);
|
ReadPixels(IntArray);
|
||||||
finally
|
finally
|
||||||
@ -4684,6 +4685,9 @@ begin
|
|||||||
else
|
else
|
||||||
raise FPImageException.CreateFmt(SWrongCombination, [BFI.biBitCount, BFI.biCompression]);
|
raise FPImageException.CreateFmt(SWrongCombination, [BFI.biBitCount, BFI.biCompression]);
|
||||||
end;
|
end;
|
||||||
|
// force alpha description
|
||||||
|
|
||||||
|
// CheckAlphaDescription(TheImage);
|
||||||
SetupRead(0, TheImage.Width * 32, True);
|
SetupRead(0, TheImage.Width * 32, True);
|
||||||
end;
|
end;
|
||||||
else
|
else
|
||||||
@ -4774,6 +4778,9 @@ var
|
|||||||
begin
|
begin
|
||||||
InternalReadHead;
|
InternalReadHead;
|
||||||
|
|
||||||
|
// force alpha description
|
||||||
|
CheckAlphaDescription(TheImage);
|
||||||
|
|
||||||
{$note check if height is also doubled without mask}
|
{$note check if height is also doubled without mask}
|
||||||
FBFI.biHeight := FBFI.biHeight div 2; { Height field is doubled, to (sort of) accomodate mask }
|
FBFI.biHeight := FBFI.biHeight div 2; { Height field is doubled, to (sort of) accomodate mask }
|
||||||
InternalReadBody; { Now read standard bitmap }
|
InternalReadBody; { Now read standard bitmap }
|
||||||
@ -4844,6 +4851,9 @@ var
|
|||||||
i: Integer;
|
i: Integer;
|
||||||
Bitmap: TBitmap;
|
Bitmap: TBitmap;
|
||||||
begin
|
begin
|
||||||
|
// force alpha description
|
||||||
|
CheckAlphaDescription(TheImage);
|
||||||
|
|
||||||
GetMem(IconDir, FnIcons*Sizeof(TIconDirEntry));
|
GetMem(IconDir, FnIcons*Sizeof(TIconDirEntry));
|
||||||
try
|
try
|
||||||
Stream.Read(IconDir^, FnIcons*Sizeof(TIconDirEntry));
|
Stream.Read(IconDir^, FnIcons*Sizeof(TIconDirEntry));
|
||||||
@ -4871,10 +4881,11 @@ begin
|
|||||||
for i := 1 to FnIcons do
|
for i := 1 to FnIcons do
|
||||||
begin
|
begin
|
||||||
Stream.Position := FnStartPos + CurrentDirEntry^.dwImageOffset;
|
Stream.Position := FnStartPos + CurrentDirEntry^.dwImageOffset;
|
||||||
if CurrentDirEntry = BestDirEntry then
|
if CurrentDirEntry = BestDirEntry
|
||||||
|
then begin
|
||||||
inherited InternalRead(Stream, Img)
|
inherited InternalRead(Stream, Img)
|
||||||
else
|
end
|
||||||
begin
|
else begin
|
||||||
Bitmap := TBitmap.Create;
|
Bitmap := TBitmap.Create;
|
||||||
try
|
try
|
||||||
Bitmap.ReadStreamWithFPImage(Stream, False, 0, TLazReaderPartIcon);
|
Bitmap.ReadStreamWithFPImage(Stream, False, 0, TLazReaderPartIcon);
|
||||||
@ -4886,8 +4897,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
Inc(CurrentDirEntry);
|
Inc(CurrentDirEntry);
|
||||||
end;
|
end;
|
||||||
end else
|
end
|
||||||
begin
|
else begin
|
||||||
Stream.Position := FnStartPos + BestDirEntry^.dwImageOffset;
|
Stream.Position := FnStartPos + BestDirEntry^.dwImageOffset;
|
||||||
inherited InternalRead(Stream, Img);
|
inherited InternalRead(Stream, Img);
|
||||||
{ Finally skip remaining icons }
|
{ Finally skip remaining icons }
|
||||||
@ -4928,7 +4939,7 @@ begin
|
|||||||
inherited HandleAlpha;
|
inherited HandleAlpha;
|
||||||
if FReadingScanlines then Exit; // already read some data
|
if FReadingScanlines then Exit; // already read some data
|
||||||
if UseTransparent or (Header.ColorType = 3)
|
if UseTransparent or (Header.ColorType = 3)
|
||||||
then SetAlphaDescription;
|
then CheckAlphaDescription(TheImage);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TLazReaderPNG.HandleScanLine(const y: integer; const ScanLine: PByteArray);
|
procedure TLazReaderPNG.HandleScanLine(const y: integer; const ScanLine: PByteArray);
|
||||||
@ -4946,22 +4957,7 @@ begin
|
|||||||
else FImage := nil;
|
else FImage := nil;
|
||||||
|
|
||||||
if Header.ColorType in [4, 6]
|
if Header.ColorType in [4, 6]
|
||||||
then SetAlphaDescription;
|
then CheckAlphaDescription(TheImage)
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TLazReaderPNG.SetAlphaDescription;
|
|
||||||
var
|
|
||||||
Desc: TRawImageDescription;
|
|
||||||
begin
|
|
||||||
if FImage = nil then Exit;
|
|
||||||
|
|
||||||
Desc := FImage.DataDescription;
|
|
||||||
if Desc.AlphaPrec >= 8 then Exit;
|
|
||||||
|
|
||||||
if not AddAlphaToDescription(Desc, 8)
|
|
||||||
then Desc.Init_BPP32_B8G8R8A8_BIO_TTB(Desc.Width, Desc.Height);
|
|
||||||
|
|
||||||
FImage.DataDescription := Desc;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user