473,396 Members | 1,816 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Background colour of a new Bitmap

Can anyone advice how to set the background colour of a new Bitmap

Thank you,
Samuel
May 12 '07 #1
3 16966
On May 12, 7:44 pm, "Samuel" <samuel.shul...@ntlworld.comwrote:
Can anyone advice how to set the background colour of a new Bitmap

Thank you,
Samuel
I can't think of a real easy way to do this, but one way would be to
use a nested loop with the bitmap's SetPixel method:

Dim bmp As New Bitmap(40, 40)

For x As Integer = 0 To bmp.Width - 1
For y As Integer = 0 To bmp.Height - 1
bmp.SetPixel(x, y, Color.Blue)
Next
Next

There may be a better way, but I can't think of it at the moment.

Thanks,

Seth Rowe

May 13 '07 #2

"rowe_newsgroups" <ro********@yahoo.comkirjoitti
viestissä:11**********************@q75g2000hsh.goo glegroups.com...
I can't think of a real easy way to do this, but one way would be to
use a nested loop with the bitmap's SetPixel method:

Dim bmp As New Bitmap(40, 40)

For x As Integer = 0 To bmp.Width - 1
For y As Integer = 0 To bmp.Height - 1
bmp.SetPixel(x, y, Color.Blue)
Next
Next

There may be a better way, but I can't think of it at the moment.
This might be much faster and easier solution:

Dim bmp As New Drawing.Bitmap(40, 40)
Dim grap As Drawing.Graphics = Drawing.Graphics.FromImage(bmp)
grap.Clear(Drawing.Color.Blue)

-Teemu

May 13 '07 #3
Thank you for you reply,

I simple use the FillRectangle method of the Graphics object specifying the
colour

Samuel
"Teemu" <ts*****@hotmail.comwrote in message
news:w6********************@reader1.news.saunalaht i.fi...
>
"rowe_newsgroups" <ro********@yahoo.comkirjoitti
viestissä:11**********************@q75g2000hsh.goo glegroups.com...
>I can't think of a real easy way to do this, but one way would be to
use a nested loop with the bitmap's SetPixel method:

Dim bmp As New Bitmap(40, 40)

For x As Integer = 0 To bmp.Width - 1
For y As Integer = 0 To bmp.Height - 1
bmp.SetPixel(x, y, Color.Blue)
Next
Next

There may be a better way, but I can't think of it at the moment.

This might be much faster and easier solution:

Dim bmp As New Drawing.Bitmap(40, 40)
Dim grap As Drawing.Graphics = Drawing.Graphics.FromImage(bmp)
grap.Clear(Drawing.Color.Blue)

-Teemu

May 13 '07 #4

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

Similar topics

6
by: Geoff | last post by:
I need to use a coloured background for a page which contains tables. Using Frontpage 2k I can create the background colour OK and it views correctly; but when viewed using apache, there is no...
1
by: John D | last post by:
I am trying to change the background colour of either a div or a textarea with javascript, but am having problems. I have passed a hex colour value in the variable hval, and with the following...
4
by: Dj Frenzy | last post by:
Hi, I know how to use javascript to change a background image to another background image, and how to change a background colour to another background colour. Is there a way to change an image to a...
4
by: david.graham18 | last post by:
Hi I spotted some nice code to change the background colour of a web page to one of four different colours at random but I can't find it now! The method was to select a number at random from 1...
3
by: Hans Karman | last post by:
Is there any way in which I can have the background colour of one or more records set to the colour stored in a datafield within the record? Hans Karman, Canberra, Australia
4
by: Lachlan Hunt | last post by:
Hi, I'm looking for an interoperable method of determining the current background colour of an element that is set using an external stylesheet. I've tried: elmt.style.backgroundColor; but...
5
by: kaisersose1995 | last post by:
Hi, I am trying to add some visual confirmation to a continous form, to let the user know if a stored date on the form has passed. I have managed to set the background colour using a simple IF...
6
by: Piyu | last post by:
Hi, I am working in jsp pages.in that i used background colour for heading through css.and those colours(heading, image background colour also) are not coming in printing. from my machine i...
3
by: bettyboo | last post by:
Hi I'm new to the forum and also a VERY new user of Access to develop databases. I'm building a DB for a driving instructor acquaintance, and he wants a button on the pupil data entry form which...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...
0
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...
0
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...

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.