1

비트 맵 이미지 데이터에 이미지 효과를 수행하는 데 도움을주십시오.안드로이드의 비트 맵 이미지에서 사진 효과를 적용하는 방법

다음 코드를 검색하여 사진 효과를 적용합니다. 하지만 정확히 무슨 가치가 효과를 위해 통과해야하는지에 관해 나는 모른다.

코드는 ..

public Bitmap createEffect(Bitmap src, int depth, double red, double green, double blue) { 
    // image size 
    int width = src.getWidth(); 
    int height = src.getHeight(); 
    // create output bitmap 
    Bitmap bmOut = Bitmap.createBitmap(width, height, src.getConfig()); 
    // constant grayscale 
    final double GS_RED = 0.3; 
    final double GS_GREEN = 0.59; 
    final double GS_BLUE = 0.11; 
    // color information 
    int A, R, G, B; 
    int pixel; 

    // scan through all pixels 
    for(int x = 0; x < width; ++x) { 
     for(int y = 0; y < height; ++y) { 
      // get pixel color 
      pixel = src.getPixel(x, y); 
      // get color on each channel 
      A = Color.alpha(pixel); 
      R = Color.red(pixel); 
      G = Color.green(pixel); 
      B = Color.blue(pixel); 
      // apply grayscale sample 
      B = G = R = (int)(GS_RED * R + GS_GREEN * G + GS_BLUE * B); 

      // apply intensity level for sepid-toning on each channel 
      R += (depth * red); 
      if(R > 255) { R = 255; } 

      G += (depth * green); 
      if(G > 255) { G = 255; } 

      B += (depth * blue); 
      if(B > 255) { B = 255; } 

      // set new pixel color to output image 
      bmOut.setPixel(x, y, Color.argb(A, R, G, B)); 
     } 
    } 

    // return final image 
    return bmOut; 
} 

나는 this 응용 프로그램처럼 작동하고 싶다. 효과와 그림이 따르고 있습니다

First effectsecond effect Third effect fourth effect sixth effect

답변

2

코드를 읽으면 당신은 SRC의 모든 픽셀이 먼저 [255] 를 그레이 스케일로 변환됩니다 것을 볼 수 있습니다 이 값은 그레이 스케일 값을 기준으로 깊이 * 색상을 추가하여 컬러 픽셀로 다시 변환됩니다.

그래서 비트 맵을 녹색 색조를 부여하려면 다음과 같이 그것을 :

Bitmap result = createEffect(src,50,0,1,0); 

이 비트 맵 친환경을 만들 것입니다.

public Bitmap invert(Bitmap src) { 
    // image size 
    int width = src.getWidth(); 
    int height = src.getHeight(); 
    // create output bitmap 
    Bitmap bmOut = Bitmap.createBitmap(width, height, src.getConfig()); 
    // color information 
    int A, R, G, B; 
    int pixel; 

    // scan through all pixels 
    for(int x = 0; x < width; ++x) { 
     for(int y = 0; y < height; ++y) { 
      // get pixel color 
      pixel = src.getPixel(x, y); 
      // get color on each channel 
      A = Color.alpha(pixel); 
      R = Color.red(pixel); 
      G = Color.green(pixel); 
      B = Color.blue(pixel); 
      // set new pixel color to output image 
      bmOut.setPixel(x, y, Color.argb(A, 255-R, 255-G, 255-B)); 
     } 
    } 

    // return final image 
    return bmOut; 
} 
+0

답장을 보내 주셔서 감사합니다.하지만 이미하고 싶은 말을하고 있지만 정확한 출력을 얻지 못했습니다. 값을 전달할 때 배경에 영향을주지 않습니다. –

+0

이 출력을 얻을 때까지 값을 실험하십시오. 또한 게시 한 기능을 사용하여 예제 그림을 만들었습니까? – Renard

+0

최종 이미지를 얻는 데 필요한 값은 –

2

방문이 링크 : 여기에 설명되어 있습니다

http://www.shaikhhamadali.blogspot.ro/p/home.html

20 ~ 30 이미지 효과 (마지막 exmaple에 같은) 색상을 반전하려면

이 (안된) 함수를 사용하여 프로그래밍 방식으로 그리고 주석으로도!

희망이 도움이됩니다.

관련 문제