hi guys,
I'm currently developing an app where I have an UIImageView that the user can freely move, scale and rotate with gestures (I'm using Apple's Touches code) and then he has the possibility to change its brightness by using an UISlider. The brightness-adjusting method works fine with all the other imageviews but not with the one I need to move and play around because you start to slide, the UIImageView starts to change but after a second the app crashes not leaving any info in the console, btw here's the code, where jk is the UIImage of the movable UIImageView and imgVback is the actual movable UIImageView:
Code:
-(void)doImageStuff:(int)value{
UIImage *jk = imageK;
CGImageRef img=jk.CGImage;
CFDataRef dataref=CopyImagePixels(img);
UInt8 *data=(UInt8 *)CFDataGetBytePtr(dataref);
int length=CFDataGetLength(dataref);
for(int index=0;index<length;index+=4){
// BRIGHTNESS
for(int i=0;i<3;i++){
if(data[index+i]+value<0){
data[index+i]=0;
}else{
if(data[index+i]+value>255){
data[index+i]=255;
}else{
data[index+i]+=value;
}
}
}
}
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);
[imgVback setImage:[UIImage imageWithCGImage:newImg]];
CGImageRelease(newImg);
CGDataProviderRelease(provider);
}
I firstly thought it was something going wrong combining this to the moving/scaling/rotating action, but even if I don't add any gestures to the UIImageView it still doesn't work
what am I supposed to do ?
please help,
David.