Closed GoogleCodeExporter closed 8 years ago
Hello again...
It works perfectly if I set the Glyph at run time with this code:
I've used provided Update tool, before I tested component (which is pretty
obvious,
because it would not compile without it.)
- If I assigne Glyph at runtime it works perfectly!!! I can live with that,
because i
can stream images from resources...
// ------------------------------------------------------
procedure LoadPNGintoBitmap32(ADstBitmap: TBitmap32; ASrcStream: TStream; out
vAlphaChannelUsed: Boolean); overload;
var
LPNGObject: TPNGObject;
LTransparentColor: TColor32;
LPixelPtr: PColor32;
LAlphaPtr: PByte;
X, Y: Integer;
begin
LPNGObject := nil;
try
LPNGObject := TPngObject.Create;
LPNGObject.LoadFromStream(ASrcStream);
ADstBitmap.Assign(LPNGObject);
ADstBitmap.ResetAlpha;
case LPNGObject.TransparencyMode of
ptmPartial:
begin
if (LPNGObject.Header.ColorType = COLOR_GRAYSCALEALPHA) or
(LPNGObject.Header.ColorType = COLOR_RGBALPHA) then
begin
LPixelPtr := PColor32(@ADstBitmap.Bits[0]);
for Y := 0 to ADstBitmap.Height - 1 do
begin
LAlphaPtr := PByte(LPNGObject.AlphaScanline[Y]);
for X := 0 to ADstBitmap.Width - 1 do
begin
LPixelPtr^ := (LPixelPtr^ and $00FFFFFF) or (TColor32(LAlphaPtr^) shl
24);
Inc(LPixelPtr);
Inc(LAlphaPtr);
end;
end;
vAlphaChannelUsed := True;
end;
end;
ptmBit:
begin
LTransparentColor := Color32(LPNGObject.TransparentColor);
LPixelPtr := PColor32(@ADstBitmap.Bits[0]);
for X := 0 to (ADstBitmap.Height - 1) * (ADstBitmap.Width - 1) do
begin
if LPixelPtr^ = LTransparentColor then
LPixelPtr^ := LPixelPtr^ and $00FFFFFF;
Inc(LPixelPtr);
end;
vAlphaChannelUsed := True;
end;
ptmNone:
vAlphaChannelUsed := False;
end;
finally
if Assigned(LPNGObject) then
LPNGObject.Free;
end;
end;
// ------------------------------------------------------
Original comment by tommi.prami@gmail.com
on 30 Oct 2008 at 7:42
look at the \Examples\test_control
it works well.
Btn1 := TGRButton.Create(Self);
with Btn1 do
try
Glyph.LoadFromFile('Background\123.png');
//LoadPicture(Glyph, 'Background\123.png');
Original comment by riceball...@gmail.com
on 13 Nov 2008 at 1:10
Hello,
I am not loading from file, but trying to add glyph at design time.
I stream file into it Runtime (from resources mxStorage component), with code
above,
it works. But adding glyph at designtime on the IDE I have problem with.
Sorry about not making that clear in previous post...
-TP-
Original comment by tommi.prami@gmail.com
on 13 Nov 2008 at 1:19
Original issue reported on code.google.com by
tommi.prami@gmail.com
on 29 Oct 2008 at 1:25Attachments: