473,657 Members | 2,405 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 17025
On May 12, 7:44 pm, "Samuel" <samuel.shul... @ntlworld.comwr ote:
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_newsgroup s" <ro********@yah oo.comkirjoitti
viestissä:11*** *************** ****@q75g2000hs h.googlegroups. 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.Graphic s = Drawing.Graphic s.FromImage(bmp )
grap.Clear(Draw ing.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*****@hotmai l.comwrote in message
news:w6******** ************@re ader1.news.saun alahti.fi...
>
"rowe_newsgroup s" <ro********@yah oo.comkirjoitti
viestissä:11*** *************** ****@q75g2000hs h.googlegroups. 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.Graphic s = Drawing.Graphic s.FromImage(bmp )
grap.Clear(Draw ing.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
1724
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 background colour, it is just white. Can anyone explain please? Geoff.
1
9332
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 code can change the background colour of the whole page, but only (now) want to change either a textarea of a form or a div. I'm stuck. document.bgColor = hval;
4
2475
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 backgound colour? I have a table with a background that has a picture. When the user hovers over the picture I want the background to change to the background colour of the rest of the page, as if to make the picture disappear.
4
1967
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 to 4 by using the rnd() function and then dividing by modulus 4. The result was then used to select a cell in a 4 cell array which was holding a different colour in each cell of the array. I would like to have this code but lack the knowledge to...
3
2356
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
2150
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 that only works if the colour has been set using the style attribute or previously set using script. I've also tried:
5
2005
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 statement comparing the stored date with the Date() control and the .backcolour vb control. however once the background colour of the field has been set, it sets the colour for every line on the form. Is there anyway of making just specific cells on...
6
15560
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 enabled the button background colour and image option. that is coming but i want globally. from everywhere(from other computers)i want to enabled that option. so please help me. Thanks in advance
3
2600
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 he can click to flag a pupil as "Do Not Rebook" (i.e. if they're a non-payer or something). Upon clicking the button, he wants a value to be recorded in the appropriate field in the table (so we can report on it later) and he also wants the...
0
8420
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8842
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
8740
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
8516
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
8617
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...
0
5642
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();...
1
2743
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
1970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1733
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.