Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Drawing / October 2005

Tip: Looking for answers? Try searching our database.

Scrolling big image on screen

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JocK - 27 Oct 2005 10:55 GMT
Hello everybody,

I am C#/.NET newbie.
I have been tasked to write a graphics application using C#.
The application needs to visualize an image that is narrow and very
long. Typically images have width=1024 pixel and height= 40000 pixel.
Of course is impossible to completely visualize such an image on the
screen, so the standard solution (in this type of applications) is to
visualize only a part of the image (all the columns, but only some
rows) on a control.
Two buttons will be available "scroll up" and "scroll down" and
employing a timer the image will scrolls up or down automatically.
At the moment I implement this keeping a rectangle object that is
shifting up or down every timer tick. The timer tick is 125 ms, and the
vertical shift is about 50 pixels, so a big part of the image is just
moved on the screen up or down, while only a small part of the image is
actually new data. At the moment when I need to paint I do something
like the following (I re-draw all the image every time):

dc.InterpolationMode = InterpolationMode.NearestNeighbor;
Point ulCorner = new Point(10, 100);
Point urCorner = new Point(this.Width-10, 100);
Point llCorner = new Point(10, this.Height);
Point[] destPara = {ulCorner, urCorner, llCorner};
dc.DrawImage( myImage, destPara, box, GraphicsUnit.Pixel);

where box is the shifting rectangle.

The performance are acceptable, but I would like to know if is possible
to do something better. The followings are just two ideas, your
recommendations would be very appreciated (also new ideas are welcome):

1.    In the timer tick event handler is possible to capture the image
that is already on the screen and shift it down or up, than add (draw)
only the new part. Would this bring a performance improvement? If yes
how would you do that?

2.    At the moment myImage (that is 1024*40000) is completely allocated
in memory using PixelFormat.Format32bppPArgb, even if the image in 8
bit per pixel grayscale. I changed to Format32bppPArgb because using
Format8bppIndexed (I don't understand because 8bppGrayScale doesn't
exists) the performances are really bad. Of course having such image
with 32 bit per pixel completely in memory wastes a lot of space
(around 160 Mb memory allocated). Would be possible inside the onPaint
event to crop only the part of the image I need to draw convert it to
32 bit per pixel on the fly and draw it? If yes how would you do that?

Any new idea would also be greatly appreciated!!!
Thanks a lot
JocK
SharpCoderMP - 28 Oct 2005 16:16 GMT
a'm afraid that doing all the stuff you'd suggested is not a good idea
for c#/.net ... but i may be wrong :) there is quite powerfull freeimage
lib that may help you with perfomance but as far as i know its .net
version is just a wrapper for unmanaged code and also, using it
introduces some difficulties.

> Hello everybody,
>
[quoted text clipped - 46 lines]
> Thanks a lot
> JocK

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.