Re: Simplest way to display Image???

new topic     » goto parent     » topic index » view thread      » older message » newer message
lockiedownunder said...

ANYONE?

HOW would I scroll an image thats larger then my bitmap area

OR

HOW can I click on the image and resize/zoom in so that the clicked point is the centre of my display.

Thanks Tony

Assuming you have gotten the image into RAM as a DIB (Device Independant Bitmap) then ...

  • Scrolling. I assume you have a "viewport" into the bitmap such that the viewport cannot display the entire bitmap at once.
    • Use bitBlt or copyBlt and set the destination offset to negative offsets.
    • For example, if you set the X/Y destination to -100,-200 the the effect is to show position 100,200 of the bitmap in the top left corner of the viewport.
    • You can scroll the image this way by linking the relative offset of the ButtonDown location to the viewport's topleft as the delta to apply to the bitBlt destination offset.
    • For example, let's assume that the user clicks and holds down the mouse at position 50 pixels to the right of the viewport's left edge, and 75 pixels from the top of the viewport's top edge - (50,75). Now track the mouse movements and subtract each mouse position from this (50,75).
    • Eg. The mouse moves to (40,68) which means the relative mouse movement is (-10, -7), that is 10 pixels left and 7 pixels up. So now you bitBlt the image to the destination offset (-10,-7) which has the effect of move the image left 10 pixels and up 7 pixels.
    • Now if the mouse position next is (45,67) we still subtract the initial mouse location from this giving (-5, -8), and again you bitBlt the image to destination (-5, -8), this moving the image by the same amont you moved the mouse.
    • On receiving a ButtonUp event you can stop moving the image around.
  • Zooming.
    • Use the stretchBlt to create an enlarged/reduced copy of your original DIB by the parameters you supply. These can be based on the mouse's scrollwheel movement, for example. You then display the new DIB in the viewport.

My technique is to store DIBs in a Pixmap control and bitBlt them to a viewport during its Paint event. If you need better performance, you can calculate which portion of the DIB needs to be bitBlt'ed by using the parameters on the Paint event. This can sometimes improve things by not having to reshow the entire DIB, just the parts that have been exposed.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu