CSJ2K.Icc.ICCProfiler.getCompData C# (CSharp) Метод

getCompData() публичный Метод

Returns, in the blk argument, a block of image data containing the specifed rectangular area, in the specified component. The data is returned, as a copy of the internal data, therefore the returned data can be modified "in place".

The rectangular area to return is specified by the 'ulx', 'uly', 'w' and 'h' members of the 'blk' argument, relative to the current tile. These members are not modified by this method. The 'offset' of the returned data is 0, and the 'scanw' is the same as the block's width. See the 'DataBlk' class.

If the data array in 'blk' is 'null', then a new one is created. If the data array is not 'null' then it is reused, and it must be large enough to contain the block's data. Otherwise an 'ArrayStoreException' or an 'IndexOutOfBoundsException' is thrown by the Java system.

The returned data has its 'progressive' attribute set to that of the input data.

public getCompData ( CSJ2K.j2k.image.DataBlk outblk, int c ) : CSJ2K.j2k.image.DataBlk
outblk CSJ2K.j2k.image.DataBlk
c int The index of the component from which to get the data. Only 0 /// and 3 are valid. /// ///
Результат CSJ2K.j2k.image.DataBlk
        public override DataBlk getCompData(DataBlk outblk, int c)
        {
            try
            {
                if (ncomps != 1 && ncomps != 3)
                {
                    System.String msg = "ICCProfiler: icc profile _not_ applied to " + ncomps + " component image";
                    FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, msg);
                    return src.getCompData(outblk, c);
                }

                int type = outblk.DataType;

                int leftedgeOut = - 1; // offset to the start of the output scanline
                int rightedgeOut = - 1; // offset to the end of the output
                // scanline + 1
                int leftedgeIn = - 1; // offset to the start of the input scanline
                int rightedgeIn = - 1; // offset to the end of the input
                // scanline + 1

                // Calculate all components:
                for (int i = 0; i < ncomps; ++i)
                {

                    int fixedPtBits = src.getFixedPoint(i);
                    int shiftVal = shiftValueArray[i];
                    int maxVal = maxValueArray[i];

                    // Initialize general input and output indexes
                    int kOut = - 1;
                    int kIn = - 1;

                    switch (type)
                    {

                        // Int and Float data only
                        case DataBlk.TYPE_INT:

                            // Set up the DataBlk geometry
                            copyGeometry(workInt[i], outblk);
                            copyGeometry(tempInt[i], outblk);
                            copyGeometry(inInt[i], outblk);
                            InternalBuffer = outblk;

                            // Reference the output array
                            workDataInt[i] = (int[]) workInt[i].Data;

                            // Request data from the source.
                            inInt[i] = (DataBlkInt) src.getInternCompData(inInt[i], i);
                            dataInt[i] = inInt[i].DataInt;

                            // The nitty-gritty.

                            for (int row = 0; row < outblk.h; ++row)
                            {
                                leftedgeIn = inInt[i].offset + row * inInt[i].scanw;
                                rightedgeIn = leftedgeIn + inInt[i].w;
                                leftedgeOut = outblk.offset + row * outblk.scanw;
                                rightedgeOut = leftedgeOut + outblk.w;

                                for (kOut = leftedgeOut, kIn = leftedgeIn; kIn < rightedgeIn; ++kIn, ++kOut)
                                {
                                    int tmpInt = (dataInt[i][kIn] >> fixedPtBits) + shiftVal;
                                    workDataInt[i][kOut] = ((tmpInt < 0)?0:((tmpInt > maxVal)?maxVal:tmpInt));
                                }
                            }
                            break;

                        case DataBlk.TYPE_FLOAT:

                            // Set up the DataBlk geometry
                            copyGeometry(workFloat[i], outblk);
                            copyGeometry(tempFloat[i], outblk);
                            copyGeometry(inFloat[i], outblk);
                            InternalBuffer = outblk;

                            // Reference the output array
                            workDataFloat[i] = (float[]) workFloat[i].Data;

                            // Request data from the source.
                            inFloat[i] = (DataBlkFloat) src.getInternCompData(inFloat[i], i);
                            dataFloat[i] = inFloat[i].DataFloat;

                            // The nitty-gritty.

                            for (int row = 0; row < outblk.h; ++row)
                            {
                                leftedgeIn = inFloat[i].offset + row * inFloat[i].scanw;
                                rightedgeIn = leftedgeIn + inFloat[i].w;
                                leftedgeOut = outblk.offset + row * outblk.scanw;
                                rightedgeOut = leftedgeOut + outblk.w;

                                for (kOut = leftedgeOut, kIn = leftedgeIn; kIn < rightedgeIn; ++kIn, ++kOut)
                                {
                                    float tmpFloat = dataFloat[i][kIn] / (1 << fixedPtBits) + shiftVal;
                                    workDataFloat[i][kOut] = ((tmpFloat < 0)?0:((tmpFloat > maxVal)?maxVal:tmpFloat));
                                }
                            }
                            break;

                        case DataBlk.TYPE_SHORT:
                        case DataBlk.TYPE_BYTE:
                        default:
                            // Unsupported output type.
                            throw new System.ArgumentException("Invalid source " + "datablock type");
                        }
                }

                switch (type)
                {

                    // Int and Float data only
                    case DataBlk.TYPE_INT:

                        if (ncomps == 1)
                        {
                            ((MonochromeTransformTosRGB) xform).apply(workInt[c], tempInt[c]);
                        }
                        else
                        {
                            // ncomps == 3
                            ((MatrixBasedTransformTosRGB) xform).apply(workInt, tempInt);
                        }

                        outblk.progressive = inInt[c].progressive;
                        outblk.Data = tempInt[c].Data;
                        break;

                    case DataBlk.TYPE_FLOAT:

                        if (ncomps == 1)
                        {
                            ((MonochromeTransformTosRGB) xform).apply(workFloat[c], tempFloat[c]);
                        }
                        else
                        {
                            // ncomps == 3
                            ((MatrixBasedTransformTosRGB) xform).apply(workFloat, tempFloat);
                        }

                        outblk.progressive = inFloat[c].progressive;
                        outblk.Data = tempFloat[c].Data;
                        break;

                    case DataBlk.TYPE_SHORT:
                    case DataBlk.TYPE_BYTE:
                    default:
                        // Unsupported output type.
                        throw new System.ArgumentException("invalid source datablock" + " type");
                    }

                // Initialize the output block geometry and set the profiled
                // data into the output block.
                outblk.offset = 0;
                outblk.scanw = outblk.w;
            }
            catch (MatrixBasedTransformException e)
            {
                //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.ERROR, "matrix transform problem:\n" + e.Message);
                if (pl.getParameter("debug").Equals("on"))
                {
                    SupportClass.WriteStackTrace(e);
                }
                else
                {
                    FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.ERROR, "Use '-debug' option for more details");
                }
                return null;
            }
            catch (MonochromeTransformException e)
            {
                //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.ERROR, "monochrome transform problem:\n" + e.Message);
                if (pl.getParameter("debug").Equals("on"))
                {
                    SupportClass.WriteStackTrace(e);
                }
                else
                {
                    FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.ERROR, "Use '-debug' option for more details");
                }
                return null;
            }

            return outblk;
        }