本文整理汇总了Java中sun.awt.SunHints.INTVAL_RENDER_QUALITY属性的典型用法代码示例。如果您正苦于以下问题:Java SunHints.INTVAL_RENDER_QUALITY属性的具体用法?Java SunHints.INTVAL_RENDER_QUALITY怎么用?Java SunHints.INTVAL_RENDER_QUALITY使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类sun.awt.SunHints
的用法示例。
在下文中一共展示了SunHints.INTVAL_RENDER_QUALITY属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTransformColorModel
private ColorModel getTransformColorModel(SunGraphics2D sg,
BufferedImage bImg,
AffineTransform tx) {
ColorModel cm = bImg.getColorModel();
ColorModel dstCM = cm;
if (tx.isIdentity()) {
return dstCM;
}
int type = tx.getType();
boolean needTrans =
((type & (AffineTransform.TYPE_MASK_ROTATION |
AffineTransform.TYPE_GENERAL_TRANSFORM)) != 0);
if (! needTrans &&
type != AffineTransform.TYPE_TRANSLATION &&
type != AffineTransform.TYPE_IDENTITY)
{
double[] mtx = new double[4];
tx.getMatrix(mtx);
// Check out the matrix. A non-integral scale will force ARGB
// since the edge conditions cannot be guaranteed.
needTrans = (mtx[0] != (int)mtx[0] || mtx[3] != (int)mtx[3]);
}
if (sg.renderHint != SunHints.INTVAL_RENDER_QUALITY) {
if (cm instanceof IndexColorModel) {
Raster raster = bImg.getRaster();
IndexColorModel icm = (IndexColorModel) cm;
// Just need to make sure that we have a transparent pixel
if (needTrans && cm.getTransparency() == Transparency.OPAQUE) {
// Fix 4221407
if (raster instanceof sun.awt.image.BytePackedRaster) {
dstCM = ColorModel.getRGBdefault();
}
else {
double[] matrix = new double[6];
tx.getMatrix(matrix);
if (matrix[1] == 0. && matrix[2] ==0.
&& matrix[4] == 0. && matrix[5] == 0.) {
// Only scaling so do not need to create
}
else {
int mapSize = icm.getMapSize();
if (mapSize < 256) {
int[] cmap = new int[mapSize+1];
icm.getRGBs(cmap);
cmap[mapSize] = 0x0000;
dstCM = new
IndexColorModel(icm.getPixelSize(),
mapSize+1,
cmap, 0, true, mapSize,
DataBuffer.TYPE_BYTE);
}
else {
dstCM = ColorModel.getRGBdefault();
}
} /* if (matrix[0] < 1.f ...) */
} /* raster instanceof sun.awt.image.BytePackedRaster */
} /* if (cm.getTransparency() == cm.OPAQUE) */
} /* if (cm instanceof IndexColorModel) */
else if (needTrans && cm.getTransparency() == Transparency.OPAQUE) {
// Need a bitmask transparency
// REMIND: for now, use full transparency since no loops
// for bitmask
dstCM = ColorModel.getRGBdefault();
}
} /* if (sg.renderHint == RENDER_QUALITY) */
else {
if (cm instanceof IndexColorModel ||
(needTrans && cm.getTransparency() == Transparency.OPAQUE))
{
// Need a bitmask transparency
// REMIND: for now, use full transparency since no loops
// for bitmask
dstCM = ColorModel.getRGBdefault();
}
}
return dstCM;
}
示例2: getTransformColorModel
private ColorModel getTransformColorModel(SunGraphics2D sg,
BufferedImage bImg,
AffineTransform tx) {
ColorModel cm = bImg.getColorModel();
ColorModel dstCM = cm;
if (tx.isIdentity()) {
return dstCM;
}
int type = tx.getType();
boolean needTrans =
((type&(tx.TYPE_MASK_ROTATION|tx.TYPE_GENERAL_TRANSFORM)) != 0);
if (! needTrans && type != tx.TYPE_TRANSLATION && type != tx.TYPE_IDENTITY)
{
double[] mtx = new double[4];
tx.getMatrix(mtx);
// Check out the matrix. A non-integral scale will force ARGB
// since the edge conditions cannot be guaranteed.
needTrans = (mtx[0] != (int)mtx[0] || mtx[3] != (int)mtx[3]);
}
if (sg.renderHint != SunHints.INTVAL_RENDER_QUALITY) {
if (cm instanceof IndexColorModel) {
Raster raster = bImg.getRaster();
IndexColorModel icm = (IndexColorModel) cm;
// Just need to make sure that we have a transparent pixel
if (needTrans && cm.getTransparency() == cm.OPAQUE) {
// Fix 4221407
if (raster instanceof sun.awt.image.BytePackedRaster) {
dstCM = ColorModel.getRGBdefault();
}
else {
double[] matrix = new double[6];
tx.getMatrix(matrix);
if (matrix[1] == 0. && matrix[2] ==0.
&& matrix[4] == 0. && matrix[5] == 0.) {
// Only scaling so do not need to create
}
else {
int mapSize = icm.getMapSize();
if (mapSize < 256) {
int[] cmap = new int[mapSize+1];
icm.getRGBs(cmap);
cmap[mapSize] = 0x0000;
dstCM = new
IndexColorModel(icm.getPixelSize(),
mapSize+1,
cmap, 0, true, mapSize,
DataBuffer.TYPE_BYTE);
}
else {
dstCM = ColorModel.getRGBdefault();
}
} /* if (matrix[0] < 1.f ...) */
} /* raster instanceof sun.awt.image.BytePackedRaster */
} /* if (cm.getTransparency() == cm.OPAQUE) */
} /* if (cm instanceof IndexColorModel) */
else if (needTrans && cm.getTransparency() == cm.OPAQUE) {
// Need a bitmask transparency
// REMIND: for now, use full transparency since no loops
// for bitmask
dstCM = ColorModel.getRGBdefault();
}
} /* if (sg.renderHint == RENDER_QUALITY) */
else {
if (cm instanceof IndexColorModel ||
(needTrans && cm.getTransparency() == cm.OPAQUE))
{
// Need a bitmask transparency
// REMIND: for now, use full transparency since no loops
// for bitmask
dstCM = ColorModel.getRGBdefault();
}
}
return dstCM;
}