I'm new to C# and want a simple app to display a bitmap that is in
bayer format. I searched the group and have an app that can draw pixels
in a picturebox using Pset. My problem is that Pset uses x,y,color,
where color is predefined. I need to draw my pixel based on the value
in my file. So if I get a value for a blue pixel of 50, how do I make
that a darker blue than a value of 100? I know Pset is probably not the
best way to do it, but I'm a newbie and it is easy to use.
Here is my code so far;
for (y = 0; y < 144; y++)
{
for (x = 0; x < 176; x+=4)
{
ByrArray[x, y] = br.ReadByte();
picture.SetPixel(x, y, Color.Red);
picture.SetPixel(x+1, y, Color.Green);
picture.SetPixel(x+2, y, Color.Blue);
picture.SetPixel(x+3, y, Color.Green);
}
}
is there a way to scale the colors?
Thanks
Ringo 5 11279
Ringo wrote:
I'm new to C# and want a simple app to display a bitmap that is in
bayer format. I searched the group and have an app that can draw pixels
in a picturebox using Pset. My problem is that Pset uses x,y,color,
where color is predefined. I need to draw my pixel based on the value
in my file. So if I get a value for a blue pixel of 50, how do I make
that a darker blue than a value of 100? I know Pset is probably not the
best way to do it, but I'm a newbie and it is easy to use.
Here is my code so far;
for (y = 0; y < 144; y++)
{
for (x = 0; x < 176; x+=4)
{
ByrArray[x, y] = br.ReadByte();
picture.SetPixel(x, y, Color.Red);
picture.SetPixel(x+1, y, Color.Green);
picture.SetPixel(x+2, y, Color.Blue);
picture.SetPixel(x+3, y, Color.Green);
}
}
is there a way to scale the colors?
I think that you have made an incorrect assumption about the Color
class. Just because there are some predefined colours, doesn't mean
you're limited to only those colours. Take a look at the constructor:
Color mySpecialColour = new Color(redValue, greenValue, blueValue);
where each of the three values can be from 0 to 255. I believe that
there is also an (easy) way to get a Color based on cmyk values.
Bruce Wood wrote:
Ringo wrote:
I'm new to C# and want a simple app to display a bitmap that is in
bayer format. I searched the group and have an app that can draw pixels
in a picturebox using Pset. My problem is that Pset uses x,y,color,
where color is predefined. I need to draw my pixel based on the value
in my file. So if I get a value for a blue pixel of 50, how do I make
that a darker blue than a value of 100? I know Pset is probably not the
best way to do it, but I'm a newbie and it is easy to use.
Here is my code so far;
for (y = 0; y < 144; y++)
{
for (x = 0; x < 176; x+=4)
{
ByrArray[x, y] = br.ReadByte();
picture.SetPixel(x, y, Color.Red);
picture.SetPixel(x+1, y, Color.Green);
picture.SetPixel(x+2, y, Color.Blue);
picture.SetPixel(x+3, y, Color.Green);
}
}
is there a way to scale the colors?
I think that you have made an incorrect assumption about the Color
class. Just because there are some predefined colours, doesn't mean
you're limited to only those colours. Take a look at the constructor:
Color mySpecialColour = new Color(redValue, greenValue, blueValue);
where each of the three values can be from 0 to 255. I believe that
there is also an (easy) way to get a Color based on cmyk values.
Thanks, so how do I define a new color on the fly?
is there a way to do somethign like picture.SetPixel(x, y, (R,G,B));
I tried adding
Color mySpecialColour = new Color(255,0, 0);
to my program just to see if it would make red but it complains about
not having a constructor.
The type 'System.Drawing.Color' has no constructors defined
How/where do I add the constructor, or is this not what I need to do.
Ringo wrote:
Thanks, so how do I define a new color on the fly?
is there a way to do somethign like picture.SetPixel(x, y, (R,G,B));
I tried adding
Color mySpecialColour = new Color(255,0, 0);
to my program just to see if it would make red but it complains about
not having a constructor.
The type 'System.Drawing.Color' has no constructors defined
How/where do I add the constructor, or is this not what I need to do.
If you look in the .NET documentation, youĝll find a FromArgb() method, which will serve your purpose.
There are two options for you, depending on whether your original image has a transparency (alpha) channel or not:
public static Color FromArgb (
int red,
int green,
int blue
)
or
public static Color FromArgb (
int alpha,
int red,
int green,
int blue
)
Use them like this:
picture.SetPixel(x, y, Color.FromArgb(R, G, B));
Hope that helps.
--
Torben K. Jensen
Use them like this:
>
picture.SetPixel(x, y, Color.FromArgb(R, G, B));
Yes. Sorry. Color (oddly) doesn't have public constructors. Instead it
has the static FromArgb methods. My mistake.
Cool, That is what I needed. Thanks
Bruce Wood wrote:
Use them like this:
picture.SetPixel(x, y, Color.FromArgb(R, G, B));
Yes. Sorry. Color (oddly) doesn't have public constructors. Instead it
has the static FromArgb methods. My mistake.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Steve Long |
last post by:
Hello, (total GDI newbie)
I'm having trouble drawing just a simple line to display in a picturebox. I
just want a straight, dotdash line.
I have two methods, one works and one doesn't (it cause...
|
by: zengou |
last post by:
My application have many picturebox objects,when run it ,sometimes i will have a strange error,how to work out ,help me please!(in windows98,the error cause frequently than in windowsxp)
...
|
by: Tyler Foreman |
last post by:
Hello,
I had an earlier post regarding a strange exception I
(thought) I was getting in my windows form. I have since
been able to trace the problem to a picturebox control on
my form. I can...
|
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...
|
by: kalp suth via DotNetMonster.com |
last post by:
I want to create arrows using lines on a picture in the picture box.
On clicking the button "btnShowAll", the image is loaded and the lines drawn. "RGSShowAll()" calls "DrawObjs()" which does the...
| |
by: Steve Marshall |
last post by:
Hi all,
I am converting an app which used a picturebox to draw graphs etc onto, then
saved them to a file. I can certainly draw things onto a picturbox in
VB.NET, but how do I save them to a...
|
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...
|
by: davetelling |
last post by:
I am not a programmer, I'm an engineer trying to make an interface to a
product I'm designing. I have used C# to make a form that interrogates the
unit via the serial port and receives the data. I...
|
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...
|
by: winzone |
last post by:
I used system.drawing.graphic in C# to draw the Rectangle and Ellipse in PictureBox. In my PC and other my buddy PC show the drawing graphic and color.
But my customer PC doesn't show the drawing...
|
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...
| |
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,...
|
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,...
|
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...
|
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: 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...
|
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...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |