Hello , let me introduce myself , I’m Nicola and I am a new user of XOJO .
I have searched in the forum and I have found nothing.
Recently for a project I was confronted with the problem of printing the report and its export to PDF, These are the problems I encountered and my solutions.
Using RSReport I was confronted with the problem of printing images considering them as rows , to be able to print a variable number per page .
The problem that arises if the image is larger than it needs to be printed , is sized correctly, but the “MMToPixel ( imageROW.Height_MM )” returns the actual size of the image and not the scaling dimension , getting high the calculation of that line .
The first solution to solve this problem is to resize manually the image, but the image appears in low resolution.
The best solution I’ve found is to change the PPI of the image to set the exact size using a high resolution image for a good printing result .
This is the code that I wrote:
Function imgPPIchange (img as Picture,Wmm as double,Hmm as double) as Picture
Dim V,PPI,WI,V1 as Double
Dim PPM as UInt16
WI=img.Width
V=WI/Wmm
V1=img.Height/Hmm
if V<V1 then V=V1
V=V*1000
PPM=Ceil(V)
PPI=PPM/39.3701
'http://en.wikipedia.org/wiki/BMP_file_format
'In Example1 Table -> Offset 26h and 2Ah
dim mb as MemoryBlock
mb=img.GetData(img.FormatBMP,-1)
dim B1 as byte
dim B2 as byte
B1 = Bitwise.ShiftRight(PPM,8)
B2 = Bitwise.BitAnd(PPM,255)
mb.Byte(38)=B2
mb.Byte(39)=B1
mb.Byte(40)=0
mb.Byte(41)=0
mb.Byte(42)=B2
mb.Byte(43)=B1
mb.Byte(44)=0
mb.Byte(45)=0
Dim oPicture as Picture
oPicture = Picture.FromData (mb)
Return oPicture
Sorry for my english, but I use a translator
I hope I was clear