public ImgWriterPPM(IFileInfo out_Renamed, BlkImgDataSrc imgSrc, int n1, int n2, int n3)
{
// Check that imgSrc is of the correct type
// Check that the component index is valid
if ((n1 < 0) || (n1 >= imgSrc.NumComps) || (n2 < 0) || (n2 >= imgSrc.NumComps) || (n3 < 0) || (n3 >= imgSrc.NumComps) || (imgSrc.getNomRangeBits(n1) > 8) || (imgSrc.getNomRangeBits(n2) > 8) || (imgSrc.getNomRangeBits(n3) > 8))
{
throw new System.ArgumentException("Invalid component indexes");
}
// Initialize
w = imgSrc.getCompImgWidth(n1);
h = imgSrc.getCompImgHeight(n1);
// Check that all components have same width and height
if (w != imgSrc.getCompImgWidth(n2) || w != imgSrc.getCompImgWidth(n3) || h != imgSrc.getCompImgHeight(n2) || h != imgSrc.getCompImgHeight(n3))
{
throw new System.ArgumentException("All components must have the" + " same dimensions and no" + " subsampling");
}
w = imgSrc.ImgWidth;
h = imgSrc.ImgHeight;
// Continue initialization
if (out_Renamed.Exists && !out_Renamed.Delete())
{
throw new System.IO.IOException("Could not reset file");
}
this.out_Renamed = SupportClass.RandomAccessFileSupport.CreateRandomAccessFile(out_Renamed, "rw");
src = imgSrc;
cps[0] = n1;
cps[1] = n2;
cps[2] = n3;
fb[0] = imgSrc.getFixedPoint(n1);
fb[1] = imgSrc.getFixedPoint(n2);
fb[2] = imgSrc.getFixedPoint(n3);
levShift[0] = 1 << (imgSrc.getNomRangeBits(n1) - 1);
levShift[1] = 1 << (imgSrc.getNomRangeBits(n2) - 1);
levShift[2] = 1 << (imgSrc.getNomRangeBits(n3) - 1);
writeHeaderInfo();
}