Working with Images
| Visual C# Tutorials |
| C# Tutorials |
|
Working with Images |
| © 2006 Packt Publishing |
| This tutorial—Working with Images—is from GDI+ Custom Controls with Visual C# 2005, by Tiberiu Radu, Iulian Serban, Dragos Brezoi, Adam Ward. Copyright © 2006 Packt Publishing. All rights reserved. This article is reproduced by permission. This tutorial has been edited especially for C# Online.NET. Read the book review! |
|
Working with Images
Ever since Graphical User Interfaces (GUIs) were invented, developers have been keen to use images to make their programs easier to use, and more attractive and intuitive to their users. Images brighten up an otherwise boring and clinical computer screen, and make the general computing experience more enjoyable.
Visual support facilitates the information absorption and presentation of up-to-date information. Any user can more easily understand information just by looking at a picture. Images are the most intuitive memories because the human mind in most cases has a visual memory. This means that when you recall a memory it is frequently a visual one. Think briefly of a tree. What comes to your mind first? Is it the roughness of bark, the taste of fruit or nuts, the smell of tree, the rustle of leaves—or is it a picture of a tree?
Have you ever wondered what it was like before the GUI? There were just text-mode applications. The GUI tried and succeeded in emulating different features of reality. Today, computers can easily reproduce the image and the sound of a tree and in the years to come they will become increasingly better at it.
As regards to the custom controls, these can be user-friendly, if you do the job the right way. It is up to you to develop a custom control that has a good-looking interface. The rendering can be done using drawing lines and curves, using brushes and text; but sometimes it can be improved using images. For example, the Save button in a common application has a floppy disk picture associated, loaded from an image file.
In this chapter, we will discuss how .NET deals with images, and how it can be used to improve your software. We'll visit the Image, Bitmap, and Graphics objects and create a powerful component that you can include in your own programs. You'll learn how to create a picture from scratch without any user intervention, and you'll see some of the cool capabilities of GDI+ in action. Most of the examples take the form of short code snippets, although we will look at creating a small but powerful component that will fast-track you towards some of the more detailed image effects that .NET has to offer.
For the rest of this chapter, you will:
- Learn about the basic .NET classes that deal with images: Image and Bitmap
- Display images
- Apply various effects on images
- Use images to build better-looking custom controls
As usual, at the end of the chapter you'll build a full custom control where you'll apply the new theory. Let's get started.
|


