= Chapter 13 Notes = Title: '''Bitmaps''' == Summary == So much ado about Bitmaps. '''Twelve programs in all''' === Programming Concepts Summary === || '''Concept''' || '''Page''' || || Image || P. 283 || == Programs == === Program WebBitmapCode === Page 284. Concepts: 1. Shows how to include a bitmap from the web Classes: 1. {{{Image}}} 1. {{{ImageSource}}} === Program WebBitmapXaml === Page 286. Concepts: 1. Shows how to include a bitmap from the web using Xaml Xaml: {{{#!xml }}} === Program ResourceBitmapCode === Page 289 Concepts: 1. Shows how to include a bitmap from an embedded resource (i.e. file) {{{#!csharp public class ResourceBitmapCodePage : ContentPage { public ResourceBitmapCodePage() { Content = new Image { Source = ImageSource.FromResource( "ResourceBitmapCode.Images.ModernUserInterface256.jpg"), VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center }; } } }}} === Program StackedBitmap === Page 291 Concepts: 1. Shows how to include a bitmap from an embedded resource (i.e. file) using XAML and a '''markup extension''' which is ''necessary!'' Here is the markup extension: {{{#!csharp namespace StackedBitmap { [ContentProperty ("Source")] public class ImageResourceExtension : IMarkupExtension { public string Source { get; set; } public object ProvideValue (IServiceProvider serviceProvider) { if (Source == null) return null; return ImageSource.FromResource(Source); } } } }}} and here is the Xaml that uses it: {{{#!xml }}} Note: Windows uses device independent units, but iOS and Android use pixels. "This inconsistency between the Windows Runtime and the other two platforms is actually beneficial when you’re accessing bitmaps from the individual platform projects. As you’ll see, iOS and Android include a feature that lets you supply different sizes of bitmaps for different device resolutions. In effect, this allows you to specify bitmap sizes in device-independent units, which means that Windows devices are consistent with those schemes." p 294. === Program DeviceIndBitmapSize === Page 301 Concepts: 1. Shows how to include a bitmap and size it in dips as opposed to pixels using {{{WidthRequest}}} and {{{HeightRequest}}}. No new Classes. === Program MadTeaParty === Page 303 Concepts: 1. Shows how to use styles to set the {{{WidthRequest}}} property to a value corresponding to 1.5 inches or 240 dips. No new classes. === Program ImageBrowser === Page 303 Concepts: 1. Shows an image browser. Classes: 1. {{{ActivityIndicator}}} === Program BitmapStreams === Page 311 Concepts: 1. Shows how to stream bitmaps. (Note this is similar to the {{{BlackCat}}} program from Chapter 4. === Program DiyGradientBitmap === Page 315 Concepts: 1. Shows how to create Bitmap gradients on the fly. Classes: ... Not as interested in this one. But primarily we are working with a built class called {{{BmpMaker}}}. === Program PlatformBitmaps === Page 315 Concepts: 1. Shows how to use different bitmaps for different platforms. 1. Talks about where the different images are stored in the different platforms. Classes: 1. uses {{{Device.OnPlatform}}} === Program ImageTap === Page 315 Concepts: 1. Shows how to use {{{GestureReconizer}}} for tap events Classes: 1. uses {{{Device.OnPlatform}}} 1. uses {{{GestureRecognizer}}} for tap events. === Program ToolbarDemo === Page 329 Concepts: 1. Shows how to create a toolbar and to assign image icons to it. Classes: 1. uses {{{Device.OnPlatform}}} === Program ButtonImages === Page 315 Concepts: 1. Shows how to add a small image onto a button (not a replacement for text see: {{{ImageTap}}} earlier in this chapter. Classes: 1. uses {{{Label}}}