2011-12-11 2 views

답변

1

color picker의 코드를 사용하여 이미지의 RGBA 행렬을 가져 와서 알파를 변경할 수 있습니다. 그리고 이미지를 다시 저장하십시오.

https://github.com/sakrist/VBColorPicker/blob/master/VBColorPicker/VBColorPicker.m

unsigned char* data = CGBitmapContextGetData (cgctx); 
if (data != NULL && data != 0) { 
    //offset locates the pixel in the data from x,y. 
    //4 for 4 bytes of data per pixel, w is width of one row of data. 
    int offset = 4*((w*round(point.y))+round(point.x)); 
    int alpha = data[offset]; 
    int red = data[offset+1]; 
    int green = data[offset+2]; 
    int blue = data[offset+3]; 
    NSLog(@"offset: %i colors: RGB A %i %i %i %i",offset,red,green,blue,alpha); 
    color = [UIColor colorWithRed:(red/255.0f) green:(green/255.0f) blue:(blue/255.0f) alpha:(alpha/255.0f)]; 
} 
0

이미지에는 앱에서 액세스 할 수있는 픽셀 또는 알려진 크기의 픽셀이 있거나 없을 수 있습니다. 그러나 이미지를 생성 한 비트 맵에 렌더링 할 수 있습니다. RGBA (또는 ABGR) 비트 맵인 경우 RGB 값을 변경할 수있는 것과 동일한 방식으로 모든 픽셀의 알파를 변경할 수 있습니다. 앱은이 수정 된 비트 맵에서 새 이미지를 만들 수 있습니다.

관련 문제