Hi all,
I have one picturebox in my report in which I am displaying one bitmap image. Currently the bitmap is scaled as 70x70 pixels. Now I want to scale it according to the size of the picturebox in which I display that image.
Note that image is generated by another application which is linked with my Navision database via ATL COM interface.
How can I map the size of controls in Navision so that my image gets scaled properly.
Please help.
0
Comments
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
And also, in the following code is 38 and 42 are fixed for a particular DPI value?
//Write horizontal resolution
BMPFile.SEEK(38);
BMPFile.WRITE(SetResolutionValue);
//Write vertical resolution
BMPFile.SEEK(42);
BMPFile.WRITE(SetResolutionValue);
Thanks for any help.
The recalculation is just about math:
the width and height of the Image control are in 0.01mm (width 100 = 1 mm). DPI is "Dots per Inch" (Dot=Pixel). Your picture have 70x70 pixels. It means, if you select DPI=70 for both axis, the picture will have size 1x1 inch on the report, it means (1 inch = 25,4mm) that it will fill picture box with size 2540x2540 in Nav. If I am right, you need to calculate the DPI as:
DPI = (SizeOfImage/SizeInNav)*2540
But there can be some deviation and you need to find correct proportion...
And the value of SetResolutionValue is integer!
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Thanks for your help. Really a great help for me.
Just to confirm, if I scale the image in a following way then will it give the same result as yours?
Size of image control in Navision 113 * 100 mm
PixelsX = 1024 = Width in pixel of the device
PixelsY = 768 = Height in pixel of the device
MMX = 320 = Width in mm of the device
MMY = 240 = Height in mm of the device
Set X and Y as follow:
X = 113 * (1024/320)
Y = 100 * (768/240)
So my scaled image will be of X * Y pixels. Is this correct?
Thanks for your great help.
The device have DPI = 82 in both axis (it is 81.27 but DPI is integer...). And now it depends on what you want to do. If you will calculate the X and Y, you will get pixel size for image, which will have resolution 82 DPI and will fill the rectangle with size 113x100 mm. But I thought that you have picture 70x70 pixels and you want to scale it. You have two possibilities if you want to have bigger picture:
1) change DPI on the picture (it means change the scale used to show the picture, no change of details or data in the picture, each pixel will be bigger or smaller...) - can be done through my example
2) change pixel size of the picture (it means change size of the BMP, using same scale for displaying, size of pixel will be same, more pixels will be used to display the image...) - you need to create new image from the source...
I do not know, if I understand what you want to do. But the calculation is correct...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Actually 70x70 is not the size of the image which I want to scale. But the scaled image. ( Actually currently I scale it to this fixed value of 70x70).
Kine, can you please tell me how you have calculated DPI of 82. I got somewhat confused.
Please help.
It means for me that 1024 pixels have 320 mm on the device...
Google Calc: 320 millimeters = 12.5984252 in
=> 1024 pixels = 12.5984 inch
DPI = pixel/inch = 1024/12.5984 = 81.28 = 82 dots per inch (Rounded up)
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
I had to find a size (W/H) of a BMP on file sistem...
with this little code (and with help of this thread) I was able to read it through file:
Where FWidth and FHeight are integers.