5
알파 마스크 인 일부 .png 아이콘이 있습니다. Android SDK를 사용하여 이미지를 드로어 블 이미지로 렌더링해야합니다. 내가 위를 달성하려면 어떻게알파 마스크를 사용하여 캔버스 채우기 및 채우기 방법
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate(NULL, thumbWidth,
thumbHeight, 8, 4*thumbWidth, colorSpace, kCGImageAlphaPremultipliedFirst);
CGRect frame = CGRectMake(0,0,thumbWidth,thumbHeight);
CGContextClipToMask(context, frame, [image CGImage]);
CGContextFillRect(context, frame);
CGImageRef imageMasked = CGBitmapContextCreateImage(context);
CGContextRelease(context);
: 아이폰에
, 나는 채우기로 검은 사용하여 'imageMasked'이미지에 "이미지"알파 마스크로 변환,이 결과를 얻으려면 다음을 사용 Android SDK?나는 다음 쓰기 시작했습니다
Drawable image = myPngImage;
final int width = image.getMinimumWidth();
final int height = image.getMinimumHeight();
Bitmap imageMasked = Bitmap.createBitmap(width,
height, Config.ARGB_8888);
Canvas canvas = new Canvas(iconMasked);
image.draw(canvas); ???
내가 이미지를 사용 imageMasked에 클리핑을 수행하는 방법을 찾는 게 아니에요.
난거야 아마 질문을하지 않았다,하지만 당신은 이미지보기로 알파 이미지를 할당하는 경우 - 알파가있을 것입니다. –
내가 여기서하려고하는 것은 알파 비트 맵을 클리핑 영역으로 변환하여 채우기에 사용하는 것입니다. 본질적으로 알파 마스크 적용. 다른 답변자가 있습니까? –
내가하려는 것은이 줄을 따라 뭔가를하는 것입니다 : final int width = icon.getMinimumWidth(); final int height = icon.getMinimumHeight(); \t \t \t \t 비트 맵 iconMasked = Bitmap.createBitmap (width, height, Config.ARGB_8888); 캔버스 캔버스 = 새 캔버스 (iconMasked); 최종 지역 region = icon.getTransparentRegion(); canvas.clipRegion (지역); canvas.drawARGB (255, 0, 0, 0); 이 방법의 문제점은 내 아이콘이 getTransparentRegion()에서 null을 반환한다는 것입니다. 기대하지 않았으므로 여전히 대답을 찾고 있습니다. –