+ Added flags to allow TLazIntfImage initialize description in creation

* replaced existing calls to create TLazIntfImage without description since it is set later (default works too, but might change).
* Enabled palette support for descriptions without palette

git-svn-id: trunk@17407 -
This commit is contained in:
marc 2008-11-16 15:27:37 +00:00
parent 28e1d0e3e3
commit c8855d51da
13 changed files with 55 additions and 28 deletions

View File

@ -2023,7 +2023,7 @@ begin
else begin
// create compatible copy
SrcImage := TLazIntfImage.Create(ARawImage, False);
DstImage := TLazIntfImage.Create(0, 0);
DstImage := TLazIntfImage.Create(0,0,[]);
// create mask for alphachannel when device has no alpha support
if (DevDesc.AlphaPrec = 0) and (riqfAlpha in QueryFlags)
then begin

View File

@ -580,7 +580,7 @@ begin
LazImg := TLazIntfImage(Image);
end
else begin
LazImg := TLazIntfImage.Create(0,0);
LazImg := TLazIntfImage.Create(0,0,[]);
RequiredState([csHandleValid]);
LazImg.DataDescription := GetDescriptionFromDevice(Handle, 0, 0);
LazImg.Assign(Image);

View File

@ -115,7 +115,7 @@ begin
try
// read image
ImgReader := GetReaderClass.Create;
IntfImg := TLazIntfImage.Create(0,0);
IntfImg := TLazIntfImage.Create(0,0,[]);
InitializeReader(IntfImg, ImgReader);
if Supports(ImgReader, ILazImageReader, LazReader)
then LazReader.UpdateDescription := True
@ -145,7 +145,7 @@ begin
// write image to temporary stream
ImgWriter := nil;
IntfImg := TLazIntfImage.Create(0,0);
IntfImg := TLazIntfImage.Create(0,0,[]);
try
ImgWriter := GetWriterClass.Create;
IntfImg.LoadFromBitmap(Handle, FMaskHandle);

View File

@ -207,7 +207,7 @@ begin
while AStream.Position < ASize do
begin
if IntfImage = nil
then IntfImage := TLazIntfImage.Create(0,0)
then IntfImage := TLazIntfImage.Create(0,0,[])
else IntfImage.SetSize(0,0);
if ImgReader = nil

View File

@ -789,7 +789,7 @@ begin
// create or reset intfimage
if IntfImage = nil
then IntfImage := TLazIntfImage.Create(0,0)
then IntfImage := TLazIntfImage.Create(0,0,[])
else IntfImage.SetSize(0,0);
if Supports(ImgReader, ILazImageReader, LazReader)

View File

@ -551,7 +551,7 @@ begin
then begin
// bummer, the widgetset doesn't support our 32bit format, try device
ListImg := TLazIntfImage.Create(RawImg, False);
DeviceImg := TLazIntfImage.Create(0, 0);
DeviceImg := TLazIntfImage.Create(0,0,[]);
DeviceImg.DataDescription := GetDescriptionFromDevice(0, Width, Height * Count);
DeviceImg.CopyPixels(ListImg);
DeviceImg.GetRawImage(RawImg);
@ -582,7 +582,7 @@ begin
then begin
// bummer, the widgetset doesn't support our 32bit format, try device
ListImg := TLazIntfImage.Create(RawImg, False);
DeviceImg := TLazIntfImage.Create(0, 0);
DeviceImg := TLazIntfImage.Create(0,0,[]);
DeviceImg.DataDescription := GetDescriptionFromDevice(0, FWidth, FHeight);
DeviceImg.CopyPixels(ListImg);
DeviceImg.GetRawImage(RawImg);
@ -1062,7 +1062,7 @@ var
MaskIntfImage:=nil;
ImgReader:=nil;
try
IntfImage:=TLazIntfImage.Create(0,0);
IntfImage:=TLazIntfImage.Create(0,0,[]);
IntfImage.DataDescription := GetDescriptionFromDevice(0, 0, 0);
// read the image bmp stream into the IntfImage
ImgReader:=TFPReaderBMP.Create;

View File

@ -117,7 +117,7 @@ begin
then begin
// todo: base on rawimage
IntfImage := TLazIntfImage.Create(0,0);
IntfImage := TLazIntfImage.Create(0,0,[]);
try
if BitmapHandleAllocated
then IntfImage.DataDescription := GetDescriptionFromBitmap(BitmapHandle, 0, 0)
@ -345,7 +345,7 @@ begin
IntfImg:=nil;
try
// create the interface image
IntfImg:=TLazIntfImage.Create(0,0);
IntfImg:=TLazIntfImage.Create(0,0,[]);
// get a snapshot
IntfImg.LoadFromDevice(DC);
// create HBitmap
@ -682,7 +682,7 @@ end;
function TRasterImage.CreateIntfImage: TLazIntfImage;
begin
{$IFDEF VerboseLCLTodos}{$note todo: create based on rawimage}{$ENDIF}
Result := TLazIntfImage.Create(0,0);
Result := TLazIntfImage.Create(0,0,[]);
Result.LoadFromBitmap(BitmapHandle, MaskHandle);
end;
@ -707,7 +707,7 @@ begin
end;
{$IFDEF VerboseLCLTodos}{$note todo: move to IntfImage}{$ENDIF}
IntfImage := TLazIntfImage.Create(0, 0);
IntfImage := TLazIntfImage.Create(0,0,[]);
try
// force handle creation here, since at next step we will check for mask handle
ImgHandle := BitmapHandle;

View File

@ -427,7 +427,7 @@ begin
else begin
// create compatible copy
SrcImage := TLazIntfImage.Create(ARawImage, False);
DstImage := TLazIntfImage.Create(0, 0);
DstImage := TLazIntfImage.Create(0,0,[]);
DstImage.DataDescription := DevDesc;
DstImage.CopyPixels(SrcImage);
SrcImage.Free;

View File

@ -322,7 +322,7 @@ begin
then begin
// bummer, the widgetset doesn't support our 32bit format, try device
ListImg := TLazIntfImage.Create(RawImg, False);
DeviceImg := TLazIntfImage.Create(0, 0);
DeviceImg := TLazIntfImage.Create(0,0,[]);
DeviceImg.DataDescription := GetDescriptionFromDevice(0, AList.Width, AList.Height);
DeviceImg.CopyPixels(ListImg);
DeviceImg.GetRawImage(RawImg);

View File

@ -239,7 +239,7 @@ begin
then begin
// bummer, the widgetset doesn't support our 32bit format, try device
ListImg := TLazIntfImage.Create(RawImg, False);
DeviceImg := TLazIntfImage.Create(0, 0);
DeviceImg := TLazIntfImage.Create(0,0,[]);
DeviceImg.DataDescription := GetDescriptionFromDevice(0, AList.Width, AList.Height);
DeviceImg.CopyPixels(ListImg);
DeviceImg.GetRawImage(RawImg);

View File

@ -51,10 +51,8 @@ type
begin
// create a bitmap (or use an existing one)
Bitmap1:=TBitmap.Create;
// create the raw image
IntfImg1:=TLazIntfImage.Create(0,0);
// get the description for the current screen (bitsperpixel, depth, ...)
IntfImg1.GetDescriptionFromDevice(0);
// create the raw image for the screenformat you want
IntfImg1:=TLazIntfImage.Create(0,0,[riqfRGB, riqfAlpha, riqfMask]);
// create the XPM reader
Reader:=TLazReaderXPM.Create;
// load the image
@ -82,7 +80,7 @@ type
begin
...
// create the raw image
IntfImg1:=TLazIntfImage.Create(0,0);
IntfImg1:=TLazIntfImage.Create(0,0,[]);
// load the raw image from the bitmap handles
IntfImg1.LoadFromBitmap(Bitmap1.Handle,Bitmap1.MaskHandle);
// create the XPM writer
@ -238,6 +236,7 @@ type
procedure SetMask_Generic(x, y: integer; const AValue: Boolean);
public
constructor Create(AWidth, AHeight: integer); override;
constructor Create(AWidth, AHeight: integer; AFlags: TRawImageQueryFlags);
constructor Create(ARawImage: TRawImage; ADataOwner: Boolean);
destructor Destroy; override;
procedure BeginUpdate;
@ -2866,7 +2865,7 @@ end;
procedure TLazIntfImage.SetUsePalette(Value: boolean);
begin
inherited SetUsePalette(False); // Can't handle palettes at the moment
inherited // we can SetUsePalette(False); // Can't handle palettes at the moment
end;
procedure TLazIntfImage.SetInternalColor(x, y: integer; const Value: TFPColor);
@ -2889,7 +2888,15 @@ end;
procedure TLazIntfImage.SetInternalPixel(x, y: integer; Value: integer);
begin
if Palette = nil then Exit;
if FRawImage.Description.PaletteColorCount = 0
then begin
// Non palettebased image so set the color
SetInternalColor(x, y, Palette.Color[Value]);
end
else begin
// TODO: Setting of palette colors
end;
end;
procedure TLazIntfImage.SetMasked(x, y: integer; const AValue: Boolean);
@ -2901,7 +2908,17 @@ end;
function TLazIntfImage.GetInternalPixel(x, y: integer): integer;
begin
Result:=0;
if Palette = nil then Exit(0);
if FRawImage.Description.PaletteColorCount = 0
then begin
// Non palettebased image so lookup the color
Result := Palette.IndexOf(GetInternalColor(x, y));
end
else begin
// TODO: Setting of palette colors
Result := 0;
end;
end;
function TLazIntfImage.GetMasked(x, y: integer): Boolean;
@ -2987,13 +3004,23 @@ begin
end;
constructor TLazIntfImage.Create(AWidth, AHeight: integer);
begin
Create(AWidth, AHeight, []);
end;
constructor TLazIntfImage.Create(AWidth, AHeight: integer; AFlags: TRawImageQueryFlags);
begin
FDataOwner := True;
FGetInternalColorProc := @GetColor_NULL;
FSetInternalColorProc := @SetColor_NULL;
inherited Create(AWidth, AHeight);
end;
if AFlags <> []
then begin
QueryDescription(FRawImage.Description, AFlags, AWidth, AHeight);
ChooseGetSetColorFunctions;
end;
end;
constructor TLazIntfImage.Create(ARawImage: TRawImage; ADataOwner: Boolean);
var
@ -3001,7 +3028,7 @@ var
begin
BeginUpdate;
FRawimage := ARawImage;
Create(Desc.Width, Desc.Height);
Create(Desc.Width, Desc.Height, []);
FDataOwner := ADataOwner;
FCreateAllDataNeeded := False;
EndUpdate;

View File

@ -785,7 +785,7 @@ var
begin
if (SrcGraph is TRasterImage) then
begin
SrcIntfImg:=TLazIntfImage.Create(0,0);
SrcIntfImg:=TLazIntfImage.Create(0,0,[]);
Lst.BeginUpdate;
Try
SrcIntfImg.LoadFromBitmap(TRasterImage(SrcGraph).BitmapHandle,

View File

@ -121,7 +121,7 @@ begin
then begin
// bummer, the widgetset doesn't support our 32bit format, try device
ListImg := TLazIntfImage.Create(RawImg, False);
DeviceImg := TLazIntfImage.Create(0, 0);
DeviceImg := TLazIntfImage.Create(0, 0, []);
DeviceImg.DataDescription := GetDescriptionFromDevice(0, FList.Width, FList.Height);
DeviceImg.CopyPixels(ListImg);
DeviceImg.GetRawImage(RawImg);