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. 2 2077
> 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.
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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);
|
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...
|
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.
|
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...
|
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
| |
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 ?
|
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)
|
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.
|
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...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |