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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 01-21-2010, 05:00 AM   #26 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 96
Default

I'm also searching for a way to colorize the image...
But Actually what I need is to add a TONE to a grayscale image ...
I'll surf the web and Will post here result ...
Dvdkite is offline   Reply With Quote
Old 01-21-2010, 08:01 AM   #27 (permalink)
indie dev
 
rocotilos's Avatar
 
Join Date: Oct 2009
Posts: 2,754
Default

Quote:
Originally Posted by Dvdkite View Post
I'm also searching for a way to colorize the image...
But Actually what I need is to add a TONE to a grayscale image ...
I'll surf the web and Will post here result ...
What do you mean TONE? Do you mean Contrast?
rocotilos is offline   Reply With Quote
Old 01-21-2010, 10:59 AM   #28 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 96
Default

Quote:
Originally Posted by rocotilos View Post
What do you mean TONE? Do you mean Contrast?
Maybe I've used the wrong word...

With "adding a tone" to a grayscale image I mean add a color like ,for example, sepia (light orange tone)...
Is it a wrong translation :-D???
Dvdkite is offline   Reply With Quote
Old 01-21-2010, 11:07 AM   #29 (permalink)
indie dev
 
rocotilos's Avatar
 
Join Date: Oct 2009
Posts: 2,754
Default

Oh i see... i dont know the right word for that either..
sepia i think is similar to colorize... im working on colorize...
pretty mindboggling for me with all the RGBs manipulation.
seems im gonna have to do it myself.

ill share here when im done.
rocotilos is offline   Reply With Quote
Old 02-04-2010, 03:14 AM   #30 (permalink)
indie dev
 
rocotilos's Avatar
 
Join Date: Oct 2009
Posts: 2,754
Default

I ditched the colorize filter.

I found a contrast filter instead.

Code:
thevalue range must be between 0 and 4.

for(int index=0;index<length;index+=4){
			double amountRed;
			double amountGreen;
			double amountBlue;
			
			
			amountRed = (double)data[index+1]/255;
			amountRed -= 0.5;
			amountRed *= thevalue;
			amountRed += 0.5;
			amountRed *= 255;
			if (amountRed <0 ) amountRed = 0;
			if (amountRed>255) amountRed = 255;
			
			
			amountGreen = (double)data[index+2]/255;
			amountGreen -= 0.5;
			amountGreen *= thevalue;
			amountGreen += 0.5;
			amountGreen *= 255;
			if (amountGreen <0 ) amountGreen = 0;
			if (amountGreen>255) amountGreen = 255;
			
			amountBlue = (double)data[index+3]/255;
			amountBlue -= 0.5;
			amountBlue *= thevalue;
			amountBlue += 0.5;
			amountBlue *= 255;
			if (amountBlue <0 ) amountBlue = 0;
			if (amountBlue>255) amountBlue = 255;
			
			
			data[index+1] = (Byte)amountRed;
			data[index+2] = (Byte)amountGreen;
			data[index+3] = (Byte)amountBlue;
		}
While playing around with manipulating pixels, I also found Artistic Pen Sketch filter!!!
rocotilos is offline   Reply With Quote
Old 02-04-2010, 07:21 AM   #31 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 96
Default

Hi !

Thank you !
It could be useful in the future..

However browsing the forum here and by google...I've found this code for tint / colorize a gray scale image...it work fine!!

Code:
+ (UIImage *)colorizeImage:(UIImage *)baseImage color:(UIColor *)theColor {
    UIGraphicsBeginImageContext(baseImage.size);
    
    CGContextRef ctx = UIGraphicsGetCurrentContext();
    CGRect area = CGRectMake(0, 0, baseImage.size.width, baseImage.size.height);
    
    CGContextScaleCTM(ctx, 1, -1);
    CGContextTranslateCTM(ctx, 0, -area.size.height);
    
    CGContextSaveGState(ctx);
    CGContextClipToMask(ctx, area, baseImage.CGImage);
    
    [theColor set];
    CGContextFillRect(ctx, area);
 
    CGContextRestoreGState(ctx);
    
    CGContextSetBlendMode(ctx, kCGBlendModeMultiply);
    
    CGContextDrawImage(ctx, area, baseImage.CGImage);
 
    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
    
    UIGraphicsEndImageContext();
    
    return newImage;
}
source here:
Apple - Support - Discussions - [iPhone] Color White Image ...
Dvdkite is offline   Reply With Quote
Old 02-05-2010, 10:29 AM   #32 (permalink)
indie dev
 
rocotilos's Avatar
 
Join Date: Oct 2009
Posts: 2,754
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
Old 02-05-2010, 10:54 PM   #33 (permalink)
indie dev
 
rocotilos's Avatar
 
Join Date: Oct 2009
Posts: 2,754
Default

Anybody done Hue adjusting?

I found some samples in the net, but all are using matrix to do Hue.
I am wondering if anybody done it with just normal equations which
modify the pixels one by one?

Been trying to do Hue for hours now... no luck
rocotilos is offline   Reply With Quote
Old 03-06-2010, 12:24 AM   #34 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 19
Default

Quote:
Originally Posted by rocotilos View Post
Ok done.

I think this is the correct brightness filter for your image. Did this from scratch.

It will go from Black to White. Oh yeah, the slider value must be -1 to +1.
Set the default to 0.

Code:
	for(int index=0;index<length;index+=4){
		// BRIGHTNESS
		
		Byte amountRed;
		Byte amountGreen;
		Byte amountBlue;
		
		if (thevalue<=0) {
			amountRed= (Byte)(data[index+1]*thevalue);
			amountGreen = (Byte)(data[index + 2]*thevalue);
			amountBlue = (Byte)(data[index+3]*thevalue);	
		} else {
			amountRed= (Byte)((255-data[index+1])*thevalue);
			amountGreen = (Byte)((255-data[index + 2])*thevalue);
			amountBlue = (Byte)((255-data[index+3])*thevalue);
			
		}

		data[index+1] = data[index+1]+amountRed;
		data[index+2] = data[index+2]+amountGreen;
		data[index+3] = data[index+3]+amountBlue;
			
    }
Oh yeah, dont forget to change the method "thevalue" typecast to float coz now we're using -1 to +1.
Hi rocotilos,

I have used your code to change brightness of colored image. It gives me expected result on simulator but it is not working on Device.

When i increase slider value from 0 to +1 on device, image turn to yellow shade and it becomes more yellowish as increase slider value.

When i decrease slider value from 0 to -1, nothing happens.

Any idea regarding this or any other option for this. Thanks in advance

Last edited by rahul; 03-06-2010 at 12:28 AM.
rahul is offline   Reply With Quote
Old 03-06-2010, 12:33 AM   #35 (permalink)
indie dev
 
rocotilos's Avatar
 
Join Date: Oct 2009
Posts: 2,754
Default

Hello rahul, the codes all assumes the image has ARGB format.

ie
index = alpha channel
index+1 = red channel
index+2 = green channel
index+3 = blue channel.

this normally is true for PNG images. But, in case of other formats, you need to cater for it.

my advise is pre-process your loaded images into png first (and scale it down a bit).

HTH.
rocotilos is offline   Reply With Quote
Old 03-08-2010, 02:02 AM   #36 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 19
Default

Quote:
Originally Posted by rocotilos View Post
Hello rahul, the codes all assumes the image has ARGB format.

ie
index = alpha channel
index+1 = red channel
index+2 = green channel
index+3 = blue channel.

this normally is true for PNG images. But, in case of other formats, you need to cater for it.

my advise is pre-process your loaded images into png first (and scale it down a bit).

HTH.
Thanks a lot Rocotilos, Image that i was using is in BGR format. so i changed code accordingly. Now when i tried to use another image(i.e. bmp file), code doesn't work properly.

Can you tell me how to convert any image of any format to Png(ARGB) format?

Thanks in advance
rahul is offline   Reply With Quote
Old 03-08-2010, 06:43 AM   #37 (permalink)
indie dev
 
rocotilos's Avatar
 
Join Date: Oct 2009
Posts: 2,754
Default

Yup: here it is

Code:
UIGraphicsBeginImageContext(rect.size);
	[oldImage drawInRect:rect];  // scales image to rect
	newImage = UIGraphicsGetImageFromCurrentImageContext();
	UIGraphicsEndImageContext();
rect.size should be your image size (or whatever size you want it to be-its good to resize to smaller size should the user loads up a 3MP or 5MP photos/images) oldimage is original image, from whatever format. and newImage is the image in ABGR.

And, sorry, this code actually returns ABGR all the time, which is good too. my mistake on prev post (for saying convert it to ARGB)..

HTH
rocotilos is offline   Reply With Quote
Old 03-08-2010, 08:34 AM   #38 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 19
Default

Quote:
Originally Posted by rocotilos View Post
Yup: here it is

Code:
UIGraphicsBeginImageContext(rect.size);
	[oldImage drawInRect:rect];  // scales image to rect
	newImage = UIGraphicsGetImageFromCurrentImageContext();
	UIGraphicsEndImageContext();
rect.size should be your image size (or whatever size you want it to be-its good to resize to smaller size should the user loads up a 3MP or 5MP photos/images) oldimage is original image, from whatever format. and newImage is the image in ABGR.

And, sorry, this code actually returns ABGR all the time, which is good too. my mistake on prev post (for saying convert it to ARGB)..

HTH
Great... Thanks for sharing the information. It helped me a lot.
rahul is offline   Reply With Quote
Old 03-09-2010, 02:32 AM   #39 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 19
Default

Quote:
Originally Posted by rocotilos View Post
Anybody done Hue adjusting?

I found some samples in the net, but all are using matrix to do Hue.
I am wondering if anybody done it with just normal equations which
modify the pixels one by one?

Been trying to do Hue for hours now... no luck
Hey Rocotilos,

Have you got any solution for Hue adjusting?

I'm trying to make image blur or sharp, Any idea?

Thanks in advance
rahul is offline   Reply With Quote
Old 03-15-2010, 06:05 AM   #40 (permalink)
indie dev
 
rocotilos's Avatar
 
Join Date: Oct 2009
Posts: 2,754
Default

Yea.. the Hue i figured it out, but.. er.. i got an app doing that so cannot be shared. lol.

to blur is easy, you just set pixel 1 to be the average of pixel 1 and pixel 2. there are many types of blurring, but averaging is simplest and it works.

to sharpen, you need to enhance the difference between the 2 pixels if the difference is big. i could share but.. er. also have an app doing that too.. hehe sorry. i can only summarise what it does.
rocotilos is offline   Reply With Quote
Old 04-17-2010, 02:09 AM   #41 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: Ahmedabad
Posts: 19
Default

Here is how i work with the saturation filter, it does not work perfectly though, if someone can get it done right

Code:
-(void)slideAction:(id)sender
{
	UISlider *contrast=(UISlider*)sender;
	CGImageRef inImage = tmpimage.CGImage;//[tmpimg image].CGImage;         
    CGContextRef ctx; 
	
	
	CFDataRef m_DataRef; 
	m_DataRef = CGDataProviderCopyData(CGImageGetDataProvider(inImage)); 
	UInt8 * m_PixelBuf = (UInt8 *) CFDataGetBytePtr(m_DataRef); 
    //    Byte tmpByte; 
	int length = CFDataGetLength(m_DataRef); 
	NSLog(@"len %d", length); 
	
	NSLog(@"width=%d, height=%d", CGImageGetWidth( inImage ), CGImageGetHeight( inImage ));         
	NSLog(@"1=%d, 2=%d, 3=%d", CGImageGetBitsPerComponent(inImage), CGImageGetBitsPerPixel(inImage),CGImageGetBytesPerRow(inImage)); 
	
CGFloat thevalue=contrast.value;

ctx = CGBitmapContextCreate(m_PixelBuf, 
								CGImageGetWidth( inImage ), 
								CGImageGetHeight( inImage ), 
								8, 
								CGImageGetBytesPerRow( inImage ), 
								CGImageGetColorSpace( inImage ), 
								kCGImageAlphaPremultipliedFirst ); 

	CGRect r = CGRectMake(0, 0, CGImageGetWidth(inImage), CGImageGetHeight(inImage));
	CGContextDrawImage(ctx, r, inImage);
	CGContextSetBlendMode(ctx, kCGBlendModeSaturation);
	CGContextAddRect(ctx,r);
	CGFloat SaturationComplement = thevalue;
	//CGContextSetRGBFillColor(ctx, 0.3086f * SaturationComplement, 0.6094f * SaturationComplement, 0.0820f * SaturationComplement, 1);
	CGContextSetRGBFillColor(ctx, thevalue, 0., thevalue, 1);
	CGContextFillPath(ctx);

	CGImageRef imageRef = CGBitmapContextCreateImage (ctx); 
	UIImage* rawImage = [UIImage imageWithCGImage:imageRef]; 
	
	CGContextRelease(ctx); 
	
    tmpimg.image = rawImage;
}

Last edited by ashish1405; 04-19-2010 at 01:48 AM.
ashish1405 is offline   Reply With Quote
Old 04-17-2010, 12:03 PM   #42 (permalink)
Registered Member
 
Join Date: Dec 2009
Posts: 88
Default

Quote:
Originally Posted by rocotilos View Post
Yea.. the Hue i figured it out, but.. er.. i got an app doing that so cannot be shared. lol.

to blur is easy, you just set pixel 1 to be the average of pixel 1 and pixel 2. there are many types of blurring, but averaging is simplest and it works.

to sharpen, you need to enhance the difference between the 2 pixels if the difference is big. i could share but.. er. also have an app doing that too.. hehe sorry. i can only summarise what it does.
You sell an image processing app but yet you don't know how to change the hue of an image? Are you just cutting and pasting random code?
Blitfast is offline   Reply With Quote
Old 04-18-2010, 02:48 PM   #43 (permalink)
indie dev
 
rocotilos's Avatar
 
Join Date: Oct 2009
Posts: 2,754
Default

Quote:
Originally Posted by Blitfast View Post
You sell an image processing app but yet you don't know how to change the hue of an image? Are you just cutting and pasting random code?
If u read properly, I said I KNOW. But just not willing to share the code at the moment. And I don't get you replying a thread like this. Would you like to share your code?
rocotilos is offline   Reply With Quote
Old 04-27-2010, 02:12 PM   #44 (permalink)
Registered Member
 
Join Date: Mar 2010
Posts: 6
Default

Hi guys,

bit of a newb and just playing around and am looking for some help if you don't mind?

Basically i understand everything thats been posted etc, quick question though: how would i go about accessing the rgb values for a particular X and Y co-ordinate?

i found: 4*((imageWidth*round(Y))+round(X))

but i can't seem to get it to work, adjusting the X co-ordinate works fine but adjusting the Y co-ordinate value seems to pick a pixel that is nowhere near where i wanted?

am i along the right lines with the above formula or am i well off?
qwerty2k is offline   Reply With Quote
Old 04-28-2010, 02:08 PM   #45 (permalink)
Registered Member
 
Join Date: Mar 2010
Posts: 6
Default

Code:
//Load in the image we want to analyse
	UIImage *c = [UIImage imageNamed:@"test.jpg"];
	
	//Convert image to format we can look at
	CGImageRef inImage = CGImageRetain(c.CGImage);          
    CGContextRef ctx;  
	
	//Get the pixel data from the image
	CFDataRef m_DataRef;  
	m_DataRef = CGDataProviderCopyData(CGImageGetDataProvider(inImage));  
	UInt8 * m_PixelBuf = (UInt8 *) CFDataGetBytePtr(m_DataRef);  
    //    Byte tmpByte;  
	int length = CFDataGetLength(m_DataRef);  
	//NSLog(@"len %d", length);  
	int bytesPerPixel = 4;
	
	int imageWidth = CGImageGetWidth(inImage);
	int imageHeight = CGImageGetHeight(inImage);

        int x = 25;
        int y = 25;

int offset = 4*((imageWidth*round(Y))+round(X))
	NSLog(@"offset:%i", offset);
	m_PixelBuf[offset+1] = 255;
	m_PixelBuf[offset+2] = 1;
	m_PixelBuf[offset+3] = 1;

	//Create an image from the pixel data
	ctx = CGBitmapContextCreate(m_PixelBuf,  
								CGImageGetWidth( inImage ),  
								CGImageGetHeight( inImage ),  
								8,  
								CGImageGetBytesPerRow( inImage ),  
								CGImageGetColorSpace( inImage ),  
								kCGImageAlphaPremultipliedFirst );  
	
	
	CGImageRef imageRef = CGBitmapContextCreateImage (ctx);  
	UIImage* rawImage = [UIImage imageWithCGImage:imageRef];  
	
	CGContextRelease(ctx);  
	
	//Set the UIImage to the new image data
    testPic2.image = rawImage;
thats a rough outline of the code im using, picture im testing on is a 50px by 50px pixel just as a test yet trying to get x,y of 25,25 doesn't yield the pixel in the dead center of the image
qwerty2k is offline   Reply With Quote
Old 06-15-2010, 05:52 AM   #46 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 96
Default

Quote:
Originally Posted by rocotilos View Post
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;
Hi again Rocotilos,

In my app I would like to add a contrast (and then a better brightness control too) slider to modify an UIImageView.
I take the photo from the library or from the camera, then I convert it to GRAY SCALE and then, as you suggested in this post, I've re-processed the images to obtain an ABGR simply with this lines:

Code:
        //should convert my Gray scale to PNG (so ABGR?)	
        CGSize size = image.size; 
	UIGraphicsBeginImageContext( size );
	[image drawInRect:CGRectMake(0,0,size.width,size.height)];
	UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
	UIGraphicsEndImageContext();
	return newImage;
And since now, on simulator, all is ok except for the fact that I don't know if the gray image in the screen has now been converted to ABGR. I've done it because I would like to use you code to change constrast so...
I'm actually tryng use your code by this way:

Code:
-(void)contrast:(int)value{
	CGImageRef img=foto.image.CGImage;
	CFDataRef dataref=CopyImagePixels(img);
	UInt8 *data=(UInt8 *)CFDataGetBytePtr(dataref);
	int length=CFDataGetLength(dataref);
	for(int index=0;index<length;index+=4){
		// CONSTRAST TEST
		int aRed = data[index+1];
		int aGreen = data[index+2];
		int aBlue = data[index+3];
		
		aRed = (((aRed-128)*value )/100) + 128;
		if (aRed < 0) aRed = 0; if (aRed>255) aRed=255;
		data[index+1] = aRed;
		
		aGreen = (((aGreen-128)*value )/100) + 128;
		if (aGreen < 0) aGreen = 0; if (aGreen>255) aGreen=255;
		data[index+2] = aGreen;
		
		aBlue = (((aBlue-128)*value )/100) + 128;
		if (aBlue < 0) aBlue = 0; if (aBlue>255) aBlue=255;
		data[index+3] = aBlue;		
		
	}
	size_t width=CGImageGetWidth(img);
	size_t height=CGImageGetHeight(img);
	size_t bitsPerComponent=CGImageGetBitsPerComponent(img);
	size_t bitsPerPixel=CGImageGetBitsPerPixel(img);
	size_t bytesPerRow=CGImageGetBytesPerRow(img);
	CGColorSpaceRef colorspace=CGImageGetColorSpace(img);
	CGBitmapInfo bitmapInfo=CGImageGetBitmapInfo(img);
	CFDataRef newData=CFDataCreate(NULL,data,length);
	CGDataProviderRef provider=CGDataProviderCreateWithCFData(newData);
	CGImageRef newImg=CGImageCreate(width,height,bitsPerComponent,bitsPerPixel,bytesPerRow,colorspace,bitmapInfo,provider,NULL,true,kCGRenderingIntentDefault);
	[foto setImage:[UIImage imageWithCGImage:newImg]];
	CGImageRelease(newImg);
	CGDataProviderRelease(provider);
	
}
The slider is between 0-200 with 100 initial value.

The result simply don't work. Just slide a little and the human face (example) disappear and the foto turns gray!
I've tryed to manually set the int value in contrast method to 10, 50, 110... all the same result: picture turns gray.

I'm really not a master of image pixel manipulation, I still have to read and learn but I'm doing some test now and now I don't know what I'm doing wrong! Probably is there a stupid beginner error in the contrast code (created from me with your code mixed with another code found for the brightness mabe in the wrong way!)!

Thank you and everyone for help!

Last edited by Dvdkite; 06-15-2010 at 05:59 AM.
Dvdkite is offline   Reply With Quote
Old 06-15-2010, 07:00 AM   #47 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: Ahmedabad
Posts: 19
Default

Most of the filters given here work quite well on simulator, but not on iphone os. issue seem to be something related to ARGB - RGBA
ashish1405 is offline   Reply With Quote
Old 06-15-2010, 07:05 AM   #48 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 96
Default

Quote:
Originally Posted by ashish1405 View Post
Most of the filters given here work quite well on simulator, but not on iphone os. issue seem to be something related to ARGB - RGBA
In the above case I've tested it only on simulator and it doesn't work... I'm sure there's something wrong in my "contrast" filter...
Dvdkite is offline   Reply With Quote
Old 06-17-2010, 10:50 AM   #49 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 96
Default

I'm still tryng to create an Optimal Contrast method but I haven't find a solution...
Anyone could help me with my post above?
Dvdkite is offline   Reply With Quote
Old 07-10-2010, 01:56 PM   #50 (permalink)
indie dev
 
rocotilos's Avatar
 
Join Date: Oct 2009
Posts: 2,754
Default

Hello DVDKite, sorry I didnt notice you were asking on this thread.

I saw a small mistake on your code

-(void)contrastint)value{

value is supposed to be CGFloat (or float) type, because that is what a UISlider's value format is in. And pls be sure that the slider's min and max value is set to 0.0f and 200.0f respectively.

You can check your image color format this way:

1. temporary comment out all that contrast code.
2. just put data[index+1]=255; data[index+2]=0; data[index+3]=0; data[index]=255;

if it turns red, then u know index+1 is RED, therefore chances are format is ARGB.
if it turns blue, the u know index+1 is BLUE< therefore chances are format is ABGR
etc.. test it this way..

You must make sure all images you loaded into your app has the same format.
As for me, i use that code post #37 above. all images are gone thru that function, therefore
it returns the image in the same color format.


ALSO, probably it is better to put a typecast for the data.

data[index+1] = (Byte)aRed;

because data is in Byte format.

Good luck!

Last edited by rocotilos; 07-10-2010 at 02:00 PM.
rocotilos is offline   Reply With Quote
Reply

Bookmarks

Tags
bitmap, effects, filter, image proccessing, uiimage

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 274
23 members and 251 guests
ADY, AragornSG, Bertrand21, Dani77, Dattee, fkmtc, HDshot, HemiMG, iDifferent, jakerocheleau, JasonR, jimbo, macquitzon216, mer10, prchn4christ, Rudy, sacha1996, silverwiz, sneaky, spiderguy84, Sunny46, theone8one
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,230
Posts: 380,767
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:07 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0