PDA

Click to See Complete Forum and Search --> : Scroll bars on image (not on viewing control)


leif-p
Dec 4th, 1999, 07:30 AM
How can I view a very large graphics image file and assign scroll bars and sizing/stretching to the image, without having scroll bars on the sides of the viewing control?

Is there an image file format that will automatically provide a scroll bar on the image itself, independent of the viewing control?

SmashingPumpkinsAddict
Dec 4th, 1999, 02:13 PM
Actually I'm trying to do something very similiar to that right now except I'm trying to scroll a label, not an image. And as long as the text inside the label doesn't have any carriage returns/line feeds in it, it works perfectly. Anyway, more to your subject: what I did was create an array of the lines in the label (each array item (ie LineArray(1)) was one line in the label.) Then I created a sub that would, at a defined position (VScroll1.value), add each line to the label until the maximum number of lines for the label was reached. Getting any ideas yet? Here was the exact code:

Private Sub VScroll1_Change() 'or VScoll1_Scroll

Dim I As Integer
Dim MainLBL As String
LineArrayPos = VScroll1.Value

lblMain = ""
MainLBL = LineArray(LineArrayPos)
For I = 1 To MaxNumberLinesDisplayed 'public variable
MainLBL = MainLBL & LineArray(LineArrayPos + I)
If I <> MaxNumberLinesDisplayed Then
MainLBL = MainLBL & vbCrLf
Else
'dont add carriage return/linefeed
End If
Next I
lblMain = MainLBL
End Sub

OK, so maybe you can tell I'm a little proud of that code. I can up with it all by myself. But my point is that you should be able to do something similiar. Using a image control array, you could divide the original image into several (vertically, horizontally, or both, depending on which way you want to scroll), set your scroll bar Change property according to how you divided the image up, and set its Max property (described in the next paragraph).

I also have another sub that determines the number of lines able to be displayed at once (maxnumberlinesdisplayed) and the Min and Max properties, but thats a little more complicated than what you need to do. All you need to do is find the total number of pixels in the image and subtract that from the number of pixels you can have on the screen at one time and set that number as the Max property.

I know all that is going to be memory intensive, but I don't know how else to do it. About sizing/streching the image, you can use the StrechBitBlt API call (that's not its exact name, I don't think, but its something similiar). Also, to speed up the scrolling process (the drawing part), you will need to use the BitBlt API call anyway, so it shouldn't be too hard to implement StrechBitBlt.

Any other questions? Email me at SmashingPumpkinsAddict@yahoo.com

-Adam

leif-p
Dec 6th, 1999, 10:34 PM
Thanks Adam:

I will look into your suggestions. Do you imply that I would have to read and write each pixel?

I have already used BitBlt to make a percentage bar for showing completion of a job.