You've already forked lazarus-ccr
fpspreadsheet: Fix xlsx image distortion introduced with new workbook units.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4569 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -24,11 +24,11 @@ begin
|
|||||||
MyWorkbook := TsWorkbook.Create;
|
MyWorkbook := TsWorkbook.Create;
|
||||||
try
|
try
|
||||||
MyWorksheet := MyWorkbook.AddWorksheet('Sheet 1');
|
MyWorksheet := MyWorkbook.AddWorksheet('Sheet 1');
|
||||||
|
{
|
||||||
for i:=0 to 20 do
|
for i:=0 to 20 do
|
||||||
MyWorksheet.WriteRowHeight(i, 4.5, suMillimeters);
|
MyWorksheet.WriteRowHeight(i, 4.5, suMillimeters);
|
||||||
// MyWorksheet.DefaultRowHeight := 4.5; // millimeters
|
// MyWorksheet.DefaultRowHeight := 4.5; // millimeters
|
||||||
|
}
|
||||||
MyWorksheet.WriteText(0, 0, 'There are images in cells A3 and B3'); //
|
MyWorksheet.WriteText(0, 0, 'There are images in cells A3 and B3'); //
|
||||||
// These images are offset by 1mm in both directions from the top/left cell edge
|
// These images are offset by 1mm in both directions from the top/left cell edge
|
||||||
MyWorksheet.WriteImage(2, 0, image1, 1.0, 1.0, 2.0, 2.0); // This image is magnified by factor 2
|
MyWorksheet.WriteImage(2, 0, image1, 1.0, 1.0, 2.0, 2.0); // This image is magnified by factor 2
|
||||||
|
@@ -55,7 +55,7 @@ type
|
|||||||
property FileName: String read FFileName;
|
property FileName: String read FFileName;
|
||||||
property ImageType: TsImagetype read FImageType;
|
property ImageType: TsImagetype read FImageType;
|
||||||
property ImageWidth: Double read FWidth write FWidth;
|
property ImageWidth: Double read FWidth write FWidth;
|
||||||
property ImageHeight: Double read FHeight write FWidth;
|
property ImageHeight: Double read FHeight write FHeight;
|
||||||
property Stream: TMemoryStream read FStream;
|
property Stream: TMemoryStream read FStream;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@@ -3408,14 +3408,14 @@ begin
|
|||||||
|
|
||||||
ARow1 := img.Row;
|
ARow1 := img.Row;
|
||||||
ACol1 := img.Col;
|
ACol1 := img.Col;
|
||||||
ARowOffs1 := img.OffsetX;
|
ARowOffs1 := img.OffsetX; // in workbook units
|
||||||
AColOffs1 := img.OffsetY;
|
AColOffs1 := img.OffsetY; // in workbook units
|
||||||
|
|
||||||
obj := FWorkbook.GetEmbeddedObj(img.Index);
|
obj := FWorkbook.GetEmbeddedObj(img.Index);
|
||||||
AWidth := obj.ImageWidth * img.ScaleX;
|
AWidth := obj.ImageWidth * img.ScaleX; // in workbook units
|
||||||
AHeight := obj.ImageHeight * img.ScaleY;
|
AHeight := obj.ImageHeight * img.ScaleY; // in workbook units
|
||||||
|
|
||||||
// Find x coordinate of left image edge, in inches.
|
// Find x coordinate of left image edge, in workbook units
|
||||||
x := AColOffs1;
|
x := AColOffs1;
|
||||||
for c := 0 to ACol1-1 do
|
for c := 0 to ACol1-1 do
|
||||||
begin
|
begin
|
||||||
@@ -3438,7 +3438,7 @@ begin
|
|||||||
inc(ACol2);
|
inc(ACol2);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// Find y coordinate of top image edge, in inches.
|
// Find y coordinate of top image edge, in workbook units.
|
||||||
y := ARowOffs1;
|
y := ARowOffs1;
|
||||||
for r := 0 to ARow1 - 1 do
|
for r := 0 to ARow1 - 1 do
|
||||||
begin
|
begin
|
||||||
@@ -6183,7 +6183,7 @@ function TsWorksheet.CalcRowHeight(ARow: Cardinal): Single;
|
|||||||
begin
|
begin
|
||||||
Result := CalcAutoRowHeight(ARow);
|
Result := CalcAutoRowHeight(ARow);
|
||||||
if Result = 0 then
|
if Result = 0 then
|
||||||
Result := GetRowHeight(ARow);
|
Result := GetRowHeight(ARow, FWorkbook.Units);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{@@ ----------------------------------------------------------------------------
|
{@@ ----------------------------------------------------------------------------
|
||||||
@@ -8570,8 +8570,12 @@ var
|
|||||||
begin
|
begin
|
||||||
obj := TsEmbeddedObj.Create;
|
obj := TsEmbeddedObj.Create;
|
||||||
if obj.LoadFromStream(AStream, AName) then
|
if obj.LoadFromStream(AStream, AName) then
|
||||||
|
begin
|
||||||
|
obj.ImageWidth := ConvertUnits(obj.ImageWidth, suInches, FUnits);
|
||||||
|
obj.ImageHeight := ConvertUnits(obj.ImageHeight, suInches, FUnits);
|
||||||
Result := FEmbeddedObjList.Add(obj)
|
Result := FEmbeddedObjList.Add(obj)
|
||||||
else begin
|
end else
|
||||||
|
begin
|
||||||
AddErrorMsg(rsImageFormatNotSupported);
|
AddErrorMsg(rsImageFormatNotSupported);
|
||||||
obj.Free;
|
obj.Free;
|
||||||
Result := -1;
|
Result := -1;
|
||||||
|
Reference in New Issue
Block a user