tags:

views:

512

answers:

1

Hello All,
I am working with delphi. I have TImage, to which I assign a bitmap.

imgmain.Picture.Bitmap := bmpMain;
imgmain.Picture.Bitmap.PixelFormat := pf24bit;

imgmain is object of TImage and bmpMain is object of TBitmap

I want to zoom my image. I have one trackbar on my form and as I click on trackbar the image should get zoom. What should I do?
Thank You.

Edit :
I found some solution at here It works but it cut my image.

+2  A: 
Sertac Akyuz
@Sertac Thanx, It is better than the code I was using. But can you tell me what is significance of line : imgmain.Canvas.Draw(x,y,bmpmain); because, before this line we are not changing bmpmain then why we are drawing it to imgmain? And by words cutting the image, I mean that after zoom It didn't increase the actual length of image, But I want the full image which I didn't get from this code too. One more thing, I have put the image into TScrollBar, Is this creating the problem?
Himadri
@Himadri - we are never changing bmpmain, we are only changing the relation betwen logical units and device units on the TImage canvas. Let me try with an example; Suppose you have a bitmap of width 96px, if your Screen.PixelsPerInch is also 96px `imgmain.Canvas.Draw(x,y,bmpmain)` would draw a 1" width bitmap on the TImage. In isotropic map mode, if you set the horizontal window extent to 100 and horizontal viewport extent to 200, you're saying that 100 logical units on the x axis would be represented with 200px. So the same call would draw the bitmap 192px or 2" or twice the width.
Sertac Akyuz
@Himadri- You can put the TImage in a scroll box of course. Whenever you change the scaling, before drawing on the image, you should calculate and set the new width/height of the image. For the example above it would be f.i. `imgmain.Width := bmpmain.Width * Zoom div 100;`
Sertac Akyuz
@Sertac I wrote this line but it is not changing width of imgmain. Am I missing setting some property? My problem of cut image is yet not solved.
Himadri
@Himadri - I think I see what you mean. It seems that if there is already a graphic assigned to the picture of an image, setting the image's size does not have an effect on the graphic's size. I've updated the answer, please try with the new code.
Sertac Akyuz
@Sertac - Thank You.!! :-)
Himadri