Класс Bitmap - Требуется определение типа или пространства имен, либо признак конца - C#
Формулировка задачи:
использую пример с офсайта https://msdn.microsoft.com/ru-ru/lib...v=vs.110).aspx но выбрасывает ошибку ... вставлял код используя консольное приложение подскажите пожалуйста что я делаю не так?
Решение задачи: «Класс Bitmap - Требуется определение типа или пространства имен, либо признак конца»
textual
Листинг программы
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication15
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
try
{
// Retrieve the image.
image1 = new Bitmap(@"C:\1.bmp", true);
int x, y;
// Loop through the images pixels to reset color.
for(x=0; x<image1.Width; x++)
{
for(y=0; y<image1.Height; y++)
{
Color pixelColor = image1.GetPixel(x, y);
Color newColor = Color.FromArgb(pixelColor.R, 0, 0);
image1.SetPixel(x, y, newColor);
}
}
// Set the PictureBox to display the image.
PictureBox1.Image = image1;
// Display the pixel format in Label1.
Label1.Text = "Pixel format: "+image1.PixelFormat.ToString();
}
catch(ArgumentException)
{
MessageBox.Show("There was an error." +
"Check the path to the image file.");
}
}