ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 StretchDraw issue

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
kalyani Posted - Apr 18 2016 : 02:01:11
We are facing issue with StretchDraw function.
We are trying to print one image on canvas.
we are applying scale to that image according to space which we have.
But after drawing this image with StretchDraw function, image is getting stretched more in width according to available space.
So the image we are getting are not in the proper dimensions.
StretchDraw is not working properly at all.
What to do o get image in proportion.

kk
5   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Apr 18 2016 : 17:13:56
Hi

This is more of a TCanvas than an ImageEn question.

It looks like you are treating the Rect.Right and Bottom values as width and height, i.e. it should be:

StretchDraw( Rect( MmToPxX(lLeft + 1),
                   MmToPxY(lTop + 1),
                   MmToPxX(lLeft + 1) + Trunc(imageWidth * lScale),
                   MmToPxY(lTop + 1) + Trunc(imageHeight * lScale)),
             ImageEn.Bitmap );


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
kalyani Posted - Apr 18 2016 : 03:47:40
above was the original image and here is the image after StretchDraw



kk
kalyani Posted - Apr 18 2016 : 03:44:55




kk
kalyani Posted - Apr 18 2016 : 03:36:42
function TBaseReport.fuPrintImage(FilePath: string;
PrintImageRequest: TPrintImageRequest): Integer; //PrintImageRequest has image parameters in mm
var
imageParameter: TImageParameter;
lRatio: Real;
lScale: Real;
lImgRatio: Real;
imageWidth,imageHeight :Double; //actual image height, width
lLeft, lTop, lRight, lBottom, lspaceBetImagePrintArea: double;
begin
Result := -1;

if (not Assigned(PrintImageRequest)) or (not Assigned(PrintImageRequest.imageParameter)) then
exit;

imageParameter := PrintImageRequest.imageParameter;

lLeft := imageParameter.Left;
lTop := imageParameter.Top;
lRight := imageParameter.Right; //width
lBottom := imageParameter.Bottom; //height

lspaceBetImagePrintArea := PrintImageRequest.SpaceBetImageAndRect;

imageWidth := MmToPxX(lRight - lspaceBetImagePrintArea);
imageHeight := MmToPxY(lBottom - lspaceBetImagePrintArea);

lScale := 1;

Result := MmToPxY(lBottom); //result in pixel

with uCurCanvas do
begin
try
try
if (FileExists(FilePath)) then
begin

LoadImageFromFile(FilePath);

if (PrintImageRequest.PrintWithRatio) and (ImageEn.IsEmpty = false) then
begin
lRatio := MmToPxY(imageParameter.Bottom) / MmToPxX(imageParameter.Right);

imageHeight := ImageEn.Bitmap.Height; // actual image ht, wd
imageWidth := ImageEn.Bitmap.Width;
lImgRatio := imageHeight / imageWidth;

if lImgRatio >= lRatio then
lScale := MmToPxY(imageParameter.Bottom) / imageHeight
else
lScale := MmToPxX(imageParameter.Right) / imageWidth;
end;
end;

if PrintImageRequest.DrawRectangeAroundImage then
begin
Rectangle(MmToPxX(lLeft), MmToPxY(lTop), MmToPxX(lRight), MmToPxY(lBottom));
end;

if (ImageEn.IsEmpty = false) then
begin
StretchDraw
(Rect(
MmToPxX(lLeft + 1),
MmToPxY(lTop + 1),
Trunc(imageWidth * lScale),
Trunc(imageHeight * lScale)), ImageEn.Bitmap);
end;


Result := MmToPxY(imageParameter.Bottom - 1); //result in pixels

except
on Ex: Exception do
fuShowMsg('TBaseReport.fuPrintImage' + cNEW_LINE + Ex.message, 1);
end;
finally
ImageEn.Blank;
end; //finally
end; //with uCurCanvas do
end;

kk
xequte Posted - Apr 18 2016 : 03:29:45
Hi

Please show us your code, and attach a few images that show what is occurring.

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com