QrCode Inserted as bmp

ScaleRichView support and discussion (TRichView add-on for WYSIWYG editing)
Post Reply
pgkammath
Posts: 36
Joined: Fri Nov 24, 2017 6:16 am

QrCode Inserted as bmp

Post by pgkammath »

HI,
I am generating a Qrcode via an API, which returns the Qrcode as a BMP file. This file a insert into a Scalerichview as per the function given below. After inserting, the this image is seen as a dot. I am able to click this image and change the properties. After that is image is show correctly. I am using this in an editor. Ataching the properties image for reference. I understand this has something to do with the style may be.

The following is the function

procedure TTextEditorNewForm.InsertQrCode(cCertId:String);
var mStream : TMemoryStream;
bmp : TBitmap;
begin
mstream := TMemoryStream.Create;
try
IdHttp2.Get('http://172.16.15.10:5002/getcertificate/'+ cCertId,mstream);
mstream.Position := 0;
AdvPicture1.Picture.LoadFromStream(mstream);
AdvPicture1.Picture.SaveToFile(ExtractFilePath(Application.ExeName)+'certid.bmp');
finally
FreeAndNil(Mstream);
end;

bmp := TBitmap.Create;
bmp.LoadFromFile(ExtractFilePath(Application.ExeName)+'certid.bmp');

with TextEdit.RichViewEdit do begin
//AddTextNL(' ',rvsKeyword,0,0);
AddTextNL(' ',rvsNormal,0,0);

AddPicture('', bmp, -1);
SetItemExtraIntProperty(ItemCount - 1, rvepImageHeight, 30);
SetItemExtraIntProperty(ItemCount - 1, rvepImageWidth , 30);

//AddTextNL(' ',rvsKeyword,0,0);
AddTextNL(' ',rvsNormal,0,0);
Format;
end;
end;

Kindly help.

Thanks in advance
Attachments
Image1.jpg
Image1.jpg (209.82 KiB) Viewed 54879 times
image-1.jpg
image-1.jpg (201.63 KiB) Viewed 54879 times
Sergey Tkachenko
Site Admin
Posts: 17553
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: QrCode Inserted as bmp

Post by Sergey Tkachenko »

Obviously, it happens because not pixels, but twips or EMU are used as measure units, so 30 is a too small size.
Change the resizing code to:

Code: Select all

SetItemExtraIntProperty(ItemCount - 1, rvepImageHeight, Style.StandardPixelsToUnits(30));
SetItemExtraIntProperty(ItemCount - 1, rvepImageWidth , Style.StandardPixelsToUnits(30));
pgkammath
Posts: 36
Joined: Fri Nov 24, 2017 6:16 am

Re: QrCode Inserted as bmp

Post by pgkammath »

Problem solved.
Thanks
Regards,
Sergey Tkachenko
Site Admin
Posts: 17553
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: QrCode Inserted as bmp

Post by Sergey Tkachenko »

By the way, is smooth scaling OK for these QrCodes? Maybe I should add a property to an image item to disable smooth scaling?
Post Reply