/// <summary> Creates a new writer to the specified File object, to write data from /// the specified component. /// /// <p>The size of the image that is written to the file is the size of the /// component from which to get the data, specified by b, not the size of /// the source image (they differ if there is some sub-sampling).</p> /// /// </summary> /// <param name="out">The file where to write the data /// /// </param> /// <param name="imgSrc">The source from where to get the image data to write. /// /// </param> /// <param name="c">The index of the component from where to get the data. /// /// </param> public ImgWriterPGM(IFileInfo out_Renamed, BlkImgDataSrc imgSrc, int c) { // Check that imgSrc is of the correct type // Check that the component index is valid if (c < 0 || c >= imgSrc.NumComps) { throw new System.ArgumentException("Invalid number of components"); } // Check that imgSrc is of the correct type if (imgSrc.getNomRangeBits(c) > 8) { FacilityManager.getMsgLogger().println("Warning: Component " + c + " has nominal bitdepth " + imgSrc.getNomRangeBits(c) + ". Pixel values will be " + "down-shifted to fit bitdepth of 8 for PGM file", 8, 8); } // Initialize 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; this.c = c; w = imgSrc.ImgWidth; h = imgSrc.ImgHeight; fb = imgSrc.getFixedPoint(c); levShift = 1 << (imgSrc.getNomRangeBits(c) - 1); writeHeaderInfo(); }
/// <summary>General utility used by ctors </summary> private void initialize() { this.pl = csMap.pl; this.ncomps = src.NumComps; shiftValueArray = new int[ncomps]; maxValueArray = new int[ncomps]; fixedPtBitsArray = new int[ncomps]; srcBlk = new DataBlk[ncomps]; inInt = new DataBlkInt[ncomps]; inFloat = new DataBlkFloat[ncomps]; workInt = new DataBlkInt[ncomps]; workFloat = new DataBlkFloat[ncomps]; dataInt = new int[ncomps][]; dataFloat = new float[ncomps][]; workDataInt = new int[ncomps][]; workDataFloat = new float[ncomps][]; dataInt = new int[ncomps][]; dataFloat = new float[ncomps][]; /* For each component, get a reference to the pixel data and * set up working DataBlks for both integer and float output. */ for (int i = 0; i < ncomps; ++i) { shiftValueArray[i] = 1 << (src.getNomRangeBits(i) - 1); maxValueArray[i] = (1 << src.getNomRangeBits(i)) - 1; fixedPtBitsArray[i] = src.getFixedPoint(i); inInt[i] = new DataBlkInt(); inFloat[i] = new DataBlkFloat(); workInt[i] = new DataBlkInt(); workInt[i].progressive = inInt[i].progressive; workFloat[i] = new DataBlkFloat(); workFloat[i].progressive = inFloat[i].progressive; } }
/// <summary> Creates a new writer to the specified File object, to write data from /// the specified component. /// /// <p>The three components that will be written as R, G and B must be /// specified through the b1, b2 and b3 arguments.</p> /// /// </summary> /// <param name="out">The file where to write the data /// /// </param> /// <param name="imgSrc">The source from where to get the image data to write. /// /// </param> /// <param name="n1">The index of the first component from where to get the data, /// that will be written as the red channel. /// /// </param> /// <param name="n2">The index of the second component from where to get the data, /// that will be written as the green channel. /// /// </param> /// <param name="n3">The index of the third component from where to get the data, /// that will be written as the green channel. /// /// </param> /// <seealso cref="DataBlk"> /// /// </seealso> 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(); }
/// <summary> Creates a new writer to the specified File object, to write data from /// the specified component. /// /// <p>The size of the image that is written to the file is the size of the /// component from which to get the data, specified by b, not the size of /// the source image (they differ if there is some sub-sampling).</p> /// /// <p>All the header informations are given by the BlkImgDataSrc source /// (component width, component height, bit-depth) and sign flag, which are /// provided to the constructor. The endianness is always big-endian (MSB /// first).</p> /// /// </summary> /// <param name="out">The file where to write the data /// /// </param> /// <param name="imgSrc">The source from where to get the image data to write. /// /// </param> /// <param name="c">The index of the component from where to get the data. /// /// </param> /// <param name="isSigned">Whether the datas are signed or not (needed only when /// writing header). /// /// </param> /// <seealso cref="DataBlk"> /// /// </seealso> public ImgWriterPGX(IFileInfo out_Renamed, BlkImgDataSrc imgSrc, int c, bool isSigned) { //Initialize this.c = c; 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"); this.isSigned = isSigned; src = imgSrc; w = src.ImgWidth; h = src.ImgHeight; fb = imgSrc.getFixedPoint(c); bitDepth = src.getNomRangeBits(this.c); if ((bitDepth <= 0) || (bitDepth > 31)) { throw new System.IO.IOException("PGX supports only bit-depth between " + "1 and 31"); } if (bitDepth <= 8) { packBytes = 1; } else if (bitDepth <= 16) { packBytes = 2; } else { // <= 31 packBytes = 4; } // Writes PGX header System.String tmpString = "PG " + "ML " + ((this.isSigned)?"- ":"+ ") + bitDepth + " " + w + " " + h + "\n"; // component height byte[] tmpByte = System.Text.Encoding.UTF8.GetBytes(tmpString); for (int i = 0; i < tmpByte.Length; i++) { this.out_Renamed.WriteByte((byte)tmpByte[i]); } offset = tmpByte.Length; maxVal = this.isSigned?((1 << (src.getNomRangeBits(c) - 1)) - 1):((1 << src.getNomRangeBits(c)) - 1); minVal = this.isSigned?((-1) * (1 << (src.getNomRangeBits(c) - 1))):0; levShift = (this.isSigned)?0:1 << (src.getNomRangeBits(c) - 1); }
public static Image FromStream(Stream stream) { RandomAccessIO in_stream = new ISRandomAccessIO(stream); // Initialize default parameters ParameterList defpl = GetDefaultParameterList(decoder_pinfo); // Create parameter list using defaults ParameterList pl = new ParameterList(defpl); // **** File Format **** // If the codestream is wrapped in the jp2 fileformat, Read the // file format wrapper FileFormatReader ff = new FileFormatReader(in_stream); ff.readFileFormat(); if (ff.JP2FFUsed) { in_stream.seek(ff.FirstCodeStreamPos); } // +----------------------------+ // | Instantiate decoding chain | // +----------------------------+ // **** Header decoder **** // Instantiate header decoder and read main header HeaderInfo hi = new HeaderInfo(); HeaderDecoder hd; try { hd = new HeaderDecoder(in_stream, pl, hi); } catch (EndOfStreamException e) { throw new ApplicationException("Codestream too short or bad header, unable to decode.", e); } int nCompCod = hd.NumComps; int nTiles = hi.sizValue.NumTiles; DecoderSpecs decSpec = hd.DecoderSpecs; // Get demixed bitdepths int[] depth = new int[nCompCod]; for (int i = 0; i < nCompCod; i++) { depth[i] = hd.getOriginalBitDepth(i); } // **** Bit stream reader **** BitstreamReaderAgent breader; try { breader = BitstreamReaderAgent. createInstance(in_stream, hd, pl, decSpec, false, hi); } catch (IOException e) { throw new ApplicationException("Error while reading bit stream header or parsing packets.", e); } catch (ArgumentException e) { throw new ApplicationException("Cannot instantiate bit stream reader.", e); } // **** Entropy decoder **** EntropyDecoder entdec; try { entdec = hd.createEntropyDecoder(breader, pl); } catch (ArgumentException e) { throw new ApplicationException("Cannot instantiate entropy decoder.", e); } // **** ROI de-scaler **** ROIDeScaler roids; try { roids = hd.createROIDeScaler(entdec, pl, decSpec); } catch (ArgumentException e) { throw new ApplicationException("Cannot instantiate roi de-scaler.", e); } // **** Dequantizer **** Dequantizer deq; try { deq = hd.createDequantizer(roids, depth, decSpec); } catch (ArgumentException e) { throw new ApplicationException("Cannot instantiate dequantizer.", e); } // **** Inverse wavelet transform *** InverseWT invWT; try { // full page inverse wavelet transform invWT = InverseWT.createInstance(deq, decSpec); } catch (ArgumentException e) { throw new ApplicationException("Cannot instantiate inverse wavelet transform.", e); } int res = breader.ImgRes; invWT.ImgResLevel = res; // **** Data converter **** (after inverse transform module) ImgDataConverter converter = new ImgDataConverter(invWT, 0); // **** Inverse component transformation **** InvCompTransf ictransf = new InvCompTransf(converter, decSpec, depth, pl); // **** Color space mapping **** BlkImgDataSrc color; if (ff.JP2FFUsed && pl.getParameter("nocolorspace").Equals("off")) { try { ColorSpace csMap = new ColorSpace(in_stream, hd, pl); BlkImgDataSrc channels = hd.createChannelDefinitionMapper(ictransf, csMap); BlkImgDataSrc resampled = hd.createResampler(channels, csMap); BlkImgDataSrc palettized = hd.createPalettizedColorSpaceMapper(resampled, csMap); color = hd.createColorSpaceMapper(palettized, csMap); } catch (ArgumentException e) { throw new ApplicationException("Could not instantiate ICC profiler.", e); } catch (ColorSpaceException e) { throw new ApplicationException("Error processing ColorSpace information.", e); } } else { // Skip colorspace mapping color = ictransf; } // This is the last image in the decoding chain and should be // assigned by the last transformation: BlkImgDataSrc decodedImage = color; if (color == null) { decodedImage = ictransf; } int numComps = decodedImage.NumComps; int bytesPerPixel = numComps; // Assuming 8-bit components // **** Copy to Bitmap **** PixelFormat pixelFormat; switch (numComps) { case 1: pixelFormat = PixelFormat.Format24bppRgb; break; case 3: pixelFormat = PixelFormat.Format24bppRgb; break; case 4: case 5: pixelFormat = PixelFormat.Format32bppArgb; break; default: throw new ApplicationException("Unsupported PixelFormat. " + numComps + " components."); } Bitmap dst = new Bitmap(decodedImage.ImgWidth, decodedImage.ImgHeight, pixelFormat); Coord numTiles = decodedImage.getNumTiles(null); int tIdx = 0; for (int y = 0; y < numTiles.y; y++) { // Loop on horizontal tiles for (int x = 0; x < numTiles.x; x++, tIdx++) { decodedImage.setTile(x, y); int height = decodedImage.getTileCompHeight(tIdx, 0); int width = decodedImage.getTileCompWidth(tIdx, 0); int tOffx = decodedImage.getCompULX(0) - (int)Math.Ceiling(decodedImage.ImgULX / (double)decodedImage.getCompSubsX(0)); int tOffy = decodedImage.getCompULY(0) - (int)Math.Ceiling(decodedImage.ImgULY / (double)decodedImage.getCompSubsY(0)); DataBlkInt[] db = new DataBlkInt[numComps]; int[] ls = new int[numComps]; int[] mv = new int[numComps]; int[] fb = new int[numComps]; for (int i = 0; i < numComps; i++) { db[i] = new DataBlkInt(); ls[i] = 1 << (decodedImage.getNomRangeBits(0) - 1); mv[i] = (1 << decodedImage.getNomRangeBits(0)) - 1; fb[i] = decodedImage.getFixedPoint(0); } for (int l = 0; l < height; l++) { for (int i = numComps - 1; i >= 0; i--) { db[i].ulx = 0; db[i].uly = l; db[i].w = width; db[i].h = 1; decodedImage.getInternCompData(db[i], i); } int[] k = new int[numComps]; for (int i = numComps - 1; i >= 0; i--) { k[i] = db[i].offset + width - 1; } int outputBytesPerPixel = Math.Max(3, Math.Min(4, bytesPerPixel)); byte[] rowvalues = new byte[width * outputBytesPerPixel]; for (int i = width - 1; i >= 0; i--) { int[] tmp = new int[numComps]; for (int j = numComps - 1; j >= 0; j--) { tmp[j] = (db[j].data_array[k[j]--] >> fb[j]) + ls[j]; tmp[j] = (tmp[j] < 0) ? 0 : ((tmp[j] > mv[j]) ? mv[j] : tmp[j]); if (decodedImage.getNomRangeBits(j) != 8) { tmp[j] = (int)Math.Round(((double)tmp[j] / Math.Pow(2D, (double)decodedImage.getNomRangeBits(j))) * 255D); } } int offset = i * outputBytesPerPixel; switch (numComps) { case 1: rowvalues[offset + 0] = (byte)tmp[0]; rowvalues[offset + 1] = (byte)tmp[0]; rowvalues[offset + 2] = (byte)tmp[0]; break; case 3: rowvalues[offset + 0] = (byte)tmp[2]; rowvalues[offset + 1] = (byte)tmp[1]; rowvalues[offset + 2] = (byte)tmp[0]; break; case 4: case 5: rowvalues[offset + 0] = (byte)tmp[2]; rowvalues[offset + 1] = (byte)tmp[1]; rowvalues[offset + 2] = (byte)tmp[0]; rowvalues[offset + 3] = (byte)tmp[3]; break; } } BitmapData dstdata = dst.LockBits( new System.Drawing.Rectangle(tOffx, tOffy + l, width, 1), ImageLockMode.WriteOnly, pixelFormat); IntPtr ptr = dstdata.Scan0; System.Runtime.InteropServices.Marshal.Copy(rowvalues, 0, ptr, rowvalues.Length); dst.UnlockBits(dstdata); } } } return(dst); }
/// <summary> Returns the position of the fixed point in the specified /// component. This is the position of the least significant integral /// (i.e. non-fractional) bit, which is equivalent to the number of /// fractional bits. For instance, for fixed-point values with 2 fractional /// bits, 2 is returned. For floating-point data this value does not apply /// and 0 should be returned. Position 0 is the position of the least /// significant bit in the data. /// /// <p>This default implementation assumes that the number of fractional /// bits is not modified by the component mixer.</p> /// /// </summary> /// <param name="c">The index of the component. /// /// </param> /// <returns> The value of the fixed point position of the source since the /// color transform does not affect it. /// /// </returns> public virtual int getFixedPoint(int c) { return(src.getFixedPoint(c)); }
/// <summary> Creates a new writer to the specified File object, to write data from /// the specified component. /// /// <p>The size of the image that is written to the file is the size of the /// component from which to get the data, specified by b, not the size of /// the source image (they differ if there is some sub-sampling).</p> /// /// <p>All the header informations are given by the BlkImgDataSrc source /// (component width, component height, bit-depth) and sign flag, which are /// provided to the constructor. The endianness is always big-endian (MSB /// first).</p> /// /// </summary> /// <param name="out">The file where to write the data /// /// </param> /// <param name="imgSrc">The source from where to get the image data to write. /// /// </param> /// <param name="c">The index of the component from where to get the data. /// /// </param> /// <param name="isSigned">Whether the datas are signed or not (needed only when /// writing header). /// /// </param> /// <seealso cref="DataBlk"> /// /// </seealso> public ImgWriterPGX(System.IO.FileInfo out_Renamed, BlkImgDataSrc imgSrc, int c, bool isSigned) { //Initialize this.c = c; bool tmpBool; if (System.IO.File.Exists(out_Renamed.FullName)) tmpBool = true; else tmpBool = System.IO.Directory.Exists(out_Renamed.FullName); bool tmpBool2; if (System.IO.File.Exists(out_Renamed.FullName)) { System.IO.File.Delete(out_Renamed.FullName); tmpBool2 = true; } else if (System.IO.Directory.Exists(out_Renamed.FullName)) { System.IO.Directory.Delete(out_Renamed.FullName); tmpBool2 = true; } else tmpBool2 = false; if (tmpBool && !tmpBool2) { throw new System.IO.IOException("Could not reset file"); } this.out_Renamed = SupportClass.RandomAccessFileSupport.CreateRandomAccessFile(out_Renamed, "rw"); this.isSigned = isSigned; src = imgSrc; w = src.ImgWidth; h = src.ImgHeight; fb = imgSrc.getFixedPoint(c); bitDepth = src.getNomRangeBits(this.c); if ((bitDepth <= 0) || (bitDepth > 31)) { throw new System.IO.IOException("PGX supports only bit-depth between " + "1 and 31"); } if (bitDepth <= 8) { packBytes = 1; } else if (bitDepth <= 16) { packBytes = 2; } else { // <= 31 packBytes = 4; } // Writes PGX header System.String tmpString = "PG " + "ML " + ((this.isSigned)?"- ":"+ ") + bitDepth + " " + w + " " + h + "\n"; // component height byte[] tmpByte = System.Text.ASCIIEncoding.ASCII.GetBytes(tmpString); for (int i = 0; i < tmpByte.Length; i++) { this.out_Renamed.WriteByte((byte) tmpByte[i]); } offset = tmpByte.Length; maxVal = this.isSigned?((1 << (src.getNomRangeBits(c) - 1)) - 1):((1 << src.getNomRangeBits(c)) - 1); minVal = this.isSigned?((- 1) * (1 << (src.getNomRangeBits(c) - 1))):0; levShift = (this.isSigned)?0:1 << (src.getNomRangeBits(c) - 1); }
/// <summary> Implements the 'getInternCompData()' and the 'getCompData()' /// methods. The 'intern' flag signals which of the two methods should run /// as. /// /// </summary> /// <param name="blk">The data block to get. /// /// </param> /// <param name="c">The index of the component from which to get the data. /// /// </param> /// <param name="intern">If true behave as 'getInternCompData(). Otherwise behave /// as 'getCompData()' /// /// </param> /// <returns> The requested data block /// /// </returns> /// <seealso cref="getInternCompData"> /// /// </seealso> /// <seealso cref="getCompData"> /// /// </seealso> private DataBlk getData(DataBlk blk, int c, bool intern) { DataBlk reqBlk; // Reference to block used in request to source // Keep request data type int otype = blk.DataType; if (otype == srcBlk.DataType) { // Probably requested type is same as source type reqBlk = blk; } else { // Probably requested type is not the same as source type reqBlk = srcBlk; // We need to copy requested coordinates and size reqBlk.ulx = blk.ulx; reqBlk.uly = blk.uly; reqBlk.w = blk.w; reqBlk.h = blk.h; } // Get source data block if (intern) { // We can use the intern variant srcBlk = src.getInternCompData(reqBlk, c); } else { // Do not use the intern variant. Note that this is not optimal // since if we are going to convert below then we could have used // the intern variant. But there is currently no way to know if we // will need to do conversion or not before getting the data. srcBlk = src.getCompData(reqBlk, c); } // Check if casting is needed if (srcBlk.DataType == otype) { return(srcBlk); } int i; int k, kSrc, kmin; float mult; int w = srcBlk.w; int h = srcBlk.h; switch (otype) { case DataBlk.TYPE_FLOAT: // Cast INT -> FLOAT float[] farr; int[] srcIArr; // Get data array from resulting blk farr = (float[])blk.Data; if (farr == null || farr.Length < w * h) { farr = new float[w * h]; blk.Data = farr; } blk.scanw = srcBlk.w; blk.offset = 0; blk.progressive = srcBlk.progressive; srcIArr = (int[])srcBlk.Data; // Cast data from source to blk fp = src.getFixedPoint(c); if (fp != 0) { mult = 1.0f / (1 << fp); for (i = h - 1, k = w * h - 1, kSrc = srcBlk.offset + (h - 1) * srcBlk.scanw + w - 1; i >= 0; i--) { for (kmin = k - w; k > kmin; k--, kSrc--) { farr[k] = ((srcIArr[kSrc] * mult)); } // Jump to geggining of next line in source kSrc -= (srcBlk.scanw - w); } } else { for (i = h - 1, k = w * h - 1, kSrc = srcBlk.offset + (h - 1) * srcBlk.scanw + w - 1; i >= 0; i--) { for (kmin = k - w; k > kmin; k--, kSrc--) { //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" farr[k] = ((float)(srcIArr[kSrc])); } // Jump to geggining of next line in source kSrc -= (srcBlk.scanw - w); } } break; // End of cast INT-> FLOAT case DataBlk.TYPE_INT: // cast FLOAT -> INT int[] iarr; float[] srcFArr; // Get data array from resulting blk iarr = (int[])blk.Data; if (iarr == null || iarr.Length < w * h) { iarr = new int[w * h]; blk.Data = iarr; } blk.scanw = srcBlk.w; blk.offset = 0; blk.progressive = srcBlk.progressive; srcFArr = (float[])srcBlk.Data; // Cast data from source to blk if (fp != 0) { //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" mult = (float)(1 << fp); for (i = h - 1, k = w * h - 1, kSrc = srcBlk.offset + (h - 1) * srcBlk.scanw + w - 1; i >= 0; i--) { for (kmin = k - w; k > kmin; k--, kSrc--) { if (srcFArr[kSrc] > 0.0f) { //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" iarr[k] = (int)(srcFArr[kSrc] * mult + 0.5f); } else { //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" iarr[k] = (int)(srcFArr[kSrc] * mult - 0.5f); } } // Jump to geggining of next line in source kSrc -= (srcBlk.scanw - w); } } else { for (i = h - 1, k = w * h - 1, kSrc = srcBlk.offset + (h - 1) * srcBlk.scanw + w - 1; i >= 0; i--) { for (kmin = k - w; k > kmin; k--, kSrc--) { if (srcFArr[kSrc] > 0.0f) { //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" iarr[k] = (int)(srcFArr[kSrc] + 0.5f); } else { //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" iarr[k] = (int)(srcFArr[kSrc] - 0.5f); } } // Jump to geggining of next line in source kSrc -= (srcBlk.scanw - w); } } break; // End cast FLOAT -> INT default: throw new System.ArgumentException("Only integer and float data " + "are " + "supported by JJ2000"); } return(blk); }
/// <summary> Returns the position of the fixed point in the specified /// component. This is the position of the least significant integral /// (i.e. non-fractional) bit, which is equivalent to the number of /// fractional bits. For instance, for fixed-point values with 2 fractional /// bits, 2 is returned. For floating-point data this value does not apply /// and 0 should be returned. Position 0 is the position of the least /// significant bit in the data. /// /// </summary> /// <param name="c">The index of the component. /// /// </param> /// <returns> The position of the fixed-point, which is the same as the /// number of fractional bits. For floating-point data 0 is returned. /// /// </returns> public override int getFixedPoint(int c) { return(src.getFixedPoint(c)); }