* Initialize rawimage data when no data present and no data loaded

git-svn-id: trunk@22266 -
This commit is contained in:
marc 2009-10-22 21:54:28 +00:00
parent e7f7fe8eb9
commit a593eef5ef

View File

@ -179,21 +179,32 @@ begin
if ImagePtr^.Description.Height = 0 then Exit; // no data if ImagePtr^.Description.Height = 0 then Exit; // no data
end; end;
// use savestream if present
// TODO description based on pixelformat if FSharedImage.FSaveStream <> nil
if FSharedImage.FSaveStream = nil
then begin then begin
FSharedImage.FSaveStream.Position := 0;
OldChangeEvent := OnChange;
try
OnChange := nil;
ReadStream(FSharedImage.FSaveStream, FSharedImage.FSaveStream.Size);
FPixelFormatNeedsUpdate := True;
finally
OnChange := OldChangeEvent;
end;
end;
// use handle
if FSharedImage.FHandle <> 0 if FSharedImage.FHandle <> 0
then begin then begin
if ADescOnly if ADescOnly
or not RawImage_FromBitmap(ImagePtr^, FSharedImage.FHandle, FMaskHandle) or not RawImage_FromBitmap(ImagePtr^, FSharedImage.FHandle, FMaskHandle)
then ImagePtr^.Description := GetDescriptionFromBitmap(FSharedImage.FHandle); then ImagePtr^.Description := GetDescriptionFromBitmap(FSharedImage.FHandle);
FPixelFormatNeedsUpdate := True; FPixelFormatNeedsUpdate := True;
Exit;
end; end;
// keep size // setup ImagePtr, fill description if not set
// ImagePtr^.Description := GetDescriptionFromDevice(0, ImagePtr^.Description.Width, ImagePtr^.Description.Height); if ImagePtr^.Description.Format = ricfNone
then begin
// use query to get a default description without alpha, since alpha drawing // use query to get a default description without alpha, since alpha drawing
// is not yet supported (unless asked for) // is not yet supported (unless asked for)
// use var and not pixelformat property since it requires a rawimagedescription (which we are creating) // use var and not pixelformat property since it requires a rawimagedescription (which we are creating)
@ -208,18 +219,14 @@ begin
ImagePtr^.Description := QueryDescription(Flags, ImagePtr^.Description.Width, ImagePtr^.Description.Height); ImagePtr^.Description := QueryDescription(Flags, ImagePtr^.Description.Width, ImagePtr^.Description.Height);
// atleast for now let pixelformat reflect the created description // atleast for now let pixelformat reflect the created description
FPixelFormatNeedsUpdate := True; FPixelFormatNeedsUpdate := True;
Exit;
end; end;
FSharedImage.FSaveStream.Position := 0; if ADescOnly then Exit;
OldChangeEvent := OnChange; if ImagePtr^.Data <> nil then Exit;
try if ImagePtr^.DataSize > 0 then Exit;
OnChange := nil;
ReadStream(FSharedImage.FSaveStream, FSharedImage.FSaveStream.Size); // setup data
FPixelFormatNeedsUpdate := True; ImagePtr^.CreateData(True);
finally
OnChange := OldChangeEvent;
end;
end; end;
function TCustomBitmap.ReleaseHandle: HBITMAP; function TCustomBitmap.ReleaseHandle: HBITMAP;