Your SlideShare is downloading. ×
  • Like
Color filters for the dummies
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Color filters for the dummies

  • 1,906 views
Published

 

Published in Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
1,906
On SlideShare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
6
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. ColorFilters For The Dummies CodeAndroid Leong Hean Hong 31th Oct 2009 (CC) BY
  • 2. Overview1. What is bitmap?2. What is a ColorFilter?3. ColorMatrixColorFilter4. LightingColorFilter5. PorterDuffColorFilter
  • 3. What is Bitmap?● A 2 dimensional array of pixels● Pixel consists of components (A, R, G, B)● Each component can be described by an integer [0 to 255]● Hexadecimal form: 0xAARRGGBB ○ Some libraries from some fruit company may use floating value [0.0 ~ 1.0]● Example ○ (1, 255, 0, 0) - Opaque red color ○ (1, 123, 123, 123) - Opaque grey color ○ (1, 0, 0, 0) - Oaque balck color ○ (128, 0, 255, 255) - 50% transparent yellow color
  • 4. What is ColorFilter● Change colors in a bitmap by ○ applying mathematical operations (e.g. +, -, *, /, modulo, AND, OR, NOT, XOR, ...) on ■ color/alpha components of bitmap
  • 5. ColorMatrixColorFilter● Apply mathematical operations by multiplying a 4x5 matrix
  • 6. LightingColorFilter● LightingColorFilter(int mul, int add)● Multiply RGB components by 1 color, follow by addition of another color● No change to alpha component● Resultant value of each component will be pinned to [0, 255]● Value range from 0x000000 to 0xffffff● Examples ○ LightingColorFilter(0xff0000, 0x0000ff) = times red plus blue ○ LightingColorFilter(0x00ff00, 0xff0000) = times green plus red
  • 7. PorterDuffColorFilter● Mathematical operation on 2 bitmaps (source & destination)● Android defines 16 types of operation (android.graphics. PorterDuff.Mode)● Sample code available in ApiDemos (<sdk_folder>/samples/ApiDemos) com.example.android. apis.graphics/Xfermodes.java
  • 8. Q&A