demonstrates how to implement an alternative scrolling system using the scrollRect method. in Font

Printing ANSI/AIM Code 128 in Font demonstrates how to implement an alternative scrolling system using the scrollRect method.

8 demonstrates how to implement an alternative scrolling system using the scrollRect method.
Code 128 Drawer In None
Using Barcode creation for Font Control to generate, create Code 128C image in Font applications.
www.OnBarcode.com
Barcode Generator In None
Using Barcode generator for Font Control to generate, create Barcode image in Font applications.
www.OnBarcode.com
The mini-map
Code 3/9 Printer In None
Using Barcode printer for Font Control to generate, create Code 39 image in Font applications.
www.OnBarcode.com
Make PDF 417 In None
Using Barcode creation for Font Control to generate, create PDF417 image in Font applications.
www.OnBarcode.com
At the beginning of this chapter, I mentioned that a bitmap is made up of two parts. The BitmapData object is the raw information that describes the size of the grid and the pixel color of every cell in that grid. The Bitmap object displays that data. I said that the reason for this is to separate the data from the display. It means that we can use the data from one bitmap to create a completely new bitmap using the same data. This feature pays off fabulously in helping to create the GPS mini-map. The map is just a tiny version of the huge 6-megapixel cave bitmap. All we need to do is take the cave s BitmapData and scale it to the desired size. We first need two variables for the map s BitmapData and Bitmap objects: private var _mapBitmapData:BitmapData; private var _mapBitmap:Bitmap;
Encode Barcode In None
Using Barcode creation for Font Control to generate, create Barcode image in Font applications.
www.OnBarcode.com
DataMatrix Generator In None
Using Barcode generation for Font Control to generate, create ECC200 image in Font applications.
www.OnBarcode.com
PIXEL-PERFECT COLLISION AND DESTRUCTIBLE ENVIRONMENTS
Code 128 Code Set B Printer In None
Using Barcode creator for Font Control to generate, create Code128 image in Font applications.
www.OnBarcode.com
Code11 Creation In None
Using Barcode generation for Font Control to generate, create Code 11 image in Font applications.
www.OnBarcode.com
The class constructor then creates these objects by taking the cave s BitmapData and scaling it down to a small size. Here s the code that does that: //1. Determine the scale factor var scaleFactor:Number = 0.04; //2. Determine the map's size based on //the _caveBitmap's full height and width var mapWidth:Number = _caveBitmapData.width * scaleFactor; var mapHeight:Number = _caveBitmapData.height * scaleFactor; //3. Create the map's BitmapData based on the scaled height and width var _mapBitmapData:BitmapData = new BitmapData (mapWidth, mapHeight, false, 0x000000); //4. Create a Matrix to scale the cave's BitmapData to the new size var scaleMatrix:Matrix = new Matrix(); scaleMatrix.scale(scaleFactor, scaleFactor); //5. Use the scaled Matrix along with the _caveBitmapData to //draw the scaled image of the cave into the _mapBitmapData _mapBitmapData.draw(_caveBitmapData, scaleMatrix); //6. Create the map's Bitmap using the new scaled _mapBitmapData _mapBitmap = new Bitmap(_mapBitmapData); I know that you don t like the look of that Matrix object, but you ll soon see that it s not nearly as intimidating as it seems. Let s go through the code. We first have to figure out how big we want the mini-map to be 25 times smaller is a good size. var scaleFactor:Number = 0.04; This value can now be applied to other values to keep the scaling consistent. How big is 25 times smaller in actual pixels Let s work that out: var mapWidth:Number = _caveBitmapData.width * scaleFactor; var mapHeight:Number = _caveBitmapData.height * scaleFactor; The original cave bitmap dimensions are 2816 by 2112 pixels. The map s dimensions are worked out to be 112 by 84 pixels. We next need to make the map s BitmapData. This line of code should be quite familiar to you, as it s how we ve been creating BitmapData objects throughout this chapter. But there are two different values in the arguments, which I ve highlighted here. var _mapBitmapData:BitmapData = new BitmapData (mapWidth, mapHeight, false, 0x000000);
Code 128C Reader In Java
Using Barcode decoder for Java Control to read, scan read, scan image in Java applications.
www.OnBarcode.com
Code 128B Decoder In Visual C#
Using Barcode decoder for VS .NET Control to read, scan read, scan image in .NET framework applications.
www.OnBarcode.com
Those two values are very important: false means that there will be no areas of transparency in the bitmap. 0x000000 means that the bitmap s fill color will be black. Any areas of the bitmap that don t have assigned colors will be filled with black. This gives the mini-map a nice solid, black background, which you can see in Figure 5-15. This is very different from the other bitmaps in this chapter, which were all created with transparent fill areas. It s important to remember that you can create bitmaps with any fill color you like. Up till now, we ve just been using transparent fills because they ve been necessary for collision checking. An object s shape was defined by the transparent pixels that surrounded it.
Draw EAN / UCC - 13 In Objective-C
Using Barcode drawer for iPhone Control to generate, create EAN / UCC - 14 image in iPhone applications.
www.OnBarcode.com
Code 3 Of 9 Scanner In VS .NET
Using Barcode decoder for VS .NET Control to read, scan read, scan image in .NET framework applications.
www.OnBarcode.com
Download from Wow! eBook <www.wowebook.com>
Encoding UPC-A In .NET
Using Barcode generation for ASP.NET Control to generate, create UPC A image in ASP.NET applications.
www.OnBarcode.com
Printing Barcode In Java
Using Barcode encoder for Java Control to generate, create Barcode image in Java applications.
www.OnBarcode.com
Figure 5-16. The map uses a black background fill color. If the map is 25 times smaller than the original bitmap, it will use 25 times fewer pixels. That means that we need to throw out most of the cave bitmap s pixels, but still end up with an image that looks like the original. If you think about it, this is a pretty sophisticated problem. We re compressing each group of 25 pixels into 1 pixel. That single pixel must represent the approximate combined color values of the whole group of 25. To do this, we need to put the cave s bitmap data through a mathematical filter. The filter must churn through all of the original data and squeeze it so that it s very small but contains correct approximations of the original pixel colors.
Recognize Code-128 In Java
Using Barcode recognizer for Java Control to read, scan read, scan image in Java applications.
www.OnBarcode.com
GS1 - 12 Scanner In .NET
Using Barcode recognizer for VS .NET Control to read, scan read, scan image in VS .NET applications.
www.OnBarcode.com
Barcode Creator In .NET
Using Barcode maker for .NET framework Control to generate, create Barcode image in .NET framework applications.
www.OnBarcode.com
Generating EAN13 In None
Using Barcode generation for Excel Control to generate, create GS1 - 13 image in Microsoft Excel applications.
www.OnBarcode.com
QR-Code Encoder In Java
Using Barcode encoder for Java Control to generate, create QR-Code image in Java applications.
www.OnBarcode.com
ANSI/AIM Code 39 Reader In VB.NET
Using Barcode recognizer for .NET Control to read, scan read, scan image in .NET framework applications.
www.OnBarcode.com
Copyright © OnBarcode.com . All rights reserved.