private static int ReadColor(ref PsdInfo info, int c, int pos) { int v; pos *= info.ColorDepthBytes; if (info.ColorDepthBytes == 1) { v = PSDReader.ToInteger(info.ImageData[c], pos, info.ColorDepthBytes); } else if (info.ColorDepthBytes == 2) { v = (int)(PSDReader.ToInteger(info.ImageData[c], pos, info.ColorDepthBytes) / 257d); // (65536 - 1) * (256 - 1) = 257 } else { v = (int)(255 * Math.Pow(PSDReader.ToFloat(info.ImageData[c], pos), 0.45470693)); } return(v); }