logo search
Учебник_ПОА

Compiling the Code

This example requires:

Robust Programming

The following conditions may cause an exception:

// The two inner loops iterate through

// each pixel in an individual square.

for (int j = columns * colWidth; j < (columns * colWidth) + colWidth; j++)

{

for (int k = rows * rowHeight; k < (rows * rowHeight) + rowHeight; k++)

{

// Set the pixel to the correct color.

checks.SetPixel(j, k, color);

}

}

}

}

pictureBox1.Image=checks;

}

Компиляция кода

Для этого примера необходимы следующие компоненты.

Надежное программирование

Исключение может возникнуть при следующих условиях.

How to: Convert Images from One Format to Another

This example demonstrates loading an image and saving it in several different graphics formats.

Example

class Program

{

static void Main(string[] args)

{

// Load the image.

System.Drawing.Image image1 = System.Drawing.Image.FromFile(@"C:\test.bmp");

// Save the image in JPEG format.

image1.Save(@"C:\test.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);

// Save the image in GIF format.

image1.Save(@"C:\test.gif", System.Drawing.Imaging.ImageFormat.Gif);

// Save the image in PNG format.

image1.Save(@"C:\test.png", System.Drawing.Imaging.ImageFormat.Png);

}

}