Search code examples
javaandroidbitmapcurvescolormatrix

How to parse photoshop curve file(.acv) to get the rgb values?


this is my first post in stackoverflow.

So I have these custom .acv files from photoshop, what I want to do is I am trying to filter a bitmap using colormatrix. To do that, I am parsing those .acv files to get its rgb values to be used by the colormatrix. How can I do this?

Edited: Here is the colormatrix code that I want to supply with the RGB values from the .acv file. The only thing left is how to extract those values.

private Bitmap filterBitmap(Bitmap bitmap) {
    Bitmap bitmapResult = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);

    Canvas canvasResult = new Canvas(bitmapResult);
    Paint paint = new Paint();

    // 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;
    float m = 255f;
    float t = -255 * 128f;
    ColorMatrix colorMatrix = new ColorMatrix(new float[]{
            m, 0, 0, 1,
            0, m, 0, 1,
            0, 0, m, 1,
    });
    ColorMatrixColorFilter filter = new ColorMatrixColorFilter(colorMatrix);
    paint.setColorFilter(filter);
    canvasResult.drawBitmap(bitmap, 0, 0, paint);

    return bitmapResult;
}

Solution

  • I'm doing this by applying curve to full palette image and then extracting rgb values from resulting image. Here's source image:

    enter image description here

    But I've done so because I'm it in OpenGL fragment shaders. That's why it has low resolution and not very accurate results (but very ok).