CSJ2K.j2k.image.output.ImgWriterPPM.write C# (CSharp) Method

write() public method

Writes the data of the specified area to the file, coordinates are relative to the current tile of the source. Before writing, the coefficients are limited to the nominal range.

This method may not be called concurrently from different threads.

If the data returned from the BlkImgDataSrc source is progressive, then it is requested over and over until it is not progressive anymore.

If an I/O error occurs. /// ///
public write ( int ulx, int uly, int w, int h ) : void
ulx int The horizontal coordinate of the upper-left corner of the /// area to write, relative to the current tile. /// ///
uly int The vertical coordinate of the upper-left corner of the area /// to write, relative to the current tile. /// ///
w int
h int
return void
        public override void write(int ulx, int uly, int w, int h)
        {
            int k, j, i, c;
            // In local variables for faster access
            int fracbits;
            // variables used during coeff saturation
            int shift, tmp, maxVal;
            int tOffx, tOffy; // Active tile offset in the X and Y direction

            // Active tiles in all components have same offset since they are at
            // same resolution (PPM does not support anything 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'"
            tOffx = src.getCompULX(cps[0]) - (int) System.Math.Ceiling(src.ImgULX / (double) src.getCompSubsX(cps[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'"
            tOffy = src.getCompULY(cps[0]) - (int) System.Math.Ceiling(src.ImgULY / (double) src.getCompSubsY(cps[0]));

            // Check the array size
            if (db.data_array != null && db.data_array.Length < w)
            {
                // A new one will be allocated by getInternCompData()
                db.data_array = null;
            }

            // Check the line buffer
            if (buf == null || buf.Length < 3 * w)
            {
                buf = new byte[3 * w];
            }

            // Write the data to the file
            // Write line by line
            for (i = 0; i < h; i++)
            {
                // Write into buffer first loop over the three components and
                // write for each
                for (c = 0; c < 3; c++)
                {
                    maxVal = (1 << src.getNomRangeBits(cps[c])) - 1;
                    shift = levShift[c];

                    // Initialize db
                    db.ulx = ulx;
                    db.uly = uly + i;
                    db.w = w;
                    db.h = 1;

                    // Request the data and make sure it is not progressive
                    do
                    {
                        db = (DataBlkInt) src.getInternCompData(db, cps[c]);
                    }
                    while (db.progressive);
                    // Get the fracbits value
                    fracbits = fb[c];
                    // Write all bytes in the line
                    if (fracbits == 0)
                    {
                        for (k = db.offset + w - 1, j = 3 * w - 1 + c - 2; j >= 0; k--)
                        {
                            tmp = db.data_array[k] + shift;
                            buf[j] = (byte) ((tmp < 0)?0:((tmp > maxVal)?maxVal:tmp));
                            j -= 3;
                        }
                    }
                    else
                    {
                        for (k = db.offset + w - 1, j = 3 * w - 1 + c - 2; j >= 0; k--)
                        {
                            tmp = (SupportClass.URShift(db.data_array[k], fracbits)) + shift;
                            buf[j] = (byte) ((tmp < 0)?0:((tmp > maxVal)?maxVal:tmp));
                            j -= 3;
                        }
                    }
                }
                // Write buffer into file
                out_Renamed.Seek(offset + 3 * (this.w * (uly + tOffy + i) + ulx + tOffx), System.IO.SeekOrigin.Begin);
                out_Renamed.Write(buf, 0, 3 * w);
            }
        }

Same methods

ImgWriterPPM::write ( ) : void