I need to convert bytes of an CYMK image to bytes for RGB image.
I think it's possible to skip the bytes of the header and convert others bytes in RGB and then change the header bytes for RGB
format.
Which are the header bytes to change for RGB
?
Which is the formula for the bit color conversion without ICC profile?
Can anybody help me to complete this code?
//Decode with inSampleSize
Bitmap Resultbitmap;
string path = "imageFileCmyk.jpg";
int scale=4;
BitmapFactory.Options o2 = new BitmapFactory.Options();
o2.inPurgeable = true;
o2.inSampleSize=scale;
o2.inDither = false;
Resultbitmap = BitmapFactory.decodeStream(new FileInputStream(path), null, o2);
if (Resultbitmap==null) // Warning!! unsupported color conversion request
{
File tmpfile = new File(path);
FileInputStream is = new FileInputStream(tmpfile.getPath());
byte[] cmykBytes= new byte[(int)tmpfile.length()];
byte[] rgbBytes= new byte[(int)tmpfile.length()];
is.read(cmykBytes);
for (int i = 0; cmykBytes.length>i; ++i)
{
if (i>11) // skip header's bytes, is it correct ??
{
rgbBytes[i] = cmykBytes[i]?? // How ??
}
}
// new header bytes for RGB format
rgbBytes[??]= ?? // How ??
Resultbitmap = BitmapFactory.decodeByteArray(rgbBytes, 0, rgbBytes.length, o2);
}
return Resultbitmap;
Thanks,
Alberto