2013-06-13 3 views
0

안드로이드 비트 맵이 있는데 이미지의 색조를 변경하려고합니다. 이미지가 빨간색 블록이므로 색조를 변경하여 녹색으로 변경하고 싶습니다. 아무 코드도 찾을 수없는 것 같습니다.안드로이드 비트 맵 변경 색조

누구든지이 작업을 수행 할 수 있습니다.

캔버스

+0

가능한 복제본입니다. http://stackoverflow.com/questions/7384278/how-to-adjust-the-hue-of-a-color-code – Piovezan

+0

나는 (을)를 적용하여 Android 비트 맵을 변경하려고합니다. 색조가 바뀌면 연결된 질문이 관련성이없는 것으로 보입니다. – Canvas

+1

따라서 "가능한". :) – Piovezan

답변

0

난 당신이 간단한 "색상"을 찾을 것이라고 확신 해요 이미지의 색상을 조정 다이얼. .

가장 가까운 근사치 (그리고 당신이 얻을 수있는 fine0 작업을해야하는 것은

This question ColorMatrix 함께 그 답은 주제에 빛을 많이 흘리는 여기

가 ColorMatrix이 무엇인지의 technical description입니다. :

ColorMatrix is a 5x4 matrix for transforming the color+alpha components of a Bitmap. 
The matrix is stored in a single array, and its treated as follows: 
    [ a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t ] 

When applied to a color [r, g, b, a], the resulting color is computed as (after clamping) 
     R' = a*R + b*G + c*B + d*A + e; 
     G' = f*R + g*G + h*B + i*A + j; 
     B' = k*R + l*G + m*B + n*A + o; 
     A' = p*R + q*G + r*B + s*A + t; 
+0

Android Studio에서는 Script IntrinsicColorMatrix를 사용하여 Bitmap의 색조를 매우 빠르게 조정하는 방법을 보여주는 "Render Script Intrinsic"이라는 "샘플 가져 오기"를 사용할 수 있습니다. –

1

글쎄, 당신이 후 모두가. 당신은 그냥 R과 G 색상 구성 요소를 전환 할 수 있습니다, 원시 "녹색 빨간색으로 변경"하지만, 당신을 위해 일을 할 수있는 경우.

private Bitmap redToGreen(Bitmap mBitmapIn) 
{ 
    Bitmap bitmap = mBitmapIn.copy(mBitmapIn.getConfig(), true); 

    int []raster = new int[bitmap.getWidth()]; 

    for(int line = 0; line < bitmap.getHeight(); line++) { 
     bitmap.getPixels(raster, 0, bitmap.getWidth(), 0, line, bitmap.getWidth(), 1); 

     for (int p = 0; p < bitmap.getWidth(); p++) 
      raster[p] = Color.rgb(Color.green(raster[p]), Color.red(raster[p]), Color.blue(raster[p])); 

     bitmap.setPixels(raster, 0, bitmap.getWidth(), 0, line, bitmap.getWidth(), 1); 
    } 

    return bitmap; 
}