You can find lots of goodies for working with graphics such as bitmaps (including NinePatch) in the android.graphics package. The core class for bitmaps is android.graphics.Bitmap.
Drawing Bitmap Graphics on a Canvas
You can draw bitmaps onto a valid Canvas, such as within the onDraw() method of a View, using one of the drawBitmap() methods. For example, the following code loads a Bitmap resource and draws it on a canvas:
Scaling Bitmap Graphics
Perhaps you want to scale your graphic to a smaller size. In this case, you can use the createScaledBitmap() method, like this:
You can preserve the aspect ratio of the Bitmap by checking the getWidth() and getHeight() methods and scaling appropriately.
Transforming Bitmaps Using Matrixes
You can use the helpful Matrix class to perform transformations on a Bitmap graphic. Use the Matrix class to perform tasks such as mirroring and rotating graphics, among other actions.
The following code uses the createBitmap() method to generate a new Bitmap that is a mirror of an existing Bitmap called pic:
You can perform a 30-degree rotation in addition to mirroring by using this Matrix instead:
You can see the results of different combinations of tilt and mirror Matrix transforms in Figure. When you’re no longer using a Bitmap, you can free its memory using the recycle() method:
A single-source bitmap: scaled, tilted, and mirrored using Android Bitmap classes.
There are a variety of other Bitmap effects and utilities available as part of the Android SDK, but they are numerous and beyond the scope of this book. See the android.graphics package for more details.
Setting Up Your Android Development Environment
Writing Your First Android Application
Understanding The Anatomy Of An Android Application
Defining Your Application Using The Android Manifest File
Managing Application Resources
Exploring User Interface Screen Elements
Designing User Interfaces With Layouts
Drawing And Working With Animation
Using Android Data And Storage Apis
Sharing Data Between Applications With Content Providers
Using Android Networking Apis
Using Android Web Apis
Using Location-based Services (lbs) Apis
Using Android Multimedia Apis
Using Android Telephony Apis
Using Android 3d Graphics With Opengl Es
Using The Android Ndk
Using Android’s Optional Hardware Apis
Working With Notifications
Working With Services
Extending Android Application Reach
Managing User Accounts And Synchronizing User Data
Handling Advanced User Input
Targeting Different Device Configurations And Languages
The Mobile Software Development Process
Designing And Developing Bulletproof Android Applications
Testing Android Applications
Selling Your Android Application
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.