Registriert seit: 16. Jan 2004
Ort: Bendorf
5.219 Beiträge
Delphi 10.2 Tokyo Professional
|
Re: RGB -> Bitmap
11. Aug 2006, 15:38
Delphi-Quellcode:
SetLength(TGAInfo.Picture, TGAInfo.Header.Width, TGAInfo.Header.Height);
if TGAInfo.Header.PictureFormat in [1..3] then
begin
for j:= 0 to TGAInfo.Header.Height-1 do begin
for i:= 0 to TGAInfo.Header.Width-1 do begin
AStream.Read(TGAInfo.Picture[i,j].B, SizeOf(Byte));
AStream.Read(TGAInfo.Picture[i,j].G, SizeOf(Byte));
AStream.Read(TGAInfo.Picture[i,j].R, SizeOf(Byte));
end;
end;
BmpStream := WriteBmpHeader(TGAInfo.Header.Width,TGAInfo.Header.Height,TGAInfo.Header.Bpp);
for j:= 0 to TGAInfo.Header.Height-1 do begin
for i:= 0 to TGAInfo.Header.Width-1 do begin
with BmpStream do
begin
Write(TGAInfo.Picture[i,j].B,SizeOf(Byte));
Write(TGAInfo.Picture[i,j].G,SizeOf(Byte));
Write(TGAInfo.Picture[i,j].R,SizeOf(Byte));
end;
end;
for i:= 0 to (4 - (j * 3) mod 4) - 1 do
BmpStream.Write(NULL,SizeOf(Byte));
end;
BmpStream.Read(FBitmap, BmpStream.Size);
// FBitmap.LoadFromStream(BmpStream); geht auch nicht
WriteBmpHeader:
Delphi-Quellcode:
function WriteBmpHeader(Width,Height: Longword; bpp: Word): TMemoryStream;
const Null : Longword = 0;
Dat1 : Word = $4D42;
Dat2 : Longword = $EC4;
var lwTemp: Longword;
wTemp : Word;
begin
Result := TMemoryStream.Create;
with Result do
begin
Write(Dat1,SizeOf(Word));
Write(NULL,SizeOf(Longword));
Write(NULL,SizeOf(Longword));
lwTemp := 54;
Write(lwTemp,SizeOf(Longword));
lwTemp := 40;
Write(lwTemp,SizeOf(Longword));
Write(Width,SizeOf(Longword));
Write(Height,SizeOf(Longword));
wTemp := 1;
Write(wTemp, SizeOf(Word));
Write(Bpp,SizeOf(Word));
Write(NULL, SizeOf(Longword));
Write(NULL, SizeOf(Longword));
Write(Dat2,SizeOf(Longword));
Write(Dat2, SizeOf(Longword));
Write(NULL, SizeOf(Longword));
Write(NULL, SizeOf(Longword));
end;
end;
Es gibt zwar keine AV aber ich bekomme auch nichts zu sehen
Gruß
Neutral General
Michael "Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."
|
|
Zitat
|