Results 1 to 12 of 12

Thread: [VB6] Scrollio Picture Viewer UserControl

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Lightbulb [VB6] Scrollio Picture Viewer UserControl

    This isn't anything amazing but I haven't seen an equivalent here packaged for easy reuse.

    Scrollio is a simple VB6 UserControl with no dependencies that provides a scrollable view of any StdPicture. In addition to scrollbars it allows zooming, either to fit its window or to a specified zoom factor.

    When the ZoomFit property is True Scrollio will rescale to match any resizing done by the container's (Form's) logic.

    VB6's LoadPicture() has some image file type limitations, so if you need to be able to load PNG or TIFF images you could use the GDI+ Flat API or the convenient WIA 2.0 wrapper library.


    Name:  sshot.png
Views: 3556
Size:  21.5 KB


    The control itself is fairly small, and almost all of the attachment archive's size comes from the rest of the demo Project ("Scrolliodo") and even more from the sample images provided.


    To use it in your own Projects just copy Scrollio.ctl and Scrollio.ctx to your Project's folder and then do an "Add file..." in the IDE to add Scrollio.ctx to your Project.


    Tested on Windows 95 OSR2, Windows XP SP3, Windows Vista SP2, and Windows 7 SP1.
    Attached Files Attached Files

  2. #2
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: [VB6] Scrollio Picture Viewer UserControl

    I see your code. You don't blit the part of picture that you have to show but you move the picture, so you need all the image at the right size. So when you change size ratio you make a new image on that ratio. That isn't good idea. If you want an image of a 6000 pixels (4000x6000 if a 24Mpixels image) width to display at 300% you have to make a 18000x12000...and what if you want to do a 2000% zoom???

    look my code. I use cDibSection for drawing on a bitmap in any ratio with a pen (a cDibSection also), using a canvas from printer page dimension, and printing only the desired part of picture...and scale it using system hardware, very fast. I use dpi from printer page and from screen to show at 100% the exact size of printer paper. Also I have the 1:1 means 1 pixel from image is one pixel for screen (the same as 100% for your zoom factor), and two more, the page fit and width fit. When you move the mouse on the form (is a form in a MDI application) you get the exactly position on the image in any zoom and any scrolling position.
    So you may have a very big image and you display only the part you want, and you can make a lot of things on it because it is a DIB. This is a class and not a user control. It is based of vbAccelerator cDib but I have made a lot of changes, with best the release of hdc....(so when i didn't do anything with my image, i didn't hold an hdc. I found that holding an hdc, eventually you get leaks in memory. So the code of Steve McMahon can work for demonstration but not for heavy duty...and maybe you didn't like it)..

    http://www.vbforums.com/showthread.p...d-print-bitmap

  3. #3
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: [VB6] Scrollio Picture Viewer UserControl

    I give one day of my life...for improving your user control scrollio (i like the name...also).
    I put my old cDib...but I do some improvements.
    First...I clear the not so good code for scroll bars. Second I put cDib and take the inner function PageVie and paste it to Scrollio (and modified). So now this function control scroll bars and painting to a picture box, the right way. Also now you haven't the annoying bliniking on the scroll bar (my way is to create a non visible scrollbar..without any use except that can take focus...and has left a value of -6000, so it is visible as state but not visible as the position indicate, so that control take the focus and let blink all night, you can't see - same job I do in gEditBox). Also the Scrollio gain a timer so the scrolling are happen fast, because each command to scroll was only a timer1.enabled = true...So no bottlenecks happens..
    Now you can load the control at design time with wmf or emf or bitmap and set the position, you can scroll it by mouse or and by scroll bars. Because rendering emf produce big images,I thought and found that for my cDib is better to save a copy of metafile, so this metafile saved on the form, not the rendered bitmap. Also you can choose the quality of emf (or wmf), and I put a scroll bar to alter and see what happen. Some other changes...you can find as you see the new scrollio.
    Attached Files Attached Files

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: [VB6] Scrollio Picture Viewer UserControl

    Feel free to make your own enhancements, this was just an example. I thought it did pretty well for a small amount of code, and easy to use as well.

    The scrollbars don't blink in the compiled EXE, because it uses Common Controls 6.0.

  5. #5
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: [VB6] Scrollio Picture Viewer UserControl

    The problem with scroll bars is more on the limitation of 32767 as maximum. If you see on the code, i posted above, i had to cut off the ecxess of a real max to 32767.
    A second problem that i found...is that I cannot open an image >120Mbytes..This isn't a lot. I use 24bit dib so we say for a 40Mbytes image. That isn't much: a 20Mpixel image give a 60Mbyte "flat" image. With dib I can store 60Mbyte image and display 500% without resize it, but only the part we see in the control. The problem come when we display wmf or emf. May be we need a code to render the metafile to the hdc of the control..like a drawing and not as a bimap. in this code there is a routine ro display emf with parameters hdc, hemf and rectangle to display.
    Can we found a real good scroll bar...with max as LONG...and not integer???

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: [VB6] Scrollio Picture Viewer UserControl

    Scrollbars have a signed Integer .Value property. So the range is -32768 to 32767, a range of 64K steps.

    This seems like more than enough steps to be able to scroll by. Even if you have a monitor and display adapter supporting 64K pixel resolution (vertically or horizontally) you have enough for single-pixel scrolling resolution for the entire screen. Even restricting yourself to the positive range provides single-pixel steps for a very high resolution monitor, and at that point who needs single-pixel steps anyway?

    So you just need to use scaling, as I did above to provide a mere 200 steps of scrolling resolution. You might raise this to 500, maybe even 1000. But more than that seems like overkill making the small-change stepping useless for most purposes.

    This was just meant for picture viewing.


    I'm not sure why you want to render metafiles at extremely high DPI densities. They aren't used very much these days anyway so unless somebody has a special need most programs won't need a lot of exotic code for metafiles. Perhaps you should start a separate question thread to get some ideas on that topic. As far as I can tell PaintPicture does exactly what you want though.

  7. #7
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: [VB6] Scrollio Picture Viewer UserControl

    I am going to change code for scroll bars (I totally forgot that is unsign integer...).
    I would like to have 1 pixel scrolling. so 64k is ok. We can't have 64kx64k. All the problem about emf can be bypassed if always repaint it, so in dib we don't render in more dpi all but the part of the emf.
    I would like to see scrollio for generic use. So now with the dib section under it we can use it as double buffer, before "redrawing".
    I am starting to code..

  8. #8
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: [VB6] Scrollio Picture Viewer UserControl

    We can't use the space -32768 to 32767 because...we can't define LargeChange for all that space but from 1 to 32767..

  9. #9
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: [VB6] Scrollio Picture Viewer UserControl

    I need 1 pixel scrolling because I want the scrolling values to became the initial position, in any position, not at n * 200px . You can scroll the image without scroll bars, by mouse move event, at the design time also, so you can feed the scrollio with an emf like a map, and stored as emf in forms file, so with compact size, and set the zoom factor and the position for first display.

  10. #10
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: [VB6] Scrollio Picture Viewer UserControl

    With scrollio we can put an emf in our form, and at design time we can scroll and zoom to the desired position. Then we can disable the hand scrolling and the scrollbars, and we save the form.
    So our application begun with our emf and saw a part of emf and without "controls" (hand scrolling or by scrollbars) we can later scroll or change zoom by programming the scrollio.
    Emf or Wmf saved in the form as compact data. Scrollio render to dib but also keep a copy of original data so we can do that:
    set scrollio.picture =scrollio.picture
    the right picture is the emf and the left is the construction, the creation of dib (clear mostly. height=0 indicates it is empty) and keep a pointer to the original emf picture. When we keep a pointer to an object the object is kept alive, and after all reference to that lost the object is free to lost too, or we can say ..it going to meet the holy object creator...HOC (digital god)...
    With that operation we can render emf to the desired quality. If we have a simple bitmap we can't change the quality, the stretch routine (using HALFTONE) is the best.
    So we can use scrollio to display information from a emf or wmf, perform scrolling or moving or zooming (with proper rendering) as an automatic information display.

    An application can be for education to display by steps (finding inside the optimum rendering zoomfactor for the final display dimension), with two buttons, for forward or backward move, reading positions and zoom factor from a list.

    Another application can be an animator maker, we can drive a scrolling background and we can display what we want on to of the scrollio image (see version 4) from here
    http://www.vbforums.com/showthread.p...-value-updated
    so we grab each image simple and export as a dib, with numbers, to make it an avi later

    There are many manipulation routines to apply effects on a dib. So we work with one control, scrollio with two parts, a front image (the image) and a back image (the dib). Also we can create some others dibs without the control, we can print to any picturebox using dib.thumbnail to picture (fit in or fill in).

    The first inspiration from dilettante, was for a compact, light control. But from my vision, there isn't convenient room for a so simple control. The new scrollio has a lot under but is viewing like the dilettante's control. So we don't loose the feeling.

  11. #11
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: [VB6] Scrollio Picture Viewer UserControl

    This the final scrollio control with an advance example. Included LargeBar1 and rotation for dib, also rotation for jpg reading exif at loading time.
    Attached Images Attached Images  
    Attached Files Attached Files

  12. #12
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: [VB6] Scrollio Picture Viewer UserControl

    http://www.vbforums.com/showthread.p...Scrollio-also)

    New scrollio...Now is an image viewer use page up and page down to change file, up arrow and down arrow to zoom in and zoom out. Moving the mouse we can see all the image in any scale.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width