📄 iccprofiler.java
字号:
case DataBlk.TYPE_INT: // Set up the DataBlk geometry copyGeometry (workInt[i], outblk); copyGeometry (tempInt[i], outblk); copyGeometry (inInt[i], outblk); setInternalBuffer (outblk); // Reference the output array workDataInt[i] = (int[])workInt[i].getData(); // Request data from the source. inInt[i] = (DataBlkInt) src.getInternCompData(inInt[i], i); dataInt[i] = inInt[i].getDataInt(); // 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); setInternalBuffer (outblk); // Reference the output array workDataFloat[i] = (float[])workFloat[i].getData(); // Request data from the source. inFloat[i] = (DataBlkFloat) src.getInternCompData(inFloat[i], i); dataFloat[i] = inFloat[i].getDataFloat(); // 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 IllegalArgumentException ("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.setData(tempInt[c].getData()); 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.setData(tempFloat[c].getData()); break; case DataBlk.TYPE_SHORT: case DataBlk.TYPE_BYTE: default: // Unsupported output type. throw new IllegalArgumentException ("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) { FacilityManager.getMsgLogger(). printmsg(MsgLogger.ERROR,"matrix transform problem:\n"+ e.getMessage()); if(pl.getParameter("debug").equals("on")) { e.printStackTrace(); } else { FacilityManager.getMsgLogger(). printmsg(MsgLogger.ERROR, "Use '-debug' option for more details"); } return null; } catch (MonochromeTransformException e) { FacilityManager.getMsgLogger(). printmsg(MsgLogger.ERROR, "monochrome transform problem:\n"+e.getMessage()); if(pl.getParameter("debug").equals("on")) { e.printStackTrace(); } else { FacilityManager.getMsgLogger(). printmsg(MsgLogger.ERROR, "Use '-debug' option for more details"); } return null; } return outblk; } /** * 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 reference to the internal data, if any, instead of as a * copy, therefore the returned data should not be modified. * * <P>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' and * 'scanw' of the returned data can be arbitrary. See the 'DataBlk' class. * * <P>This method, in general, is more efficient than the 'getCompData()' * method since it may not copy the data. However if the array of returned * data is to be modified by the caller then the other method is probably * preferable. * * <P>If possible, the data in the returned 'DataBlk' should be the * internal data itself, instead of a copy, in order to increase the data * transfer efficiency. However, this depends on the particular * implementation (it may be more convenient to just return a copy of the * data). This is the reason why the returned data should not be modified. * * <P>If the data array in <tt>blk</tt> is <tt>null</tt>, then a new one * is created if necessary. The implementation of this interface may * choose to return the same array or a new one, depending on what is more * efficient. Therefore, the data array in <tt>blk</tt> prior to the * method call should not be considered to contain the returned data, a * new array may have been created. Instead, get the array from * <tt>blk</tt> after the method has returned. * * <P>The returned data may have its 'progressive' attribute set. In this * case the returned data is only an approximation of the "final" data. * * @param blk Its coordinates and dimensions specify the area to return, * relative to the current tile. Some fields in this object are modified * to return the data. * * @param c The index of the component from which to get the data. * * @return The requested DataBlk * * @see #getCompData **/ public DataBlk getInternCompData(DataBlk out, int c) { return getCompData(out, c); } /** Return a suitable String representation of the class instance. */ public String toString () { StringBuffer rep = new StringBuffer ("[ICCProfiler:"); StringBuffer body = new StringBuffer (); if(icc!=null) body.append(eol).append(ColorSpace.indent(" ", icc.toString())); if(xform!=null) body.append(eol).append(ColorSpace.indent(" ", xform.toString())); rep.append(ColorSpace.indent(" ", body)); return rep.append("]").toString(); } /* end class ICCProfiler */ }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -