Pro Android Graphics - Wallace Jackson.pdf

所需积分/C币:10 2014-06-15 09:31:18 54.82MB PDF
收藏 收藏

對於Android Graphics方面的概念與技術有由淺入深的介紹.
Contents at a Glance About the author About the technical reviewer mmmm xix Acknowledgments uauuuuuXX Chapter 1: Android Digital Imaging: Formats, Concepts, and optimization m 1 Chapter 2: Android Digital video: Formats, Concepts, and optimization. ■■■■■■■■■■■■■■■■■■■■■■■■■ 25 Chapter 3: Android Frame Animation: XML, concepts, and optimization mmmmamm 69 Chapter 4: Android procedural Animation: XML, concepts, and optimization mamn 95 Chapter 5 Android DIP: Device-Independent Pixel Graphics Design ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 121 Chapter 6: Android UI Layouts: Graphics Design Using the view Group class am 147 Chapter 7: Android UI Widgets: Graphics Design Using the view class at ■■■■■■■■■■■■■■■■国■■■ 183 Chapter 8: Advanced Imageview: More Graphics Design Using ImageViewaaammamm 229 Chapter 9: Advanced ImageButton: creating a Custom Multi-State Image Button mmm 255 Chapter 10: Using 9-Patch Imaging Techniques to Create Scalable Imaging Elements. 283 Chapter 11: Advanced Image Blending: Using Android Porterduff Classes am. ■■■■■■■■■■■■■■ 307 Chapter 12: Advanced Image compositing: Using the layerDrawable class man 333 Chapter 13: Digital Image Transitions: Using the Transition Drawable class.mam 361 Contents at a glance Chapter 14: Frame-Based Animation: Using the Animation Drawable class.ammamnnaan 385 Chapter 15: Procedural Animation: Using the Animation Classes 411 Chapter 16: Advanced Graphics: Mastering the Drawable class mmmmamann 439 Chapter 17: Interactive Drawing: Using Paint and canvas classes Interactively mmmm 479 Chapter 18: Playing Captive Video Using the Videoview and Media Player Classes.m 515 Chapter 19: Streaming Digital video from an External Media Server. 545 Index mmm579 Chapter Android Digital Imaging: Formats, Concepts and optimization In this first chapter, you will see how digital imaging is implemented inside of the Android operating system. We will take a look at the digital image formats that are supported in Android, the classes that allow imagery to be formatted on the screen, and the basic digital imaging concepts that you will need to understand to follow what we will be doing in Android graphics design We will also take a look at how to optimize your digital image assets for Android application development. We'll explore digital image optimization both from an individual image asset data footprint standpoint and from an android device type market coverage standpoint As you know, Android devices are no longer just smartphones, but run the gamut from watches to phones to tablets to game consoles to 4K iTV sets. The significance of this to the graphic design aspect of Android application development is that you must now create your digital image assets in a far wider range of pixels, from as low a resolution as 240 pixels to as high a resolution as 4096 pixels, and you must do this for each of your digital imaging assets We will look at the facilities that Android has in place for doing this as a part of your application development workflow and your asset referencing XML(eXtensible Markup Language)markup Markup is different from Java code in that it uses"tags"much as HTML (Hyper Text Markup Language) does. XML is very similar to HTML in that it uses these tag structures, but different in that it is customizable, which is why google has selected it for use in Android Os Since this is a Pro level book I assume that you have a decent level of experience with developing for the android platform, and have already been through the learning process in an Android educational title such as my Learn Android App Development(Apress, 2013) et's get started by taking a look at what image formats Android supports CHAPTER 1: Android Digital Imaging: Formats, Concepts, and optimization Android's Digital Image Formats: Lossless versus Lossy Android supports several popular digital imagery formats, some which have been around for decades, such as the Compuserve giF (Graphic Information Format)and the Joint Photographic Experts Group(JPEG) format, and some are more recent, such as the Png (Portable Network Graphics) and WebP(developed by oN2 and acquired and made open source by Google will talk about these in their order of origin, from the oldest (and thus least desirable)giF through the newest (and thus most advanced)WebP format. Compuserve GiF is fully supported by the Android OS, but is not recommended. GlF is a lossless digital image file format, as it does not throw away image data to achieve better compression results This is because the glF compression algorithm is not as refined(read: powerful)as PNG, and it only supports indexed color, which you will be learning about in detail in this chapter. That said, if all your image assets are already created and in glF format, you will be able to use them with no problem (other than the mediocre resulting quality) in your Android applications The next oldest digital image file format that Android supports is JPEG, which uses a truecolor color depth instead of an indexed color depth We will be covering color theory and color depth soon JPEG is said to be a lossy digital image file format, as it throws away(loses)image data in order to achieve smaller file sizes. It is important to note that this original image data is unrecoverable after compression has taken place, so make sure to save an original uncompressed image file If you zoom into a JPEG image after compression, you will see a discolored area effect that clearly was not present in the original imagery. These degraded areas in the image data are termed compression artifacts in the digital imaging industry and will only occur in lossy image compression The most recommended image format in Android is called the PNG (Portable Network Graphic file format png has both an indexed color version called png8 and a truecolor version called PNG24. The PNG& and pNG2 4 extensions represent the bit depth of color support, which we will be getting into in a little bit PNG is pronounced"ping"in the digital image industry PNG is the recommended format to use for android because it has decent compression and because it is lossless, and thus has both high image quality and a reasonable level of compression efficiency The most recent image format was added to Android when Google acquired oN2 and is called the WebP image format. The format is supported under Android 2.3.7 for image read, or playback, support and in Android 4.0 or later for image write, or file saving, support WebP is a static(image) version of the WebM video file format, also known in the industry as the VP8 codec. You will be learning all about codecs and compression in a later section Android view and view Group classes: Image Containers Everything in this section is just a review of Android Java class concepts and constructs, which you, as an intermediate level Android programmer, probably understand already Android os has a class that is dedicated to displaying digital imagery and digital video called the view class The view class is subclassed directly from the java. lang Object class; it is designed to hold CHAPTER 1: Android Digital Imaging: Formats, Concepts, and optimization imagery and video, and to format it for display within your user interface screen designs. If you wish to review what the View class can do, visit the following URL http://developer.androidcom/reference/android/view/view.html All user interface elements are based on (subclassed from) the View class, and are called widgets and have their own package called android. widget, as most developers know. If you are not that familiar with Views and Widgets, you might consider going through the Learn Android App Development book before embarking on this one. If you wish to review what android widgets can do, visit the following URL http://developer.androidcom/reference/android/widget/package-summary.html The view Group class is also subclassed from the view class. it is used to provide developers with the user interface element container that they can use to design their screen layout and organize their user interface widget View objects. If you wish to review the various types of Android View Group Screen Layout Container classes, visit the following URL http://developer.androidcom/reference/android/view/viewgroup.html Views, View Groups and widgets in Android are usually defined using XML. This is set up this way so that designers can work right alongside the coders in the application development, as XML is far easier to code in than java is In fact, XML isn't really programming code at all; it's markup, and, just like HTML5, it uses tags, nested tags, and tag parameters to build constructs that are later used in your Android application Not only is XML utilized in Android to create user interface screen design but also menu structures string constants, and to define your application version, components, and permissions inside the Androidmanifest. xml file The process of turning your XML data structures into Java-code-compatible objects that can be used with your Android application Java components is called inflating XML markup and android has a number of inflater classes that perform this function, usually in component startup methods, such as the on Created method. You will see this in some detail throughout the Java coding examples in this book, as it bridges our XML markup and Java code The Foundation of Digital Images: Pixels and Aspect Ratio Digital images are made up of tWo-dimensional arrays of pixels, which is short for picture(pix) elements(els). The number of pixels in an image is expressed by its resolution, which is the number of pixels in both the height (H)and Width(W) dimensions To find the number of pixels in an image, simply multiply the Width pixels by the height pixels. For pixels. Two million pixels could also be referred to as two megapire r slightly more than 2 million instance, an HDTV 1920 X 1080 image will contain 2, 073, 600 pixels The more pixels that are in an image, the higher its resolution; just like with digital cameras, the more megapixels are in the data bank, the higher the quality level that can be achieved. Android supports everything from low resolution 320 x 240 pixel display screens(Android Watches and CHAPTER 1: Android Digital Imaging: Formats, Concepts, and optimization smaller flip-phones to medium resolution 854 x 480 pixel display screens(mini-tablets and smartphones), up to high resolution 1280 x 720 pixel display screens (HD smartphones and mid-level tablets), and extra high resolution 1920 X 1080 pixel display screens(large tablets and iTV sets Android 4.3 adds support for 4K resolution iTVs, which feature 4096 by 2160 resolution A slightly more complicated aspect (no pun intended) of image resolution is the image aspect ratio a concept that also applies to display screens. This is the ratio of width to height, or W: H, and will define how square or rectangular (popularly termed widescreen) an image or a display screen is A 1: 1 aspect ratio display (or image) is perfectly square, as is a 2: 2 or a 3: 3 aspect ratio image You see, it is the ratio between the two numbers that defines the shape of the image or screen not the numbers themselves. An example of an android device that has a 1: 1 square aspect ratio would be an android smartWatch Most Android screens are hdtv aspect ratio, which is 16: 9 but some are a little less wide as in 16: 10 (or 8: 5 if you prefer). Wider screens will also surely appear, so look for 16: 8 (or 2: 1, if you prefer)ultra-Wide screens that have a 2160 by 1080 resolution LCD or LED display The aspect ratio is usually expressed as the smallest pair of numbers that can be achieved(reached on either side of the aspect ratio colon. If you paid attention in high school when you were learning about lowest common denominators then this aspect ratio should be fairly easy to calculate usually do this by continuing to divide each side by two. So, taking the fairly odd-ball 1280 X 1024 SXGA resolution as an example, half of 1280x 1024 is 640 x 512, and half of that is 320 X 256, half of that is 160x 128, half of that is 80x 64 half of that is 40x 32 half of that is 20x16. half of that is 10X 8, and half of that is 5 X 4, so an SXGA screen is a 5: 4 aspect ratio Original Pc screens primarily offered a 4: 3 aspect ratio; early crt tube TVs were nearly square, featuring a 3: 2 aspect ratio. The current market trend is certainly towards wider screens and higher resolution displays; however, the new Android Watches may change that back towards square aspect ratIos The color of Digital Images: Color Theory and color Deptl Now you know about digital image pixels and how they are arranged into 2D rectangular arrays at a specific aspect ratio defining the rectangular shape. So the next logical aspect (again, no pun intended) to look into is how each of those pixels gain their color values Color values for image pixels are defined by the amount of three different colors, red green and blue(RGB, which are present in varying amounts in each pixel Android display screens utilize additive color, which is where the wavelengths of light for each RGB color plane are summed together in order to create millions of different color values Additive color, which is utilized in LCD or LED displays, is the opposite of subtractive color, which is utilized in print. To show the difference, under a subtractive color model, mixing red with green(inks will yield a purplish color, whereas in an additive color model, mixing red with green (light) creates a bright yellow color result There are 256 levels of each RGB color for each pixel, or 8-bits of color intensity variation, for each of these red, green, and blue values, from a minimum of zero ( off, no color contributed) to a maximum of 255 (fully on, maximum color contributed). The number of bits used to represent color in a digital image is referred to as the color depth of that image CHAPTER 1: Android Digital Imaging: Formats, Concepts, and optimization There are several common color depths used in the digital imaging industry, and I will outline the most common ones here along with their formats. The lowest color depth exists in an 8-bit indexed color image, which has 256 color values, and uses the giF and PNG8 image formats to contain this indexed color type of digital image data A medium color depth image features a 16-bit color depth and thus contains 65, 536 colors (calculated as 256 X 256); it is supported in the TARGA TGA) and Tagged Image File Format tiFF) digital image formats Note that Android does not support any of the 16-bit color depth digital image file formats (TGa or TIFF), Which I think is an omission, as 16-bit color depth support would greatly enhance a developer image data footprint optimization, a subject which we will be covering later on in the chapter a high color depth image features a 24-bit color depth and thus contains over 16 million colors This is calculated as 256 x 256 x 256 and equals 16,777,216 colors. File formats supporting 24-bit color include JPEG(or JPG), PNG, TGA, TIFF and WebP. Using 24-bit color depth will give you the highest quality level, which is why Android prefers the use of a PNG24 or a JPEG image file format. Since PNG2 4 is lossless, it has the highest quality compression(lowest original data loss)along with the highest quality color depth, and So PNG24 is the preferred digital image format to use, as it produces the highest quality Representing Colors in Android: Hexadecimal Notation So now that you know what color depth is, and that color is represented as a combination of three different red, green, and blue color channels within any given image, we need to look at how we are to represent these three rgb color channel values It is also important to note that in Android, color is not only used in 2D digital imagery, also called bitmap imagery, but also in 2D illustrations, commonly known as vector imagery, as well as in color settings, such as the background color for a user interface screen or text color In Android, different levels of rgb color intensity values are represented using hexadecimal notation, the Base 16 computer notation invented decades ago to represent 16 bits of data value Unlike Base 10, which counts from zero through 9, Base 16 counts from zero through F, where F represents a base 10 value of 1 5 (or if you are a programmer you could count from 0-15, which also gives 16 decimal data values, either way you prefer to look at it). See Table 1-1 for some examples Table 1-1. Hexadecimal values and Corresponding Decimal values Hexadecimal 0 1 2 3 4 5 6 7 9Ab C DEF Values Decimal 56789101112131415 Values CHAPTER 1: Android Digital Imaging: Formats, Concepts, and optimization a hexadecimal value in android always starts with a pound sign, like this: FFFFFF. This hexadecimal data color value represents a color of white as each slot in this 24-bit hexadecimal representation represents one Base 16 value, to get the 256 values you need for each RGB color will take 2 slots, as 16x 16 equals 256. Thus for a 24-bit image you need six slots after the pound sign to hold each of the six hexadecimal data values The hexadecimal data slots represent the rgb values in a following format: #RRGGBB. So, for the color white, all red, green, and blue channels in this hexadecimal color data value representation are at the maximum luminosity If you additively sum all of these colors together you' ll get white light. As mentioned, the color yellow is represented by the red and green channels being on and the blue channel being off, so the hexadecimal representation is FFFFoo, where both red and green channel slots are on( FF or 255) and blue channel slots are fully off (00 or a zero value It is important to note here that there is also a 32-bit image color depth whose data values are represented using an ARGB color channel model, where the A stands for alpha, which is short for alpha channel. I will be going over the concept of alpha and alpha channels, as well as pixel blending, in great detail in the next section of this chapter. The hexadecimal data slots for an ARGB value hold data in the following format: #AARRGGBB So for the color white, all alpha, red, green, and blue channels in this hexadecimal color data value representation are at a maximum luminosity (or opacity), and the alpha channel is fully opaque as represented by an ff value, so its hexadecimal value is FFFFFFFF A 100% transparent alpha channel is represented by setting the alpha slots to zero thus, a fully transparent image pixel is #OOFFFFFF, or #00000000. If an alpha channel is transparent, color value doesnt matter Image Compositing: Alpha Channels and Blending Modes In this section we will take a look at compositing digital images. This is the process of blending together more than one layer of a digital image in order to obtain a resulting image on the display that appears as though it is one final image, but which in fact is actually a collection of more than one seamlessly composited image layers To accomplish this, we need to have an alpha channel (transparency) value that we can utilize to precisely control the blending of that pixel with the pixel (in that same location)on the other layers above and below it Like the other RGB channels, the alpha channel also has 256 levels of transparency as represented by two slots in the hexadecimal representation for the argB data value, which has eight slots (32-bits)of data rather than the six slots used in a 24-bit image, which can be thought of as a 32-bit image with no alpha channel data Indeed, if there's no alpha channel data, why waste another 8 bits of data storage even if it's filled with F's( or fully opaque pixel values, which essentially equate to unused alpha transparency values). So a 24-bit image has no alpha channel and is not going to be used for compositing for instance the bottom plate in a compositing layer stack, whereas a 32-bit image is going to be used as a compositing layer on top of something else that will need the ability to show through (via transparency values) in some of the pixel locations in the image composite

试读 127P Pro Android Graphics - Wallace Jackson.pdf
立即下载 低至0.43元/次 身份认证VIP会员低至7折
eastpoplar 可以用,谢谢!
Cc养鱼人 看书就要看原版,现在国内翻译真实越来越差劲了
howkyo0 没什么价值的书
你好明天_2016 这个相当不错呢,就是原版太难看懂了
meiyouyisi 不错的资源,适合初学者参考。
阿卡明 对于入门参考还可以吧。
u013164293 经济实惠的资料,值得下载
rionaldo 书还可以,不过讲的太浅了 没啥深入的内容
taotaopianyi001 书不错,可以打开,无需密码
wgzhou 讲的是android图形开发相关的,值得一看
关注 私信 TA的资源
Pro Android Graphics - Wallace Jackson.pdf 10积分/C币 立即下载
Pro Android Graphics - Wallace Jackson.pdf第1页
Pro Android Graphics - Wallace Jackson.pdf第2页
Pro Android Graphics - Wallace Jackson.pdf第3页
Pro Android Graphics - Wallace Jackson.pdf第4页
Pro Android Graphics - Wallace Jackson.pdf第5页
Pro Android Graphics - Wallace Jackson.pdf第6页
Pro Android Graphics - Wallace Jackson.pdf第7页
Pro Android Graphics - Wallace Jackson.pdf第8页
Pro Android Graphics - Wallace Jackson.pdf第9页
Pro Android Graphics - Wallace Jackson.pdf第10页
Pro Android Graphics - Wallace Jackson.pdf第11页
Pro Android Graphics - Wallace Jackson.pdf第12页
Pro Android Graphics - Wallace Jackson.pdf第13页
Pro Android Graphics - Wallace Jackson.pdf第14页
Pro Android Graphics - Wallace Jackson.pdf第15页
Pro Android Graphics - Wallace Jackson.pdf第16页
Pro Android Graphics - Wallace Jackson.pdf第17页
Pro Android Graphics - Wallace Jackson.pdf第18页
Pro Android Graphics - Wallace Jackson.pdf第19页
Pro Android Graphics - Wallace Jackson.pdf第20页

试读结束, 可继续阅读

10积分/C币 立即下载 >