Solved

how can I horizontaly scroll a very wide bitmap gif or whatever across the form

Posted on 2009-05-14
5
186 Views
Last Modified: 2012-05-07
I have a bitmap that is to wide to display completely in the picture box how can I progromaticly scroll the picture within the picture box without the use of scroll bars
0
Comment
Question by:Dov_B
  • 4
5 Comments
 
LVL 39

Accepted Solution

by:
abel earned 500 total points
ID: 24390107
This needed a bit experimenting to get it right. Esp. the redraw bit for once the image goes inside the rectangle of the Picture control. But here you go. This scrolls to the left in steps of 5 pixels. Make -5 into 5 to do the reverse: scrolling to right.

Dim bmpTemp As New Bitmap(picSourceLarge.Image)
Dim graph As Graphics = Graphics.FromImage(bmpTemp)
Dim aPen As New Pen(New SolidBrush(Color.White), picSourceLarge.Width)
 
' erase background with white
Dim rect As New Rectangle(0, 0, picSourceLarge.Width, picSourceLarge.Height)
graph.DrawRectangle(aPen, rect)
 
' draw scrolled to the left image in a -5 pixel step
graph.DrawImageUnscaled(picSourceLarge.Image, New Point(-5, 0))
picSourceLarge.Image = bmpTemp

Open in new window

0
 
LVL 39

Expert Comment

by:abel
ID: 24390118
picSourceLarge in the code above is supposed to be your picture control on your form, having a picture that is too large, and without scrollbars.
0
 
LVL 39

Expert Comment

by:abel
ID: 24390276
glad it helped :)
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 24390285
Or you could just put the UNSCALED PictureBox inside a Panel (without AutoScroll) and then simply change the Location() Property of the PictureBox to move it around in there...
0
 
LVL 39

Expert Comment

by:abel
ID: 24391154
haha, lol, funny. While I thought about it, all I thought of was the scrollbars, so I didn't even try. Of course you can remove them. Getting to late here. Was a nice exercise regardless and thanks for waking me up ;-)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question