fpspreadsheet: Fix display of images inserted in WorksheetGrid under gtk as black areas.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7331 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
5457aab56b
commit
5def48c316
@ -4124,7 +4124,7 @@ var
|
|||||||
begin
|
begin
|
||||||
img := PsImage(FImages[AIndex]);
|
img := PsImage(FImages[AIndex]);
|
||||||
if (img <> nil) then begin
|
if (img <> nil) then begin
|
||||||
if (img^.Bitmap <> nil) then img^.Bitmap.Free;
|
if (img^.Picture <> nil) then img^.Picture.Free;
|
||||||
img^.HyperlinkTarget := '';
|
img^.HyperlinkTarget := '';
|
||||||
img^.HyperlinkToolTip := '';
|
img^.HyperlinkToolTip := '';
|
||||||
end;
|
end;
|
||||||
|
@ -829,7 +829,7 @@ type
|
|||||||
Index: Integer; // index into the workbook's embedded streams list
|
Index: Integer; // index into the workbook's embedded streams list
|
||||||
OffsetX, OffsetY: Double; // mm, relative to anchor
|
OffsetX, OffsetY: Double; // mm, relative to anchor
|
||||||
ScaleX, ScaleY: Double; // scaling factor of image
|
ScaleX, ScaleY: Double; // scaling factor of image
|
||||||
Bitmap: TObject; // used for bitmap for display in grid
|
Picture: TObject; // used for TPicture to display in grid
|
||||||
HyperlinkTarget: String; // Hyperlink assigned to the image
|
HyperlinkTarget: String; // Hyperlink assigned to the image
|
||||||
HyperlinkToolTip: String; // Tooltip for hyperlink of the image
|
HyperlinkToolTip: String; // Tooltip for hyperlink of the image
|
||||||
end;
|
end;
|
||||||
|
@ -2580,7 +2580,7 @@ begin
|
|||||||
AValue.OffsetY := AOffsetY;
|
AValue.OffsetY := AOffsetY;
|
||||||
AValue.ScaleX := AScaleX;
|
AValue.ScaleX := AScaleX;
|
||||||
AValue.ScaleY := AScaleY;
|
AValue.ScaleY := AScaleY;
|
||||||
AValue.Bitmap := nil; // to be initialized by viewing application
|
AValue.Picture := nil; // to be initialized by viewing application
|
||||||
AValue.Index := -1;
|
AValue.Index := -1;
|
||||||
AValue.HyperlinkTarget := '';
|
AValue.HyperlinkTarget := '';
|
||||||
AValue.HyperlinkToolTip := '';
|
AValue.HyperlinkToolTip := '';
|
||||||
|
@ -1810,7 +1810,6 @@ procedure TsWorkbookTabControl.ListenerNotification(
|
|||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
sheet: TsWorksheet;
|
sheet: TsWorksheet;
|
||||||
sheetName: String;
|
|
||||||
begin
|
begin
|
||||||
Unused(AData);
|
Unused(AData);
|
||||||
|
|
||||||
|
@ -2965,7 +2965,6 @@ var
|
|||||||
imgRect: TRect;
|
imgRect: TRect;
|
||||||
w, h: Integer;
|
w, h: Integer;
|
||||||
coloffs, rowoffs: Integer;
|
coloffs, rowoffs: Integer;
|
||||||
pic: TPicture;
|
|
||||||
rgn: HRGN;
|
rgn: HRGN;
|
||||||
fc, fr: Integer;
|
fc, fr: Integer;
|
||||||
R: TRect = (Left:0; Top:0; Right: 0; Bottom: 0);
|
R: TRect = (Left:0; Top:0; Right: 0; Bottom: 0);
|
||||||
@ -2977,72 +2976,51 @@ begin
|
|||||||
GetScrollOffset(rowOffs, colOffs);
|
GetScrollOffset(rowOffs, colOffs);
|
||||||
fc := FHeaderCount + FFrozenCols;
|
fc := FHeaderCount + FFrozenCols;
|
||||||
fr := FHeaderCount + FFrozenRows;
|
fr := FHeaderCount + FFrozenRows;
|
||||||
(*
|
|
||||||
Canvas.SaveHandleState;
|
|
||||||
try
|
|
||||||
// Draw bitmap over grid. Take care of clipping.
|
|
||||||
InterSectClipRect(Canvas.Handle,
|
|
||||||
clipArea.Left, clipArea.Top, clipArea.Right, clipArea.Bottom);
|
|
||||||
*)
|
|
||||||
for i := 0 to Worksheet.GetImageCount-1 do begin
|
|
||||||
img := Worksheet.GetPointerToImage(i);
|
|
||||||
obj := Workbook.GetEmbeddedObj(img^.Index);
|
|
||||||
|
|
||||||
// Frozen part of the grid draw only images which are anchored there.
|
for i := 0 to Worksheet.GetImageCount-1 do begin
|
||||||
case AGridPart of
|
img := Worksheet.GetPointerToImage(i);
|
||||||
DRAW_NON_FROZEN:
|
obj := Workbook.GetEmbeddedObj(img^.Index);
|
||||||
;
|
|
||||||
DRAW_FROZEN_ROWS:
|
|
||||||
if (integer(img^.Row) >= fr) then Continue;
|
|
||||||
DRAW_FROZEN_COLS:
|
|
||||||
if (integer(img^.Col) >= fc) then Continue;
|
|
||||||
DRAW_FROZEN_CORNER:
|
|
||||||
if (integer(img^.Row) >= fr) or (integer(img^.Col) >= fc) then Continue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
// Size of image and its position
|
// Frozen part of the grid draw only images which are anchored there.
|
||||||
w := ToPixels(obj.ImageWidth * img^.ScaleX);
|
case AGridPart of
|
||||||
h := ToPixels(obj.ImageHeight * img^.ScaleY);
|
DRAW_NON_FROZEN:
|
||||||
imgRect := GetImageRect(img, w, h, rowoffs, coloffs);
|
;
|
||||||
|
DRAW_FROZEN_ROWS:
|
||||||
// Nothing to do if image is outside the visible grid area
|
if (integer(img^.Row) >= fr) then Continue;
|
||||||
if not IntersectRect(R, clipArea, imgRect) then
|
DRAW_FROZEN_COLS:
|
||||||
continue;
|
if (integer(img^.Col) >= fc) then Continue;
|
||||||
|
DRAW_FROZEN_CORNER:
|
||||||
// If not yet done load image stream into bitmap and scale to required size
|
if (integer(img^.Row) >= fr) or (integer(img^.Col) >= fc) then Continue;
|
||||||
if img^.Bitmap = nil then begin
|
|
||||||
img^.Bitmap := TBitmap.Create;
|
|
||||||
TBitmap(img^.Bitmap).SetSize(w, h);
|
|
||||||
TBitmap(img^.Bitmap).PixelFormat := pf32Bit;
|
|
||||||
TBitmap(img^.Bitmap).Transparent := true;
|
|
||||||
end;
|
|
||||||
|
|
||||||
pic := TPicture.Create;
|
|
||||||
try
|
|
||||||
obj.Stream.Position := 0;
|
|
||||||
pic.LoadFromStream(obj.Stream);
|
|
||||||
if pic.Bitmap <> nil then
|
|
||||||
TBitmap(img^.Bitmap).Canvas.StretchDraw(Rect(0, 0, w, h), pic.Bitmap)
|
|
||||||
else if pic.Graphic <> nil then
|
|
||||||
TBitmap(img^.Bitmap).Canvas.StretchDraw(Rect(0, 0, w, h), pic.Graphic);
|
|
||||||
finally
|
|
||||||
pic.Free;
|
|
||||||
end;
|
|
||||||
|
|
||||||
// Draw the bitmap
|
|
||||||
rgn := CreateRectRgn(clipArea.Left, clipArea.Top, clipArea.Right, clipArea.Bottom);
|
|
||||||
try
|
|
||||||
SelectClipRgn(Canvas.Handle, rgn);
|
|
||||||
Canvas.Draw(imgRect.Left, imgRect.Top, TBitmap(img^.Bitmap));
|
|
||||||
finally
|
|
||||||
DeleteObject(rgn);
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
{
|
|
||||||
finally
|
|
||||||
Canvas.RestoreHandleState;
|
|
||||||
end; }
|
|
||||||
|
|
||||||
|
// Size of image and its position
|
||||||
|
w := ToPixels(obj.ImageWidth * img^.ScaleX);
|
||||||
|
h := ToPixels(obj.ImageHeight * img^.ScaleY);
|
||||||
|
imgRect := GetImageRect(img, w, h, rowoffs, coloffs);
|
||||||
|
|
||||||
|
// Nothing to do if image is outside the visible grid area
|
||||||
|
if not IntersectRect(R, clipArea, imgRect) then
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// If not yet done load image stream into picture and scale to required size
|
||||||
|
if img^.Picture = nil then
|
||||||
|
begin
|
||||||
|
img^.Picture := TPicture.Create;
|
||||||
|
obj.Stream.Position := 0;
|
||||||
|
TPicture(img^.Picture).LoadFromStream(obj.Stream);
|
||||||
|
end;
|
||||||
|
|
||||||
|
// Scale and draw image
|
||||||
|
rgn := CreateRectRgn(clipArea.Left, clipArea.Top, clipArea.Right, clipArea.Bottom);
|
||||||
|
try
|
||||||
|
SelectClipRgn(Canvas.Handle, rgn);
|
||||||
|
R := Rect(0, 0, w, h);
|
||||||
|
OffsetRect(R, imgRect.Left, imgRect.Top);
|
||||||
|
Canvas.StretchDraw(R, TPicture(img^.Picture).Graphic);
|
||||||
|
finally
|
||||||
|
DeleteObject(rgn);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{@@ ----------------------------------------------------------------------------
|
{@@ ----------------------------------------------------------------------------
|
||||||
|
@ -106,7 +106,8 @@ type
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Types, Math, LCLType, LCLIntf, LazUTF8, fpsUtils;
|
Types, Math, LCLType, LCLIntf, LazUTF8,
|
||||||
|
fpsUtils;
|
||||||
|
|
||||||
const
|
const
|
||||||
{@@ Font size factor for sub-/superscript characters }
|
{@@ Font size factor for sub-/superscript characters }
|
||||||
|
Loading…
Reference in New Issue
Block a user