473,396 Members | 1,961 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.

SetPixel question

I have put the following in my Form1_Load event:

Dim Img As Bitmap = New Bitmap(1, 1)
Img.SetPixel(0, 0, Color.Green)
BackgroundImage = Img
TransparencyKey = Img.GetPixel(0, 0)

This makes the background green. It should make the background transparent.

If you comment out the second line, it actually works properly. However, I
need the image to be green.

Any ideas?

Matthew
Nov 21 '05 #1
2 1188
Hi,

Why not try something like this

Private Sub Form1_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint

Me.TransparencyKey = Color.Green

e.Graphics.FillRectangle(Brushes.Green, Me.ClientRectangle)

End Sub

Ken

-------------------------------

"Matthew" <tu*************@alltel.net> wrote in message
news:u2*************@TK2MSFTNGP15.phx.gbl...
I have put the following in my Form1_Load event:

Dim Img As Bitmap = New Bitmap(1, 1)
Img.SetPixel(0, 0, Color.Green)
BackgroundImage = Img
TransparencyKey = Img.GetPixel(0, 0)

This makes the background green. It should make the background transparent.

If you comment out the second line, it actually works properly. However, I
need the image to be green.

Any ideas?

Matthew

Nov 21 '05 #2
> Me.TransparencyKey = Color.Green
e.Graphics.FillRectangle(Brushes.Green, Me.ClientRectangle)


That's perfect.
Thanks Ken!

Matthew
Nov 21 '05 #3

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

Similar topics

2
by: timeash | last post by:
The code below subtracts two images from one another and determines if there is any new things in the picture. A large enough color change will "register" a pixel. The pixel is then plotted using...
3
by: Ekqvist Marko | last post by:
Hi, I have one Access database table including questions and answers. Now I need to give answer id automatically to questionID column. But I don't know how it is best (fastest) to do? table...
1
by: Peter | last post by:
Hi, I found the SetPixel performance is very poor. it took lots of time to twist dots for a large image. I wonder if there is any other way to speed it up. Thanks. Peter ...
3
by: halise | last post by:
Hi, i am in trouble with an exception in .net platform with c#. The exception thrown is exactly as follows: System.ArgumentException: Invalid parameter used. at...
0
by: mark | last post by:
Somebody can explain me why if I put a color with SetPixel the color showed is of another value? For example: I've to draw a grayscale image. The color RGB(90,90,90) become RGB(40,45,60). In the...
3
by: Atmapuri | last post by:
Hi! I was profiling a drawing applicationa and Bitmap.SetPixel is consuming 90% of all CPU. Is there an alternative way to create the bitmap and fill it with data that is stored in an array of...
1
by: tamasumalta | last post by:
I would like to change some pixels inside a particular gif file. I tried using the setpixel and noticed that it is not compatible with indexed images. Then I converted the file from a gif to a bmp...
0
by: Anil Gupte | last post by:
I am using an Image Button from Microsoft's Power Pack. When I use the ..Enabled=True/False I get the following error "SetPixel is not supported for images with indexed pixel formats" I am...
3
by: Seabass | last post by:
Hello everyone, I have to do an image viewer for an exotic format so I want to know how to place pixels somewhere on the form or on some object. I tried doing this but it works incredibly...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
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,...

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.