Klasse, funktioniert wunderbar!
Hier die Endfassung (ich habe ARGB noch wieder in
RGB geändert, da sonst die Farben etwas verfälscht waren):
Delphi-Quellcode:
function TPNGMapleCanvas.Parse1(Input: TMemoryStream): TPNGImage;
var
x, y: Integer;
b1, b2: Byte;
a, r, g, b: Word;
begin
Result := TPNGImage.CreateBlank(COLOR_RGB, 16, FWidth, FHeight);
Result.CreateAlpha;
x := 0;
y := 0;
while Input.Position < Input.Size
do
begin
if x = FWidth
then
begin
x := 0;
Inc(y);
if y = FHeight
then
Break;
end;
Input.
Read(b1, 1);
Input.
Read(b2, 1);
b := b1
and 15;
b := b
or (b
shl 4);
g := b1
and 240;
g := g
or (g
shr 4);
r := b2
and 15;
r := r
or (r
shl 4);
a := b2
and 240;
a := a
or (a
shr 4);
Result.Pixels[x, y] :=
RGB(r, g, b);
// don't use Canvas here
Result.AlphaScanline[y][x] := a;
// Now set the alpha value
Inc(x);
end;
end;