472,328 Members | 1,072 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,328 software developers and data experts.

Drawing bitmaps

Hello everybody.

I am drawing a country map that consists of 149 municipality bitmaps, each
around 25 Kb. I draw it onto the in-memory bitmap, then draw it on the
picture box.
I use C++, but anyways if I were using the C# the question would be the same.
And here is the problem: it takes 700 ms to draw it, and anything above 300
ms is noticable by the human eye.
So, is there any technique that I could use to actually keep the bitmaps in
the memory oince I load them (like in memory stream, or an ArrayList of
objects, or something), so to avoid the issues of losing time on IO
operations?
Is there like a general guideline to follow when it comes to this?

Thanks.

Dec 10 '05 #1
2 1974
> Hello everybody.
Hi!

I am drawing a country map that consists of 149 municipality bitmaps, each
around 25 Kb. I draw it onto the in-memory bitmap, then draw it on the
picture box. Cool!
I use C++, but anyways if I were using the C# the question would be the
same.
And here is the problem: it takes 700 ms to draw it, and anything above
300
ms is noticable by the human eye. I would say that even >50ms is perceptible
So, is there any technique that I could use to actually keep the bitmaps
in
the memory oince I load them (like in memory stream, or an ArrayList of
objects, or something), so to avoid the issues of losing time on IO
operations? what about keeping a reference to them?
perhaps in a structure with some location information. and then store the
structures in an array?

I'm a bit confused because this seems overtly simple and evident... do you
know you could have instance variable?
Say in your form?
Is there like a general guideline to follow when it comes to this? Well usually there is some some instance variable ins some relevant class
which last as long as the problem.
Maybe instance variable in your form.....

Thanks.

Dec 10 '05 #2
Mike wrote:
Hello everybody.

I am drawing a country map that consists of 149 municipality bitmaps,
each around 25 Kb. I draw it onto the in-memory bitmap, then draw it
on the picture box.
You have to determine what is taking the time. Are you loading the
bitmaps from disk before drawing them to the in-memory bitmap? You
really need to do some profiling to see what is taking the time. Without
seeing the code it is not possible to give an accurate solution, but
here's some stuff to check:

- are the bitmaps loaded from disk, if so, then try to pre-load them,
perhaps using a separate thread kicked off from the form constructor so
that they are all loaded before the routine to draw them is run (you'll
need inter-thread communication here).
- are all the bitmaps compatible with the in-memory bitmap, ie the same
colour depth?
- you say the bitmaps are 'municipality bitmaps' which presumably are
not at exact intersections of a grid and are irregular in size, in which
case, check the code that decides where in the in-memory bitmap each
'municipality bitmap' is drawn.
So, is there any technique that I could use to actually keep the
bitmaps in the memory oince I load them (like in memory stream, or an
ArrayList of objects, or something), so to avoid the issues of losing
time on IO operations?
Yes. ArrayList is fine:

string[] names = {"one.bmp", "two.bmp", "three.bmp"};
ArrayList bitmaps = new ArrayList();
foreach(string name in names)
{
bitmaps.Add(new Bitmap(name));
}

// draw image two.bmp at 100, 200:
graphics.DrawImage((Image)bitmaps[1], 100, 200);
Is there like a general guideline to follow when it comes to this?


Profiling is the best course. Also check your loops. The IO operation
that is the slowest is disk IO, so be careful about any code that
accesses files.

Richard
--
http://www.grimes.demon.co.uk/workshops/fusionWS.htm
http://www.grimes.demon.co.uk/workshops/securityWS.htm
Dec 11 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Christina Androne | last post by:
Hi I want to allow the user to drow some locators on an image and connect the locators with lines. So I tried to put the following code in the...
6
by: James dean | last post by:
I have heard that the video drivers in GDI+ are a big performance issue. But is this only an issue with something like Games Programming i...
3
by: Pete Davis | last post by:
I'm having trouble dealing with bitmaps larger than about 10,000 pixels in either direction. I've tried using DrawImage and DrawImageUnscaled,...
13
by: Metallicraft | last post by:
I have a vb6 application. On the main form is a picture box with one or two images and several pieces of text displayed in it. These are created on...
3
by: Chris Saunders | last post by:
I am fairly new to .Net and C# but am familiar with the Win32 API. I wish to set the pixels of the client area of a window one at a time with a...
3
by: pradnyapatil29 | last post by:
I am trying to draw a chart similar to GANTT chart in asp.net. Right now, I am drawing the rectangles on bitmap...but I dont want to use bitmap...
14
by: marko | last post by:
Hi everyone, I'm an artist and I'm looking for a way to draw a line that will zig-zag its way thru an image randomly, crisscrossing itself many...
5
by: Macias | last post by:
Hi, Please help me, how I can make a line drawing on PictureBox similar to MS paint. I thinking about this: click and hold button, move mouse and...
2
by: Nathan Sokalski | last post by:
I am attempting to create icons for controls I have created using VB.NET by using the System.Drawing.ToolboxBitmap attribute. I have managed to do...
0
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
1
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.