473,729 Members | 2,177 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2071
> 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.DrawIm age((Image)bitm aps[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
3095
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 onmousedown enevt of the picture: Graphics LGraphics = Graphics.FromImage(imgMap.Image); LGraphics.DrawString("X", new Font("Arial", 12), SystemBrushes.WindowText, AX, AY);
6
4056
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 think...is this wrong?. What about a drawing application just drawing simple one dimensional shapes(Polygons,beziers,polylines etc...) are these video drivers still useful for this?. If the video drivers are not a problem then is there any other performance problems that would be disastrous for a...
3
10152
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, but both give me out of memory errors. In my case, I'm simply trying to draw a portion of the bitmap. The portion is slightly under the 1600x1200 size of my screen. When trying to do it, I get an Out of Memory exception.
13
3342
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 the fly using gdi32 routines that are all in a referenced, custom dll. I call a PrintImage routine in the dll and pass it only the the Picturebox.hdc from the main form. The dll's print routine draws to the hdc and it shows up in the picturebox perfectly. I would like to do a similar thing...
3
2607
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 specific color. I have so far discovered that System.Drawing.Bitmap has a SetPixel() method but I can't seem to find out how to have the bitmap displayed. I would actually like to have the pixels appear as I set them. Regards Chris Saunders
3
2435
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 . Coz loading bitmap takes time...Is there any other way to draw graphics / charts / rectangles without using bitmap or any other image as a background ?
14
2124
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 times, based on random numbers. To give you an idea of what I'd like to do, here's a link to a gif : http://www.chaosmos.net/chaosmoseng/chaosmos7.htm (it is based on a simple algorithm : http://www.chaosmos.net/chaosmoseng/chaosmos6.htm)
5
12875
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 relase button. I'm trying useing this g.DrawLine(..), but I have a lot of line. In C++ is a parameter XORPUT, but in C# I can't find it.
2
8758
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 this in C# by specifying the path to the *.ico file, but I have been unable to get any of the overloads to work in VB.NET. I would like to store the *.ico files in a *.resx file so that users do not need anything other than the *.dll, but at the moment I am just trying to get any of the overloads...
0
9426
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9280
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9200
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8144
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6016
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3238
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.