Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 02-05-2010, 09:29 AM   #32 (permalink)
rocotilos
almostfunnydev
iPhone Dev SDK Supporter
 
rocotilos's Avatar
 
Join Date: Oct 2009
Age: 34
Posts: 3,015
rocotilos is on a distinguished road
Default Better performance Contrast code

Just made this. The above also works but, seems too many calculation in the loop making the process lag a bit.

This one, is better for adjusting contrast:

contrast is a UISlider with value 0-200, default 100.

Code:
int aRed = data[index+1];
			 int aGreen = data[index+2];
			 int aBlue = data[index+3];
			 
			 aRed = (((aRed-128)*contrast.value )/100) + 128;
			 if (aRed < 0) aRed = 0; if (aRed>255) aRed=255;
			 data[index+1] = aRed;
			 
			 aGreen = (((aGreen-128)*contrast.value )/100) + 128;
			 if (aGreen < 0) aGreen = 0; if (aGreen>255) aGreen=255;
			 data[index+2] = aGreen;
			 
			 aBlue = (((aBlue-128)*contrast.value )/100) + 128;
			 if (aBlue < 0) aBlue = 0; if (aBlue>255) aBlue=255;
			 data[index+3] = aBlue;
rocotilos is offline   Reply With Quote
 

» Advertisements
» Online Users: 527
12 members and 515 guests
cch4d10, Domele, Hassasin, headkaze, ilmman, jbro, jeiry, linetteqi95, nebulabox, Newbie123, sangsom, smithms
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,446
Threads: 94,031
Posts: 402,604
Top Poster: BrianSlick (7,978)
Welcome to our newest member, larueta13
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 10:15 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.