Presentation is loading. Please wait.

Presentation is loading. Please wait.

Resources & Bitmaps Adding clip art to your application.

Similar presentations


Presentation on theme: "Resources & Bitmaps Adding clip art to your application."— Presentation transcript:

1 Resources & Bitmaps Adding clip art to your application

2 Overview Two approaches to getting a nice look to you program Drawing Use bitmap images, attached to PictureBox objects Drawing required for some applications (e.g., mapping software), bitmaps suffice otherwise Bitmaps can be accessed in two ways Compiled into program resources Loaded from files

3 Drawing Basic Procedure Get a graphic device attached to the client region (a Graphic object) Use the many drawing tools associated with it Dispose() it when you are done Best place to draw is usually the Paint event

4 Example Drawing Comments: Draws a rectangle with a blue brush Draws an ellipse with a red brush Writes a string with a black brush

5 Screen capture 1.Creates a graphics device tied to the form 2.Creates an empty Bitmap with the same characteristics (e.g., pixel size) as our form graphics device, then creates a graphics device tied to the bitmap, allowing us to draw on it 3.Performs a screen capture from the upper-left corner of the client to the bitmap device we created

6 Resources Provides a means of binding key objects into programs Text Images Can be identified and customized, with little risk to code, as circumstances change e.g, Internationalization of text Many companies require all text/images in programs be bound into resources Resources don’t require extra files in setup

7 Creating Resource File

8 Resource Editor

9 Accessing Resources in Program To access resources: Use ResourceFileName as if it were a namespace or class Typecast it to Bitmap, if that’s what it is

10 Loading Bitmaps from Files Comments: Bitmap constructor overload allows file name to be specified To copy a Bitmap, use the Clone() method To attach to PictureBox, use Image property

11 Transparency Comments: One bitmap color can be made transparent Use a pixel in the background region (1,1 was chosen here, knowing the fish) “Transparent” for a control means form background “shows through”, as shown in example above. Controls underneath it are obscured.

12 Parting words… Putting bitmaps in resource files makes them much more convenient Consider it for text as well—it will make programs much easier to globalize Using bitmaps allows quite a bit of interest in the interface Performance problems do arise with a lot of drawing Graphics-intensive applications tend to bypass Windows, writing directly to video memory, using standards like DirectX


Download ppt "Resources & Bitmaps Adding clip art to your application."

Similar presentations


Ads by Google