473,770 Members | 1,677 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Alternative to using Bitmap

I'm a VB.NET newbie. I've created a program that plots pixels at random on
the form. I have a 19" LCD monitor with a resolution set to 1280 by 1024. If
you do the math, that means that there are over 1.3 million pixels. In one
version of the program, the pixels start plotting at the upper-left & go down
the form from top to bottom & left to right. In another version, the pixels
are plotted at random. I have a 2.4 GHZ Athlon 64 with 1 gigabyte of RAM. If
DrawImage is inside the For-Next loop, I can see the pixels being plotted.
It's sooo slooow! If DrawImage is outside of the For-Next loop, I sit & stare
at a blank form until the image is drawn. Unfortunately, there is no Pset or
its .NET equivalent. Microsoft in its infinite wisdom chose to not include
it. I want to be able to create a program that can draw fractals. I know that
fractal calculations are time-consuming. I don't want to have to wait for
hours to see a fractal. Is there a faster way to plot individual pixels
without having to resort to using Bitmap? Remember, I'm a newbie. I don't
want a complicated convoluted way to draw pixels. Can I create an object
that will plot pixels faster than Bitmap or am I out of luck? What is the
Path object? Can I use that to plot individual pixels? Thank you. David
Jul 7 '06 #1
10 3310
Can you preconstruct your fractal in a rectangular array first, then
draw it as one image?
Pretend a 2D array is your form that you are drawing to. Only draw it
at the end.

Jul 7 '06 #2

pcnerd wrote:
I'm a VB.NET newbie. I've created a program that plots pixels at random on
the form. I have a 19" LCD monitor with a resolution set to 1280 by 1024. If
you do the math, that means that there are over 1.3 million pixels. In one
version of the program, the pixels start plotting at the upper-left & go down
the form from top to bottom & left to right. In another version, the pixels
are plotted at random. I have a 2.4 GHZ Athlon 64 with 1 gigabyte of RAM. If
DrawImage is inside the For-Next loop, I can see the pixels being plotted.
It's sooo slooow!
Show us your code. My own not-particularly-optimised Mandelbrot program
does a full screen of a part of the Mandelbrot set that is half in,
half out, in about 7 seconds on a 3 GHz P4. Note that programs like
this are often much (order of magnitude) quicker when run without the
debuger attached - once there are no known bugs, run with Ctrl+F5
rather than F5 to try this.
If DrawImage is outside of the For-Next loop, I sit & stare
at a blank form until the image is drawn. Unfortunately, there is no Pset or
its .NET equivalent. Microsoft in its infinite wisdom chose to not include
it.
What's Bitmap.SetPixel then?

--
Larry Lard
Replies to group please
When starting a new topic, please mention which version of VB/C# you
are using

Jul 7 '06 #3
Don't draw the bitmap for every single pixel that you draw. Use a
counter and draw the bitmap for every thousand pixel or something.

pcnerd wrote:
I'm a VB.NET newbie. I've created a program that plots pixels at random on
the form. I have a 19" LCD monitor with a resolution set to 1280 by 1024. If
you do the math, that means that there are over 1.3 million pixels. In one
version of the program, the pixels start plotting at the upper-left & go down
the form from top to bottom & left to right. In another version, the pixels
are plotted at random. I have a 2.4 GHZ Athlon 64 with 1 gigabyte of RAM. If
DrawImage is inside the For-Next loop, I can see the pixels being plotted.
It's sooo slooow! If DrawImage is outside of the For-Next loop, I sit & stare
at a blank form until the image is drawn. Unfortunately, there is no Pset or
its .NET equivalent. Microsoft in its infinite wisdom chose to not include
it. I want to be able to create a program that can draw fractals. I know that
fractal calculations are time-consuming. I don't want to have to wait for
hours to see a fractal. Is there a faster way to plot individual pixels
without having to resort to using Bitmap? Remember, I'm a newbie. I don't
want a complicated convoluted way to draw pixels. Can I create an object
that will plot pixels faster than Bitmap or am I out of luck? What is the
Path object? Can I use that to plot individual pixels? Thank you. David
Jul 7 '06 #4

I haven't done the fractal program yet. I'm still learning VB. So, I can't
show you the code because it doesn't exist. I don't completely understand
fractal math, but I know that the math is time-consuming. I'm still learning
how to plot pixels. Does the managed code & the .NET Framework overhead slow
every thing down? I think that I have a pretty fast PC ( 2.4 GHZ Athlon 64
with 1 gigabyte of RAM). I didn't know about the debugger being attached.
I've been pressing F5. I'll have tp press CTRL + F5 & see if the program runs
faster. Thank you. David

"Larry Lard" wrote:
>
pcnerd wrote:
I'm a VB.NET newbie. I've created a program that plots pixels at random on
the form. I have a 19" LCD monitor with a resolution set to 1280 by 1024. If
you do the math, that means that there are over 1.3 million pixels. In one
version of the program, the pixels start plotting at the upper-left & go down
the form from top to bottom & left to right. In another version, the pixels
are plotted at random. I have a 2.4 GHZ Athlon 64 with 1 gigabyte of RAM. If
DrawImage is inside the For-Next loop, I can see the pixels being plotted.
It's sooo slooow!

Show us your code. My own not-particularly-optimised Mandelbrot program
does a full screen of a part of the Mandelbrot set that is half in,
half out, in about 7 seconds on a 3 GHz P4. Note that programs like
this are often much (order of magnitude) quicker when run without the
debuger attached - once there are no known bugs, run with Ctrl+F5
rather than F5 to try this.
If DrawImage is outside of the For-Next loop, I sit & stare
at a blank form until the image is drawn. Unfortunately, there is no Pset or
its .NET equivalent. Microsoft in its infinite wisdom chose to not include
it.

What's Bitmap.SetPixel then?

--
Larry Lard
Replies to group please
When starting a new topic, please mention which version of VB/C# you
are using

Jul 8 '06 #5

Interesting idea. I haven't considered that. It would be a pretty big array.
If it works, it would probably be faster than going thru the hassle of
creating the bitmap & then setting each pixel & then drawing the bitmap. Pset
would make it a whole lot simpler & easier. My LCD monitor has a resolution
of 1280 by 1024. My PC has 1 gigabyte of RAM. Wouldn't a 1280 by 1024 size
array take up a lot of system resources? How would I draw the array? What is
the source code? Wouldn't I have to use nested For-Next loops to access each
element in the array?

"Steven Nagy" wrote:
Can you preconstruct your fractal in a rectangular array first, then
draw it as one image?
Pretend a 2D array is your form that you are drawing to. Only draw it
at the end.

Jul 8 '06 #6
The array would take up the same amount of memory that a BitMap object
of the same size would.

To draw the array you would create a bitmap, and set the color of each
pixel in the bitmap from the array.

Yes, to reach each element in the array using nested loops is the
easiest way.

pcnerd wrote:
Interesting idea. I haven't considered that. It would be a pretty big array.
If it works, it would probably be faster than going thru the hassle of
creating the bitmap & then setting each pixel & then drawing the bitmap. Pset
would make it a whole lot simpler & easier. My LCD monitor has a resolution
of 1280 by 1024. My PC has 1 gigabyte of RAM. Wouldn't a 1280 by 1024 size
array take up a lot of system resources? How would I draw the array? What is
the source code? Wouldn't I have to use nested For-Next loops to access each
element in the array?

"Steven Nagy" wrote:
>Can you preconstruct your fractal in a rectangular array first, then
draw it as one image?
Pretend a 2D array is your form that you are drawing to. Only draw it
at the end.

Jul 8 '06 #7

So, you are telling me that I still have to use the Bitmap object? Creating
an array is an extra step. I don't want it to be complicated. I want it to
be simple. Won't both the array & the Bitmap object exist in memory at the
same time? I was hoping to avoid using the Bitmap. I was hoping that there
was a simpler way to do it. Apparently, there isn't.

"Göran Andersson" wrote:
The array would take up the same amount of memory that a BitMap object
of the same size would.

To draw the array you would create a bitmap, and set the color of each
pixel in the bitmap from the array.

Yes, to reach each element in the array using nested loops is the
easiest way.

pcnerd wrote:
Interesting idea. I haven't considered that. It would be a pretty big array.
If it works, it would probably be faster than going thru the hassle of
creating the bitmap & then setting each pixel & then drawing the bitmap. Pset
would make it a whole lot simpler & easier. My LCD monitor has a resolution
of 1280 by 1024. My PC has 1 gigabyte of RAM. Wouldn't a 1280 by 1024 size
array take up a lot of system resources? How would I draw the array? What is
the source code? Wouldn't I have to use nested For-Next loops to access each
element in the array?

"Steven Nagy" wrote:
Can you preconstruct your fractal in a rectangular array first, then
draw it as one image?
Pretend a 2D array is your form that you are drawing to. Only draw it
at the end.

Jul 8 '06 #8
Typically, you could assume that if your screen size is 1200 x 1024,
just muliply the 2 to get how many elements in your array (in this
case, around 1.2 million) and then assume each element is an integer
(32 bit to represent your 32bit color) which is 4 bytes. So that means
you have an array with 4 million bytes, or 4mb. You'll find that the
Visual Studio will take at least 30mb ram straight off the bat anyway
so your 4mb array is not so bad.

So then assume you use a bit map to draw it to the screen, the bitmap
only needs to exist during the drawing process. However you could just
draw each pixel manually without using a Bitmap. The Bitmap just makes
it easier to manage, particularly if you want to save the image as a
file later. Bitmap objects can be converted to other types as well so
that your fractal can save as GIF or whatever.

So use an array to create the fractal, then stick it in a bitmap, and
then cleanup the array from memory if you are overly concerned.

Discussion point:
Did you say you have a 64 bit processor? Then perhaps the calculation
will occur faster if you use LONGs instead of INTs. It will take more
RAM, but the calc should be faster because your processer will not need
to do any fancy work to turn your integer calculations into long
calculations. Can anyone provide advice on this? Am I just rambling? It
might be 1 million pixels, but it might be way more than 1 mil
calculations, particularly if fractal math requires multiple recursive
operations.

Jul 11 '06 #9
You state "However you could just draw each pixel manually without using a
Bitmap." Finally! This is what I've been trying to do. Microsoft in its
infinite wisdom chose to not include "Pset" in VB.NET. So, how do I draw each
pixel manually? Can you include example source code? Thank you. David

"Steven Nagy" wrote:
Typically, you could assume that if your screen size is 1200 x 1024,
just muliply the 2 to get how many elements in your array (in this
case, around 1.2 million) and then assume each element is an integer
(32 bit to represent your 32bit color) which is 4 bytes. So that means
you have an array with 4 million bytes, or 4mb. You'll find that the
Visual Studio will take at least 30mb ram straight off the bat anyway
so your 4mb array is not so bad.

So then assume you use a bit map to draw it to the screen, the bitmap
only needs to exist during the drawing process. However you could just
draw each pixel manually without using a Bitmap. The Bitmap just makes
it easier to manage, particularly if you want to save the image as a
file later. Bitmap objects can be converted to other types as well so
that your fractal can save as GIF or whatever.

So use an array to create the fractal, then stick it in a bitmap, and
then cleanup the array from memory if you are overly concerned.

Discussion point:
Did you say you have a 64 bit processor? Then perhaps the calculation
will occur faster if you use LONGs instead of INTs. It will take more
RAM, but the calc should be faster because your processer will not need
to do any fancy work to turn your integer calculations into long
calculations. Can anyone provide advice on this? Am I just rambling? It
might be 1 million pixels, but it might be way more than 1 mil
calculations, particularly if fractal math requires multiple recursive
operations.

Jul 12 '06 #10

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

Similar topics

0
18040
by: Nicolas Guilhot | last post by:
Hi all ! I have a multi-page Tiff image file that I want to convert to PDF. To do so I am using iText library. The conversion is working, but the code execution is very different according to wich iTextSharp.text.Image.getInstance(...) signature I am using : - using code 1 below, the conversion is fast enough but the resulting PDF file is too big (1 817ko sample Tiff file is converted in less than 30 seconds to a 2 764ko PDF file) -...
5
2301
by: Erwin | last post by:
At the moment I'm using a report which contains an indicator to show if a Service group of the company isn't working well or is working perfectly. This indicator is a "*" which looks like a traffic light. Example: When a Service groep does hit the target, the indicator will lit up using the following Control Source: =IIf(>0,8*10*;"*") But now, I would like the use a real bitmap, trafficlight bitmaps, to
5
20292
by: Vin | last post by:
Hi, I am using the following code to draw whatever the user draws using x,y. // draws lines directly on a winform. CreateGraphics().DrawLine(APen, x, y, OldX, OldY); Now how do I save the drawing on to a bmp file on my harddisk? C# code in this regard would be very helpful. I tried all forums but invain.
4
2574
by: John Swan | last post by:
Hello. I'm trying to create a simple program that amongst other things creates a thumbnail of an image (Bitmap) to a set size determined by the user in pixels? The problem is: All of the examples I have seen so far are in c#. Can anyone please provide reference to a c++ managed version. Thanks. John
0
7452
by: Jeff | last post by:
Help!!! The bitmap I am trying to display in a sample Crystal Report is coming up with much less quality than the original bitmap. I have a 300x300 dpi bitmap file that I want to insert at run time into a Crystal Report. The path to the file is stored in a varchar(100) field in a table in SQL Server. The Crystal Report displays the bitmap in the IBlobField object but it
5
2016
by: pcnerd | last post by:
I want to create a program that will do graphics like math functions & fractals & stuff. I've been browsing thru books at the bookstores. Apparently, the Point object replaced Pset. The books explain how to create a Point object, but not how to use it. I want to be able to plot individual pixels. I tried DrawEllipse, but that just draws circles. I reckon that I have to somehow use the Pen & the Point object. I don't want to draw lines. I...
3
14946
by: Bama | last post by:
I already stored the image in the SQL database. How do I retrieve it? Any help is appreciated.
1
1547
by: Martijn Mulder | last post by:
When I want to invoke Dispose() automatically on an object, I can use using(object) { //do something with object } and after the closing brace the object is Disposed(). But what get disposed when I use code like this
2
8760
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
9439
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,...
0
10071
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
10017
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
9882
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7431
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
6690
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
5326
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...
2
3589
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2832
bsmnconsultancy
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...

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.