SlideShare a Scribd company logo
1 of 8
Download to read offline
ColorFilters For The Dummies

          CodeAndroid
        Leong Hean Hong
          31th Oct 2009
            (CC) BY
Overview

1. What is bitmap?
2. What is a ColorFilter?
3. ColorMatrixColorFilter
4. LightingColorFilter
5. PorterDuffColorFilter
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
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
ColorMatrixColorFilter

● Apply mathematical operations by multiplying a 4x5 matrix
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
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
Q&A

More Related Content

What's hot

Transportation+method
Transportation+methodTransportation+method
Transportation+method
videoaakash15
 
optimal subsampling
optimal subsamplingoptimal subsampling
optimal subsampling
Tian Tian
 

What's hot (19)

Paper Summary of Infogan-CR : Disentangling Generative Adversarial Networks w...
Paper Summary of Infogan-CR : Disentangling Generative Adversarial Networks w...Paper Summary of Infogan-CR : Disentangling Generative Adversarial Networks w...
Paper Summary of Infogan-CR : Disentangling Generative Adversarial Networks w...
 
Transportation+method
Transportation+methodTransportation+method
Transportation+method
 
V -linear_programming
V  -linear_programmingV  -linear_programming
V -linear_programming
 
Prom
PromProm
Prom
 
Break even point
Break even pointBreak even point
Break even point
 
4-CONNECTED AND 8-CONNECTED NEIGHBOR SELECTION By Sintiak Haque
4-CONNECTED AND 8-CONNECTED NEIGHBOR SELECTION  By Sintiak Haque4-CONNECTED AND 8-CONNECTED NEIGHBOR SELECTION  By Sintiak Haque
4-CONNECTED AND 8-CONNECTED NEIGHBOR SELECTION By Sintiak Haque
 
Linear Programming
Linear ProgrammingLinear Programming
Linear Programming
 
Analysis and Modelling of CMOS Gm-C Filters through Machine Learning
Analysis and Modelling of CMOS Gm-C Filters through Machine LearningAnalysis and Modelling of CMOS Gm-C Filters through Machine Learning
Analysis and Modelling of CMOS Gm-C Filters through Machine Learning
 
13_linear_factors.pdf
13_linear_factors.pdf13_linear_factors.pdf
13_linear_factors.pdf
 
Effective management of high volume numeric data with histograms
Effective management of high volume numeric data with histogramsEffective management of high volume numeric data with histograms
Effective management of high volume numeric data with histograms
 
Image processing
Image processingImage processing
Image processing
 
M C6java4
M C6java4M C6java4
M C6java4
 
Arrays in c++
Arrays in c++Arrays in c++
Arrays in c++
 
optimal subsampling
optimal subsamplingoptimal subsampling
optimal subsampling
 
Continuously Adaptive Mean Shift(CAMSHIFT)
Continuously Adaptive Mean Shift(CAMSHIFT)Continuously Adaptive Mean Shift(CAMSHIFT)
Continuously Adaptive Mean Shift(CAMSHIFT)
 
20181204i mlse discussions
20181204i mlse discussions20181204i mlse discussions
20181204i mlse discussions
 
Activity selection problem
Activity selection problemActivity selection problem
Activity selection problem
 
Break even point
Break even pointBreak even point
Break even point
 
Constrained Optimization
Constrained OptimizationConstrained Optimization
Constrained Optimization
 

Similar to Color filters for the dummies

ENG 202 – Digital Electronics 1 - Chapter 4 (1).pptx
ENG 202 – Digital Electronics 1 - Chapter 4 (1).pptxENG 202 – Digital Electronics 1 - Chapter 4 (1).pptx
ENG 202 – Digital Electronics 1 - Chapter 4 (1).pptx
Aishah928448
 
Verilog Final Probe'22.pptx
Verilog Final Probe'22.pptxVerilog Final Probe'22.pptx
Verilog Final Probe'22.pptx
SyedAzim6
 

Similar to Color filters for the dummies (20)

Lecture 2-2023.pdf
Lecture 2-2023.pdfLecture 2-2023.pdf
Lecture 2-2023.pdf
 
Lecture 2-2023.pdf
Lecture 2-2023.pdfLecture 2-2023.pdf
Lecture 2-2023.pdf
 
Gsp 215 Future Our Mission/newtonhelp.com
Gsp 215 Future Our Mission/newtonhelp.comGsp 215 Future Our Mission/newtonhelp.com
Gsp 215 Future Our Mission/newtonhelp.com
 
GSP 215 Doing by learn/newtonhelp.com
GSP 215 Doing by learn/newtonhelp.comGSP 215 Doing by learn/newtonhelp.com
GSP 215 Doing by learn/newtonhelp.com
 
GSP 215 Become Exceptional/newtonhelp.com
GSP 215 Become Exceptional/newtonhelp.comGSP 215 Become Exceptional/newtonhelp.com
GSP 215 Become Exceptional/newtonhelp.com
 
GSP 215 Perfect Education/newtonhelp.com
GSP 215 Perfect Education/newtonhelp.comGSP 215 Perfect Education/newtonhelp.com
GSP 215 Perfect Education/newtonhelp.com
 
Auto Tuning
Auto TuningAuto Tuning
Auto Tuning
 
ENG 202 – Digital Electronics 1 - Chapter 4 (1).pptx
ENG 202 – Digital Electronics 1 - Chapter 4 (1).pptxENG 202 – Digital Electronics 1 - Chapter 4 (1).pptx
ENG 202 – Digital Electronics 1 - Chapter 4 (1).pptx
 
GSP 215 Effective Communication - tutorialrank.com
GSP 215  Effective Communication - tutorialrank.comGSP 215  Effective Communication - tutorialrank.com
GSP 215 Effective Communication - tutorialrank.com
 
MULTIPLEXER_DICA UNIT III-III.pptx
MULTIPLEXER_DICA UNIT III-III.pptxMULTIPLEXER_DICA UNIT III-III.pptx
MULTIPLEXER_DICA UNIT III-III.pptx
 
Multimedia graphics and image data representation
Multimedia graphics and image data representationMultimedia graphics and image data representation
Multimedia graphics and image data representation
 
GSP 215 Enhance teaching/tutorialrank.com
 GSP 215 Enhance teaching/tutorialrank.com GSP 215 Enhance teaching/tutorialrank.com
GSP 215 Enhance teaching/tutorialrank.com
 
GSP 215 Inspiring Innovation/tutorialrank.com
GSP 215 Inspiring Innovation/tutorialrank.comGSP 215 Inspiring Innovation/tutorialrank.com
GSP 215 Inspiring Innovation/tutorialrank.com
 
Verilog Final Probe'22.pptx
Verilog Final Probe'22.pptxVerilog Final Probe'22.pptx
Verilog Final Probe'22.pptx
 
Chapter02 graphics-programming
Chapter02 graphics-programmingChapter02 graphics-programming
Chapter02 graphics-programming
 
GSP 215 Entire Course NEW
GSP 215 Entire Course NEWGSP 215 Entire Course NEW
GSP 215 Entire Course NEW
 
Python lecture 12
Python lecture 12Python lecture 12
Python lecture 12
 
VA1160 Class 05
VA1160 Class 05VA1160 Class 05
VA1160 Class 05
 
Gsp 215 Effective Communication / snaptutorial.com
Gsp 215  Effective Communication / snaptutorial.comGsp 215  Effective Communication / snaptutorial.com
Gsp 215 Effective Communication / snaptutorial.com
 
Data efficiency on BEAM - Choose the right data representation by Dmytro Lyto...
Data efficiency on BEAM - Choose the right data representation by Dmytro Lyto...Data efficiency on BEAM - Choose the right data representation by Dmytro Lyto...
Data efficiency on BEAM - Choose the right data representation by Dmytro Lyto...
 

More from Hean Hong Leong

PHP_Frameworks_Discussion
PHP_Frameworks_DiscussionPHP_Frameworks_Discussion
PHP_Frameworks_Discussion
Hean Hong Leong
 

More from Hean Hong Leong (19)

Telegram Bot
Telegram BotTelegram Bot
Telegram Bot
 
How To Work With UI/UX Designer
How To Work With UI/UX DesignerHow To Work With UI/UX Designer
How To Work With UI/UX Designer
 
How not to be a mediocre developer!
How not to be a mediocre developer!How not to be a mediocre developer!
How not to be a mediocre developer!
 
Gitflow Workflow
Gitflow WorkflowGitflow Workflow
Gitflow Workflow
 
Lazy Programmer's Guide To Writing Spec
Lazy Programmer's Guide To Writing SpecLazy Programmer's Guide To Writing Spec
Lazy Programmer's Guide To Writing Spec
 
Developing Better Software
Developing Better SoftwareDeveloping Better Software
Developing Better Software
 
Go serving: Building server app with go
Go serving: Building server app with goGo serving: Building server app with go
Go serving: Building server app with go
 
Webhook & Mailhook
Webhook & MailhookWebhook & Mailhook
Webhook & Mailhook
 
Hacker Culture
Hacker CultureHacker Culture
Hacker Culture
 
Do More With Message Queue
Do More With Message QueueDo More With Message Queue
Do More With Message Queue
 
Building A Software Team
Building A Software TeamBuilding A Software Team
Building A Software Team
 
What the HACK is HHVM?
What the HACK is HHVM?What the HACK is HHVM?
What the HACK is HHVM?
 
Developing MyTrafficCam
Developing MyTrafficCamDeveloping MyTrafficCam
Developing MyTrafficCam
 
Mobile Payment
Mobile PaymentMobile Payment
Mobile Payment
 
Android and web services
Android and web servicesAndroid and web services
Android and web services
 
Android security
Android securityAndroid security
Android security
 
PHP_Frameworks_Discussion
PHP_Frameworks_DiscussionPHP_Frameworks_Discussion
PHP_Frameworks_Discussion
 
Rubik Cubes For Geeks
Rubik Cubes For GeeksRubik Cubes For Geeks
Rubik Cubes For Geeks
 
Geekcamp Android
Geekcamp AndroidGeekcamp Android
Geekcamp Android
 

Recently uploaded

Recently uploaded (20)

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

Color filters for the dummies

  • 1. ColorFilters For The Dummies CodeAndroid Leong Hean Hong 31th Oct 2009 (CC) BY
  • 2. Overview 1. What is bitmap? 2. What is a ColorFilter? 3. ColorMatrixColorFilter 4. LightingColorFilter 5. 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