I draw a figures on a windows form, not on picturebox. And I would like to save view of my windows form to special folder on desktop. I dont know if better will be make a screenshot or i should try to save it as an image (bitmap) in my folder.
Generally I tried both options but it doesnt work :(
I put here one of my attempt ...
public void Form1_Paint(object sender, PaintEventArgs e)
{
int x1, y1, x2, y2;
Random losowa1 = new Random();
x1 = losowa1.Next(0, 200);
y1 = losowa1.Next(120, 300);
x2 = losowa1.Next(300, 480);
y2 = losowa1.Next(120,300);
e.Graphics.FillRectangle(Brushes.Black, x1, y1, 100, 100);
e.Graphics.FillEllipse(Brushes.Black, x2, y2, 100, 100);
Bitmap bitmap = new Bitmap(this.Width, this.Height);
DrawToBitmap(bitmap, new Rectangle(0, 0, bitmap.Width, bitmap.Height));
bitmap.Save("#C:\\Desktop", ImageFormat.Jpeg);
// MessageBox.Show("saved");
System.Threading.Thread.Sleep(1000);
this.Close();
}
and
private void button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < 3; i++)
{
Form1 OknoStart = new Form1();
OknoStart.ShowDialog();
}
try this
int i;
public Form1(int i)
{
InitializeComponent();
this.i = i;
}
private void Form1_Load(object sender, EventArgs e)
{
using (Bitmap bmp = new Bitmap(this.Width, this.Height))
{
this.DrawToBitmap(bmp, new Rectangle(Point.Empty, bmp.Size));
bmp.Save(#"C:\Users\User\Desktop\sample" + i+".png", ImageFormat.Png);
}
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
int x1, y1, x2, y2;
Random losowa1 = new Random();
x1 = losowa1.Next(0, 200);
Random losowa2 = new Random();
y1 = losowa2.Next(0, 480);
Random losowa3 = new Random();
x2 = losowa1.Next(300, 500);
Random losowa4 = new Random();
y2 = losowa2.Next(0, 480);
e.Graphics.FillRectangle(Brushes.Black, x1, y1, 100, 100);
e.Graphics.FillEllipse(Brushes.Black, x2, y2, 100, 100);
System.Threading.Thread.Sleep(2000);
this.Close();
}
private void button1_Click(object sender, EventArgs e)
{
for (int i=0;i<3;i++) {
Form1 form1 = new Form1(i);
form1.ShowDialog();
}
}
Related
I have drawn a grid on form 8 in on paint event of the form as shown below. I have written a class drawRules in which I mentioned to draw the vertical and horizontal lines based on input from the form.
protected override void OnPaint(PaintEventArgs e)
{
Graphics g;
g = e.Graphics;
Pen linePen = new Pen(System.Drawing.Color.CornflowerBlue);
Int32 Num_of_Lines;
Int32 gridLength;
Int32 gridWidth;
bool IsIntValue = Int32.TryParse(Form7.setValue2, out Num_of_Lines);
bool IsIntValue1 = Int32.TryParse(Form7.setValue3, out gridWidth);
bool IsIntValue2 = Int32.TryParse(Form7.setValue4, out gridLength);
this.Size = new Size(Num_of_Lines * gridWidth, Num_of_Lines * gridLength);
if (IsIntValue)
{
if (IsIntValue1)
{
if (IsIntValue2)
{
drawRules.verticalRule vr1 = new drawRules.verticalRule(g, gridWidth, gridLength, Num_of_Lines);
//Draw horizontal line
drawRules.horizontalRule hr1 = new drawRules.horizontalRule(g, gridWidth, gridLength, Num_of_Lines);
}
linePen.Dispose();
base.OnPaint(e);
}
}
}
after this I want to draw circles wherever mouse is clicked for which I mentioned the mouse click event
private void Form8_MouseClick_1(object sender, MouseEventArgs e)
{
int r1 = e.X;
int r2 = e.Y;
Graphics g2;
g2 = this.CreateGraphics();
drawRules newclass1 = new drawRules();
newclass1.addcoordinate(r1, r2, g2);
}
addcoordinate1 is a method in drawRules class which is called to draw circle. Also, i am writing those coordinates in a file
public void addcoordinate(int r1, int r2, Graphics g2)
{
int gridWidth;
int gridLength;
int Num_of_Lines;
bool IsIntValue = Int32.TryParse(Form7.setValue2, out Num_of_Lines);
bool IsIntValue1 = Int32.TryParse(Form7.setValue3, out gridWidth);
bool IsIntValue2 = Int32.TryParse(Form7.setValue4, out gridLength);
Rectangle rectangle = new Rectangle();
PaintEventArgs arg = new PaintEventArgs(g2, rectangle);
Pen redPen1 = new Pen(Color.Red, 3);
DrawCircle(arg, redPen1, r1, r2, 8, 8);
System.IO.StreamWriter objWriter;
objWriter = new System.IO.StreamWriter("test.txt", true);
objWriter.Write(r1);
objWriter.Write(" ");
objWriter.Write(r2);
objWriter.WriteLine();
objWriter.Close();
}
public void DrawCircle(PaintEventArgs e, Pen redpen1, int x, int y, int
width, int height)
{
e.Graphics.DrawEllipse(redpen1, x - width / 2, y - height / 2, width, height);
redpen1.Dispose();
}
Now, I want to delete that circle, for which mouse is double clicked inside circle's area.
Please suggest how to delete the circles without deleting the grids behind. I will be grateful, if someone help me in this.
Don't draw in the code that gets executed when clicking the Button.
Save the coordinates and let the OnPaint methode handle it.
To remove your cirlces just remove them from the list.
private List<Point> circleCoordinates = new List<Point>();
public Form1()
{
InitializeComponent();
}
public void addcoordinate(int r1, int r2)
{
this.circleCoordinates.Add(new Point(r1, r2));
}
protected override void OnPaint(PaintEventArgs e)
{
// linedrawing goes here
foreach (Point point in this.circleCoordinates)
{
e.Graphics.DrawEllipse(Pens.Black, new Rectangle(point, new Size(10, 10)));
}
base.OnPaint(e);
}
private void Form1_MouseDoubleClick(object sender, MouseEventArgs e)
{
for (int i = this.circleCoordinates.Count() - 1; i >= 0; i--)
{
Rectangle ellipseRectangle = new Rectangle(this.circleCoordinates[i].X - 5, this.circleCoordinates[i].Y - 5, 10, 10)
GraphicsPath path = new GraphicsPath();
path.AddEllipse(ellipseRectangle);
if(path.IsVisible(e.Location))
{
this.circleCoordinates.RemoveAt(i);
}
//invalidate form to trigger repainting
this.Invalidate();
}
How can I make a free-form selection (like in paint or photoshop) in a picture box and then crop that selection and save it to a folder?
I already did a rectangle crop but I want that free-form selection..
Here is my rectangle crop:
Image img;
bool mouseClicked;
Point startPoint = new Point();
Point endPoint = new Point();
Rectangle rectCropArea;
private void Button1_Click(System.Object sender, System.EventArgs e)
{
}
private void OnLoad(System.Object sender, System.EventArgs e)
{
loadPrimaryImage();
}
private void loadPrimaryImage()
{
img = Image.FromFile("..\\..\\images.jpg");
PictureBox1.Image = img;
}
private void PicBox_MouseUp(System.Object sender, System.Windows.Forms.MouseEventArgs e)
{
mouseClicked = false;
if ((endPoint.X != -1)) {
Point currentPoint = new Point(e.X, e.Y);
Y1.Text = e.X.ToString();
Y2.Text = e.Y.ToString();
}
endPoint.X = -1;
endPoint.Y = -1;
startPoint.X = -1;
startPoint.Y = -1;
}
private void PicBox_MouseDown(System.Object sender, System.Windows.Forms.MouseEventArgs e)
{
mouseClicked = true;
startPoint.X = e.X;
startPoint.Y = e.Y;
//Display coordinates
X1.Text = startPoint.X.ToString();
Y1.Text = startPoint.Y.ToString();
endPoint.X = -1;
endPoint.Y = -1;
rectCropArea = new Rectangle(new Point(e.X, e.Y), new Size());
}
private void PicBox_MouseMove(System.Object sender, System.Windows.Forms.MouseEventArgs e)
{
Point ptCurrent = new Point(e.X, e.Y);
if ((mouseClicked)) {
if ((endPoint.X != -1)) {
//Display Coordinates
X1.Text = startPoint.X.ToString();
Y1.Text = startPoint.Y.ToString();
X2.Text = e.X.ToString();
Y2.Text = e.Y.ToString();
}
endPoint = ptCurrent;
if ((e.X > startPoint.X & e.Y > startPoint.Y)) {
rectCropArea.Width = e.X - startPoint.X;
rectCropArea.Height = e.Y - startPoint.Y;
} else if ((e.X < startPoint.X & e.Y > startPoint.Y)) {
rectCropArea.Width = startPoint.X - e.X;
rectCropArea.Height = e.Y - startPoint.Y;
rectCropArea.X = e.X;
rectCropArea.Y = startPoint.Y;
} else if ((e.X > startPoint.X & e.Y < startPoint.Y)) {
rectCropArea.Width = e.X - startPoint.X;
rectCropArea.Height = startPoint.Y - e.Y;
rectCropArea.X = startPoint.X;
rectCropArea.Y = e.Y;
} else {
rectCropArea.Width = startPoint.X - e.X;
rectCropArea.Height = startPoint.Y - e.Y;
rectCropArea.X = e.X;
rectCropArea.Y = e.Y;
}
PictureBox1.Refresh();
}
}
private void PicBox_Paint(System.Object sender, System.Windows.Forms.PaintEventArgs e)
{
Pen drawLine = new Pen(Color.Red);
drawLine.DashStyle = DashStyle.Dash;
e.Graphics.DrawRectangle(drawLine, rectCropArea);
}
private void btnCrop_Click(System.Object sender, System.EventArgs e)
{
PictureBox2.Refresh();
Bitmap sourceBitmap = new Bitmap(PictureBox1.Image, PictureBox1.Width, PictureBox1.Height);
Graphics g = PictureBox2.CreateGraphics();
if (!(CheckBox1.Checked)) {
g.DrawImage(sourceBitmap, new Rectangle(0, 0, PictureBox2.Width, PictureBox2.Height), rectCropArea, GraphicsUnit.Pixel);
sourceBitmap.Dispose();
} else {
int x1 = 0;
int x2 = 0;
int y1 = 0;
int y2 = 0;
try {
x1 = Convert.ToInt32(CX1.Text);
x2 = Convert.ToInt32(CX2.Text);
y1 = Convert.ToInt32(CY1.Text);
y2 = Convert.ToInt32(CY2.Text);
} catch (Exception ex) {
MessageBox.Show("Enter valid Coordinates (only Integer values)");
}
if (((x1 < x2 & y1 < y2))) {
rectCropArea = new Rectangle(x1, y1, x2 - x1, y2 - y1);
} else if ((x2 < x1 & y2 > y1)) {
rectCropArea = new Rectangle(x2, y1, x1 - x2, y2 - y1);
} else if ((x2 > x1 & y2 < y1)) {
rectCropArea = new Rectangle(x1, y2, x2 - x1, y1 - y2);
} else {
rectCropArea = new Rectangle(x2, y2, x1 - x2, y1 - y2);
}
PictureBox1.Refresh();
//This repositions the dashed box to new location as per coordinates entered.
g.DrawImage(sourceBitmap, new Rectangle(0, 0, PictureBox2.Width, PictureBox2.Height), rectCropArea, GraphicsUnit.Pixel);
sourceBitmap.Dispose();
}
}
private void pictureBox1_MouseClick(System.Object sender, System.Windows.Forms.MouseEventArgs e)
{
PictureBox1.Refresh();
}
private void CheckBox1_CheckedChanged(System.Object sender, System.EventArgs e)
{
if ((CheckBox1.Checked)) {
CX1.Visible = true;
Label10.Visible = true;
CY1.Visible = true;
Label9.Visible = true;
CX2.Visible = true;
Label8.Visible = true;
CY2.Visible = true;
Label7.Visible = true;
X1.Text = "0";
X2.Text = "0";
Y1.Text = "0";
Y2.Text = "0";
} else {
CX1.Visible = false;
Label10.Visible = false;
CY1.Visible = false;
Label9.Visible = false;
CX2.Visible = false;
Label8.Visible = false;
CY2.Visible = false;
Label7.Visible = false;
}
}
public Form1()
{
Load += OnLoad;
}
}
To copy a free-form selection you need to work with polygons.
Here is a complete example. Just paste this into a new solution and try it out (just change the path to the images).
It will create 2 pictureboxes and load an image into the first one and also create an image. Then you can click on the first image and when you have clicked 2 times it will start to show a selection, when you are finished just press the button and it will copy the selection to the other pictureBox and then save it as an png image.
What it does is to create a brush from the first image and then paint the polygon onto another image and set the other pixels in the rectangle to a background color of your choice, in this case the color: Color.Transparent.
Example:
public partial class Form1 : Form {
private List<Point> _points = new List<Point>();
private PictureBox _pictureBox1;
private PictureBox _pictureBox2;
private Button _button1;
public Form1() {
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e) {
Size = new Size(1366, 675);
_pictureBox1 = new PictureBox {
Location = new Point(12, 51),
Size = new Size(651, 474),
BorderStyle = BorderStyle.FixedSingle
};
_pictureBox2 = new PictureBox
{
Location = new Point(669, 51),
Size = new Size(651, 474),
BorderStyle = BorderStyle.FixedSingle
};
_button1 = new Button {
Text = #"Copy selected area",
Location = new Point(13, 13),
Size = new Size(175, 23)
};
Controls.AddRange(new Control[] { _pictureBox1, _pictureBox2, _button1 });
_pictureBox1.Image = Image.FromFile(#"d:\temp\Hopetoun_falls.jpg");
_points = new List<Point>();
_pictureBox1.MouseDown += delegate(object o, MouseEventArgs args) { _points.Add(args.Location); _pictureBox1.Refresh(); };
_pictureBox1.Paint += pictureBox1_Paint;
_button1.Click += button_Click;
}
private void pictureBox1_Paint(object sender, PaintEventArgs e) {
if (_points.Count < 2) {
return;
}
var max = _points.Count;
for (int i = 1; i < max; i++) {
e.Graphics.DrawLine(Pens.Red, _points[i-1].X, _points[i-1].Y, _points[i].X, _points[i].Y);
}
e.Graphics.DrawLine(Pens.Red, _points[max - 1].X, _points[max - 1].Y, _points[0].X, _points[0].Y);
}
private static Bitmap GetSelectedArea(Image source, Color bgColor, List<Point> points) {
var bigBm = new Bitmap(source);
using (var gr = Graphics.FromImage(bigBm)) {
// Set the background color.
gr.Clear(bgColor);
// Make a brush out of the original image.
using (var br = new TextureBrush(source)) {
// Fill the selected area with the brush.
gr.FillPolygon(br, points.ToArray());
// Find the bounds of the selected area.
var sourceRect = GetPointListBounds(points);
// Make a bitmap that only holds the selected area.
var result = new Bitmap(sourceRect.Width, sourceRect.Height);
// Copy the selected area to the result bitmap.
using (var resultGr = Graphics.FromImage(result)) {
var destRect = new Rectangle(0, 0, sourceRect.Width, sourceRect.Height);
resultGr.DrawImage(bigBm, destRect, sourceRect, GraphicsUnit.Pixel);
}
// Return the result.
return result;
}
}
}
private static Rectangle GetPointListBounds(List<Point> points) {
int xmin = points[0].X;
int xmax = xmin;
int ymin = points[0].Y;
int ymax = ymin;
for (int i = 1; i < points.Count; i++) {
if (xmin > points[i].X) xmin = points[i].X;
if (xmax < points[i].X) xmax = points[i].X;
if (ymin > points[i].Y) ymin = points[i].Y;
if (ymax < points[i].Y) ymax = points[i].Y;
}
return new Rectangle(xmin, ymin, xmax - xmin, ymax - ymin);
}
private void button_Click(object sender, EventArgs e) {
if (_points.Count < 3) {
return;
}
var img = GetSelectedArea(_pictureBox1.Image, Color.Transparent, _points);
_pictureBox2.Image = img;
_pictureBox2.Image.Save(#"d:\temp\sample.png", ImageFormat.Png);
}
}
xPanel.Save(ms, System.Drawing.Imaging.ImageFormat.Png); should save in Memory stream, ms, each line that is drawn showing 9 ellipses. Is below there is no output png just a objGraphicPanel.FillRectangle screen.
Missing is the "F" in PointF x1, y1, x2 and y2 are single floats.
protected void Page_Load(object sender, EventArgs e)
{
...
using (Bitmap xPanel = new Bitmap(500, 500))
{
using (Graphics objGraphicPanel = Graphics.FromImage(xPanel))
{
//Background White
SolidBrush whiteBrush = new SolidBrush(Color.White);
objGraphicPanel.FillRectangle(whiteBrush, 0, 0, 200, 200);
Pen colorPen = new Pen(Color.Black, 2);
MemoryStream ms = new MemoryStream();
for (k = 1; k <= 9; k++)
{
for (int nn = 2; nn <= n; nn++)
{
float x1 = Convert.ToSingle(XYecl[k, nn - 1]);
float y1 = Convert.ToSingle(ZYecl[k, nn - 1]);
float x2 = Convert.ToSingle(XYecl[k, nn]);
float y2 = Convert.ToSingle(ZYecl[k, nn]);
PointF[] ptf =
{
new PointF(x1, y1),
new PointF(x2, y2)
};
objGraphicPanel.DrawLines(colorPen, ptf);
xPanel.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
}
}
string Imgbase64 = Convert.ToBase64String(ms.ToArray());
MyImage.Src = "data:image/png;base64," + Imgbase64;
objGraphicPanel.Dispose();
}
xPanel.Dispose();
}
<img ID="MyImage" runat="server" />
At the moment my code takes about 10% of my CPUs power. How can I make it more efficient and less flickerish?
Code:
private void timer1_Tick(object sender, EventArgs e)
{
DrawLocal();
Thread.Sleep(17);
pictureBox1.Invalidate();
}
private void DrawLocal()
{
int localReadX = ReadAddress("hl2", "client.dll+0xBFFF00 364 0");
int localReadY = ReadAddress("hl2", "client.dll+0xBFFF00 368 0");
byte[] bytesOflocalX = BitConverter.GetBytes(localReadX);//converts to float
byte[] bytesOflocalY = BitConverter.GetBytes(localReadY);//converts to float
float localX = BitConverter.ToSingle(bytesOflocalX, 0)/10;//converts to float
float localY = BitConverter.ToSingle(bytesOflocalY, 0)/10;//converts to float
Graphics localP = pictureBox1.CreateGraphics();
localP.FillRectangle(new SolidBrush(Color.Red), localX, localY, 5, 5);
Graphics localName = pictureBox1.CreateGraphics();
localName.DrawString(" local", new Font("Arial", 7), new SolidBrush(Color.Red), localX, localY);
}
The comments above, demonstrated below:
private Font f = new Font("Arial", 7);
public Form1()
{
InitializeComponent();
pictureBox1.Paint += pictureBox1_Paint;
}
private void timer1_Tick(object sender, EventArgs e)
{
pictureBox1.Invalidate();
}
void pictureBox1_Paint(object sender, PaintEventArgs e)
{
int localReadX = ReadAddress("hl2", "client.dll+0xBFFF00 364 0");
int localReadY = ReadAddress("hl2", "client.dll+0xBFFF00 368 0");
byte[] bytesOflocalX = BitConverter.GetBytes(localReadX);//converts to float
byte[] bytesOflocalY = BitConverter.GetBytes(localReadY);//converts to float
float localX = BitConverter.ToSingle(bytesOflocalX, 0) / 10;//converts to float
float localY = BitConverter.ToSingle(bytesOflocalY, 0) / 10;//converts to float
e.Graphics.FillRectangle(Brushes.Red, localX, localY, 5, 5);
e.Graphics.DrawString(" local", f, Brushes.Red, localX, localY);
}
I am trying to save an image I have processed in my program. e.g. added pseudocolor to the original image
I have tried a few methods, each time i get an error.
A generic error occurred in GDI+.
Can anyone tell me how to properly implement a save method?
Here is the latest attempt:
using System;
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Text;
using System.Windows.Forms;
namespace IMGPROC
{
public partial class Form1 : Form
{
public Bitmap original_image, proc_image;
public Form1()
{
InitializeComponent();
original_image = null;
proc_image = null;
}
private void Form1_Load(object sender, EventArgs e)
{
}
public void Form1_Paint(object sender, PaintEventArgs e)
{
if (original_image != null)
{
Graphics g = e.Graphics;
Rectangle r = new Rectangle(10, 50, original_image.Width, original_image.Height);
g.DrawImage(original_image, r);
}
}
// OPEN IMAGE FILE
/******************************************************************************************/
private void openToolStripMenuItem_Click_1(object sender, EventArgs e)
{
// show the openFile dialog box
Graphics g = this.CreateGraphics();
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
original_image = new Bitmap(openFileDialog1.FileName);
}
Rectangle r = new Rectangle(10, 50, original_image.Width, original_image.Height);
g.DrawImage(original_image, r);
}
// SAVE IMAGE FILE
/******************************************************************************************/
private void saveAsToolStripMenuItem_Click(object sender, System.EventArgs e)
{
SaveFileDialog save = new SaveFileDialog();
save.Filter = "Bitmap Image (.bmp)|*.bmp|Gif Image (.gif)|*.gif |JPEG Image (.jpeg)|*.jpeg |Png Image (.png)|*.png |Tiff Image (.tiff)|*.tiff |Wmf Image (.wmf)|*.wmf |All files (*.*)|*.*";
save.FilterIndex = 4;
save.InitialDirectory = "C:\\";
save.RestoreDirectory = true;
if (save.ShowDialog() == DialogResult.OK)
{
proc_image.Save(save.InitialDirectory);
}
}
// EXIT APPLICATION
/************************************************************************************/
private void exitToolStripMenuItem_Click_1(object sender, EventArgs e)
{
Dispose();
Application.Exit();
}
private void btnRed_Click(object sender, System.EventArgs e)
{
Graphics g = this.CreateGraphics();
int width = original_image.Width;
int height = original_image.Height;
Color pixel;
Rectangle r = new Rectangle(535, 50, original_image.Width, original_image.Height);
Rectangle r2 = new Rectangle(0, 0, original_image.Width, original_image.Height);
Rectangle r3 = new Rectangle(10, 50, original_image.Width, original_image.Height);
g.DrawImage(original_image, r3);
Bitmap proc_image = new Bitmap(width, height, PixelFormat.Format24bppRgb);
for (int y = 0; y < height; ++y)
{
for (int x = 0; x < width; ++x)
{
pixel = original_image.GetPixel(x, y);
proc_image.SetPixel(x, y, Color.FromArgb(pixel.R, 0, 0));
}
} g.DrawImage(proc_image, r);
}
private void btnGreen_Click(object sender, System.EventArgs e)
{
Graphics g = this.CreateGraphics();
int width = original_image.Width;
int height = original_image.Height;
Color pixel;
Rectangle r = new Rectangle(535, 50, original_image.Width, original_image.Height);
Rectangle r2 = new Rectangle(0, 0, original_image.Width, original_image.Height);
Rectangle r3 = new Rectangle(10, 50, original_image.Width, original_image.Height);
g.DrawImage(original_image, r3);
Bitmap bitmap_colour = new Bitmap(width, height, PixelFormat.Format24bppRgb);
for (int y = 0; y < height; ++y)
{
for (int x = 0; x < width; ++x)
{
pixel = original_image.GetPixel(x, y);
bitmap_colour.SetPixel(x, y, Color.FromArgb(0, pixel.G, 0));
}
} g.DrawImage(bitmap_colour, r);
}
private void btnBlue_Click(object sender, System.EventArgs e)
{
Graphics g = this.CreateGraphics();
int width = original_image.Width;
int height = original_image.Height;
Color pixel;
Rectangle r = new Rectangle(535, 50, original_image.Width, original_image.Height);
Rectangle r2 = new Rectangle(0, 0, original_image.Width, original_image.Height);
Rectangle r3 = new Rectangle(10, 50, original_image.Width, original_image.Height);
g.DrawImage(original_image, r3);
Bitmap bitmap_colour = new Bitmap(width, height, PixelFormat.Format24bppRgb);
for (int y = 0; y < height; ++y)
{
for (int x = 0; x < width; ++x)
{
pixel = original_image.GetPixel(x, y);
bitmap_colour.SetPixel(x, y, Color.FromArgb(0, 0, pixel.B));
}
} g.DrawImage(bitmap_colour, r);
}
private void pseudocolorToolStripMenuItem_Click(object sender, System.EventArgs e)
{
checkImageOpen();
btnRed.Visible = true;
btnGreen.Visible = true;
btnBlue.Visible = true;
Graphics g = this.CreateGraphics();
int width = original_image.Width;
int height = original_image.Height;
Rectangle r = new Rectangle(535, 50, original_image.Width, original_image.Height);
Rectangle r2 = new Rectangle(0, 0, original_image.Width, original_image.Height);
Rectangle r3 = new Rectangle(10, 50, original_image.Width, original_image.Height);
g.DrawImage(original_image, r3);
}
}
}
if (save.ShowDialog() == DialogResult.OK)
{
proc_image.Save(save.FileName);
}
Can't save some thing as a directory, and even if you could you wouldn't want to use the initial directory..