+ setting image attributes when loading images

* fixing copyright section in the file header
This commit is contained in:
mazen 2003-09-09 11:26:59 +00:00
parent 43840ab3ca
commit d76b345184

View File

@ -1,7 +1,8 @@
{*****************************************************************************}
{ {
$Id$ $Id$
This file is part of the Free Pascal run time library. This file is part of the Free Pascal's "Free Components Library".
Copyright (c) 2003 by the Free Pascal development team Copyright (c) 2003 by Mazen NEIFER of the Free Pascal development team
BMP writer implementation. BMP writer implementation.
@ -11,8 +12,8 @@
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
}
**********************************************************************} {*****************************************************************************}
{$mode objfpc}{$h+} {$mode objfpc}{$h+}
unit FPReadBMP; unit FPReadBMP;
@ -58,9 +59,6 @@ implementation
uses BMPcomn; uses BMPcomn;
const
WhiteSpace = ' '#8#10#13;
constructor TFPReaderBMP.create; constructor TFPReaderBMP.create;
begin begin
inherited create; inherited create;
@ -85,37 +83,42 @@ procedure TFPReaderBMP.InternalRead(Stream:TStream; Img:TFPCustomImage);
begin begin
Stream.Read(BFI,SizeOf(BFI)); Stream.Read(BFI,SizeOf(BFI));
with BFI do with BFI do
if(bitCount = 8) begin
then Img.Width:=Width;
begin Img.Height:=Height;
// stream.read(Palet, bfh.bfOffset - 54); BytesPerPixel:=BitCount SHR 3;
end end;
if BytesPerPixel=1
then
begin
// stream.read(Palet, bfh.bfOffset - 54);
end
{Treating the 24bit BMP files} {Treating the 24bit BMP files}
else else
begin begin
nBpLine:=Img.Width*SizeOf(TColorRGB); nBpLine:=Img.Width*SizeOf(TColorRGB);
ReadSize:=(nBpLine+3)AND $FFFFFFFC;//BMP needs evry line 4Bytes aligned ReadSize:=(nBpLine+3)AND $FFFFFFFC;//BMP needs evry line 4Bytes aligned
{$IFDEF UseDynArray} {$IFDEF UseDynArray}
SetLength(aLine,Img.Width+1);//3 extra byte for BMP 4Bytes alignement. SetLength(aLine,Img.Width+1);//3 extra byte for BMP 4Bytes alignement.
{$ELSE UseDynArray} {$ELSE UseDynArray}
GetMem(aLine,(Img.Width+1)*SizeOf(TColorRGB));//3 extra byte for BMP 4Bytes alignement. GetMem(aLine,(Img.Width+1)*SizeOf(TColorRGB));//3 extra byte for BMP 4Bytes alignement.
{$ENDIF UseDynArray} {$ENDIF UseDynArray}
for Row:=img.Height-1 downto 0 do for Row:=img.Height-1 downto 0 do
begin begin
for Coulumn:=0 to img.Width-1 do for Coulumn:=0 to img.Width-1 do
with aLine[Coulumn],aColor do with aLine[Coulumn],aColor do
begin begin
{Use only the high byte to convert the color} {Use only the high byte to convert the color}
Red:=R shl 8; Red:=R shl 8;
Green:=G shl 8; Green:=G shl 8;
Blue:=B shl 8; Blue:=B shl 8;
img.colors[Coulumn,Row]:=aColor; img.colors[Coulumn,Row]:=aColor;
end; end;
Stream.Write(aLine{$IFNDEF UseDynArray}^{$ENDIF UseDynArray},ReadSize); Stream.Write(aLine{$IFNDEF UseDynArray}^{$ENDIF UseDynArray},ReadSize);
end; end;
end; end;
{$IFNDEF UseDynArray} {$IFNDEF UseDynArray}
FreeMem(aLine,(Img.Width+1)*SizeOf(TColorRGB)); FreeMem(aLine,(Img.Width+1)*SizeOf(TColorRGB));
{$ENDIF UseDynArray} {$ENDIF UseDynArray}
end; end;
@ -140,7 +143,11 @@ initialization
end. end.
{ {
$Log$ $Log$
Revision 1.1 2003-09-08 14:10:10 mazen Revision 1.2 2003-09-09 11:26:59 mazen
+ setting image attributes when loading images
* fixing copyright section in the file header
Revision 1.1 2003/09/08 14:10:10 mazen
+ adding support for loading bmp images + adding support for loading bmp images
} }