fpvectorial: Improves raster image rendering in html table

git-svn-id: trunk@48350 -
This commit is contained in:
sekelsenmat 2015-03-15 07:52:31 +00:00
parent 3102a20b2d
commit 09251020ef
2 changed files with 40 additions and 32 deletions

View File

@ -717,6 +717,7 @@ type
RasterImage: TFPCustomImage; RasterImage: TFPCustomImage;
Width, Height: Double; Width, Height: Double;
destructor Destroy; override; destructor Destroy; override;
procedure CalculateBoundingBox(ADest: TFPCustomCanvas; var ALeft, ATop, ARight, ABottom: Double); override;
procedure CreateRGB888Image(AWidth, AHeight: Cardinal); procedure CreateRGB888Image(AWidth, AHeight: Cardinal);
procedure CreateImageFromFile(AFilename: string); procedure CreateImageFromFile(AFilename: string);
procedure InitializeWithConvertionOf3DPointsToHeightMap(APage: TvVectorialPage; AWidth, AHeight: Integer); procedure InitializeWithConvertionOf3DPointsToHeightMap(APage: TvVectorialPage; AWidth, AHeight: Integer);
@ -4513,6 +4514,15 @@ begin
inherited Destroy; inherited Destroy;
end; end;
procedure TvRasterImage.CalculateBoundingBox(ADest: TFPCustomCanvas;
var ALeft, ATop, ARight, ABottom: Double);
begin
ALeft := X;
ATop := Y;
ARight := X + Width;
ABottom := Y + Height;
end;
procedure TvRasterImage.CreateRGB888Image(AWidth, AHeight: Cardinal); procedure TvRasterImage.CreateRGB888Image(AWidth, AHeight: Cardinal);
{$ifdef USE_LCL_CANVAS} {$ifdef USE_LCL_CANVAS}
var var
@ -5824,12 +5834,9 @@ begin
lEntity := GetFirstEntity(); lEntity := GetFirstEntity();
while lEntity <> nil do while lEntity <> nil do
begin begin
if lEntity is TvText then lEntity.CalculateBoundingBox(ADest, lLeft, lTop, lRight, lBottom);
begin lCurWidth := lCurWidth + (lRight - lLeft);
lText.CalculateBoundingBox(ADest, lLeft, lTop, lRight, lBottom); lCurHeight := Max(lCurHeight, Abs(lTop - lBottom));
lCurWidth := lCurWidth + (lRight - lLeft);
lCurHeight := Max(lCurHeight, Abs(lTop - lBottom));
end;
lEntity := GetNextEntity(); lEntity := GetNextEntity();
end; end;
@ -6036,19 +6043,17 @@ var
lCurHeight: Double = 0.0; lCurHeight: Double = 0.0;
lLeft, lTop, lRight, lBottom: Double; lLeft, lTop, lRight, lBottom: Double;
lEntity: TvEntity; lEntity: TvEntity;
lParagraph: TvParagraph absolute lEntity; //lParagraph: TvParagraph absolute lEntity;
begin begin
Result := 0; Result := 0;
lEntity := GetFirstEntity(); lEntity := GetFirstEntity();
while lEntity <> nil do while lEntity <> nil do
begin begin
if lEntity is TvParagraph then lEntity.X := X;
begin lEntity.Y := Y + Result;
lParagraph.X := X; lEntity.CalculateBoundingBox(ADest, lLeft, lTop, lRight, lBottom);
lParagraph.Y := Y + Result; Result := Result + (lBottom - lTop);
lParagraph.CalculateBoundingBox(ADest, lLeft, lTop, lRight, lBottom);
Result := Result + (lBottom - lTop);
end;
lEntity := GetNextEntity(); lEntity := GetNextEntity();
end; end;
@ -6059,7 +6064,7 @@ function TvRichText.CalculateMaxNeededWidth(ADest: TFPCustomCanvas): Double;
var var
lLeft, lTop, lRight, lBottom: Double; lLeft, lTop, lRight, lBottom: Double;
lEntity: TvEntity; lEntity: TvEntity;
lParagraph: TvParagraph absolute lEntity; //lParagraph: TvParagraph absolute lEntity;
begin begin
Result := 0; Result := 0;
@ -6069,13 +6074,11 @@ begin
lEntity := GetFirstEntity(); lEntity := GetFirstEntity();
while lEntity <> nil do while lEntity <> nil do
begin begin
if lEntity is TvParagraph then lEntity.X := X;
begin lEntity.Y := Y + Result;
lParagraph.X := X; lEntity.CalculateBoundingBox(ADest, lLeft, lTop, lRight, lBottom);
lParagraph.Y := Y + Result; Result := Max(Result, (lRight - lLeft));
lParagraph.CalculateBoundingBox(ADest, lLeft, lTop, lRight, lBottom);
Result := Max(Result, (lRight - lLeft));
end;
lEntity := GetNextEntity(); lEntity := GetNextEntity();
end; end;
end; end;
@ -6094,7 +6097,7 @@ var
lCurHeight: Double = 0.0; lCurHeight: Double = 0.0;
lLeft, lTop, lRight, lBottom: Double; lLeft, lTop, lRight, lBottom: Double;
lEntity: TvEntity; lEntity: TvEntity;
lParagraph: TvParagraph absolute lEntity; //lParagraph: TvParagraph absolute lEntity;
lEntityRenderInfo: TvRenderInfo; lEntityRenderInfo: TvRenderInfo;
begin begin
ARenderInfo.EntityCanvasMinXY := Point(-1, -1); ARenderInfo.EntityCanvasMinXY := Point(-1, -1);
@ -6103,14 +6106,12 @@ begin
lEntity := GetFirstEntity(); lEntity := GetFirstEntity();
while lEntity <> nil do while lEntity <> nil do
begin begin
if lEntity is TvParagraph then lEntity.X := X;
begin lEntity.Y := Y + lCurHeight;
lParagraph.X := X; lEntity.Render(ADest, lEntityRenderInfo, ADestX, ADestY, AMulX, AMuly);
lParagraph.Y := Y + lCurHeight; lEntity.CalculateBoundingBox(ADest, lLeft, lTop, lRight, lBottom);
lParagraph.Render(ADest, lEntityRenderInfo, ADestX, ADestY, AMulX, AMuly); lCurHeight := lCurHeight + (lBottom - lTop);
lParagraph.CalculateBoundingBox(ADest, lLeft, lTop, lRight, lBottom);
lCurHeight := lCurHeight + (lBottom - lTop);
end;
lEntity := GetNextEntity(); lEntity := GetNextEntity();
MergeRenderInfo(lEntityRenderInfo, ARenderInfo); MergeRenderInfo(lEntityRenderInfo, ARenderInfo);
end; end;

View File

@ -153,9 +153,11 @@ begin
// <img src="images/noimage.gif" width="100" height="100" alt="No image" /> // <img src="images/noimage.gif" width="100" height="100" alt="No image" />
'img', 'image': 'img', 'image':
begin begin
lRasterImage := nil;
lWidth := -1;
lHeight := -1;
for i := 0 to lCurNode.Attributes.Length - 1 do for i := 0 to lCurNode.Attributes.Length - 1 do
begin begin
lRasterImage := nil;
lAttrName := lCurNode.Attributes.Item[i].NodeName; lAttrName := lCurNode.Attributes.Item[i].NodeName;
lAttrValue := lCurNode.Attributes.Item[i].NodeValue; lAttrValue := lCurNode.Attributes.Item[i].NodeValue;
@ -196,6 +198,11 @@ begin
end; end;
end; end;
if lWidth <= 0 then
lWidth := lRasterImage.RasterImage.Width;
if lHeight <= 0 then
lHeight := lRasterImage.RasterImage.Height;
if lRasterImage <> nil then if lRasterImage <> nil then
begin begin
lRasterImage.Width := lWidth; lRasterImage.Width := lWidth;