Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
5c07bb3a
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
5c07bb3a
编写于
4月 28, 2008
作者:
P
prr
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6679308: Poor text rendering on translucent image.
Reviewed-by: flar, campbell
上级
b1b6817e
变更
24
隐藏空白更改
内联
并排
Showing
24 changed file
with
210 addition
and
18 deletion
+210
-18
src/share/native/sun/java2d/loops/AlphaMacros.h
src/share/native/sun/java2d/loops/AlphaMacros.h
+8
-4
src/share/native/sun/java2d/loops/ByteGray.h
src/share/native/sun/java2d/loops/ByteGray.h
+2
-0
src/share/native/sun/java2d/loops/FourByteAbgr.h
src/share/native/sun/java2d/loops/FourByteAbgr.h
+2
-0
src/share/native/sun/java2d/loops/FourByteAbgrPre.h
src/share/native/sun/java2d/loops/FourByteAbgrPre.h
+2
-0
src/share/native/sun/java2d/loops/Index12Gray.h
src/share/native/sun/java2d/loops/Index12Gray.h
+2
-0
src/share/native/sun/java2d/loops/Index8Gray.h
src/share/native/sun/java2d/loops/Index8Gray.h
+2
-0
src/share/native/sun/java2d/loops/IntArgb.h
src/share/native/sun/java2d/loops/IntArgb.h
+2
-0
src/share/native/sun/java2d/loops/IntArgbBm.h
src/share/native/sun/java2d/loops/IntArgbBm.h
+2
-0
src/share/native/sun/java2d/loops/IntArgbPre.h
src/share/native/sun/java2d/loops/IntArgbPre.h
+2
-0
src/share/native/sun/java2d/loops/IntBgr.h
src/share/native/sun/java2d/loops/IntBgr.h
+2
-0
src/share/native/sun/java2d/loops/IntRgb.h
src/share/native/sun/java2d/loops/IntRgb.h
+2
-0
src/share/native/sun/java2d/loops/IntRgbx.h
src/share/native/sun/java2d/loops/IntRgbx.h
+2
-0
src/share/native/sun/java2d/loops/LoopMacros.h
src/share/native/sun/java2d/loops/LoopMacros.h
+12
-4
src/share/native/sun/java2d/loops/ThreeByteBgr.h
src/share/native/sun/java2d/loops/ThreeByteBgr.h
+2
-0
src/share/native/sun/java2d/loops/Ushort4444Argb.h
src/share/native/sun/java2d/loops/Ushort4444Argb.h
+2
-0
src/share/native/sun/java2d/loops/Ushort555Rgb.h
src/share/native/sun/java2d/loops/Ushort555Rgb.h
+2
-0
src/share/native/sun/java2d/loops/Ushort555Rgbx.h
src/share/native/sun/java2d/loops/Ushort555Rgbx.h
+2
-0
src/share/native/sun/java2d/loops/Ushort565Rgb.h
src/share/native/sun/java2d/loops/Ushort565Rgb.h
+2
-0
src/share/native/sun/java2d/loops/UshortGray.h
src/share/native/sun/java2d/loops/UshortGray.h
+2
-0
src/solaris/native/sun/java2d/loops/vis_FourByteAbgr.c
src/solaris/native/sun/java2d/loops/vis_FourByteAbgr.c
+13
-1
src/solaris/native/sun/java2d/loops/vis_FourByteAbgrPre.c
src/solaris/native/sun/java2d/loops/vis_FourByteAbgrPre.c
+29
-5
src/solaris/native/sun/java2d/loops/vis_IntArgb.c
src/solaris/native/sun/java2d/loops/vis_IntArgb.c
+8
-0
src/solaris/native/sun/java2d/loops/vis_IntArgbPre.c
src/solaris/native/sun/java2d/loops/vis_IntArgbPre.c
+0
-4
test/java/awt/Graphics2D/DrawString/AlphaSurfaceText.java
test/java/awt/Graphics2D/DrawString/AlphaSurfaceText.java
+106
-0
未找到文件。
src/share/native/sun/java2d/loops/AlphaMacros.h
浏览文件 @
5c07bb3a
...
...
@@ -416,7 +416,8 @@ void NAME_SRCOVER_MASKBLIT(SRC, DST) \
MultiplyAndStore ## STRATEGY ## Comps(res, \
srcF, res);\
} \
if (!(DST ## IsPremultiplied) && resA && \
if (!(DST ## IsOpaque) && \
!(DST ## IsPremultiplied) && resA && \
resA < MaxValFor ## STRATEGY) \
{ \
DivideAndStore ## STRATEGY ## Comps(res, \
...
...
@@ -475,7 +476,8 @@ void NAME_SRCOVER_MASKBLIT(SRC, DST) \
MultiplyAndStore ## STRATEGY ## Comps(res, \
srcF, res); \
} \
if (!(DST ## IsPremultiplied) && resA && \
if (!(DST ## IsOpaque) && \
!(DST ## IsPremultiplied) && resA && \
resA < MaxValFor ## STRATEGY) \
{ \
DivideAndStore ## STRATEGY ## Comps(res, res, resA); \
...
...
@@ -797,7 +799,8 @@ void NAME_SRCOVER_MASKFILL(TYPE) \
Store ## STRATEGY ## CompsUsingOp(res, +=, tmp); \
} \
} \
if (!(TYPE ## IsPremultiplied) && resA && \
if (!(TYPE ## IsOpaque) && \
!(TYPE ## IsPremultiplied) && resA && \
resA < MaxValFor ## STRATEGY) \
{ \
DivideAndStore ## STRATEGY ## Comps(res, res, resA); \
...
...
@@ -831,7 +834,8 @@ void NAME_SRCOVER_MASKFILL(TYPE) \
Postload ## STRATEGY ## From ## TYPE(pRas, DstPix, res); \
MultiplyAddAndStore ## STRATEGY ## Comps(res, \
dstF, res, src); \
if (!(TYPE ## IsPremultiplied) && resA && \
if (!(TYPE ## IsOpaque) && \
!(TYPE ## IsPremultiplied) && resA && \
resA < MaxValFor ## STRATEGY) \
{ \
DivideAndStore ## STRATEGY ## Comps(res, res, resA); \
...
...
src/share/native/sun/java2d/loops/ByteGray.h
浏览文件 @
5c07bb3a
...
...
@@ -36,6 +36,8 @@
typedef
jubyte
ByteGrayPixelType
;
typedef
jubyte
ByteGrayDataType
;
#define ByteGrayIsOpaque 1
#define ByteGrayPixelStride 1
#define ByteGrayBitsPerPixel 8
...
...
src/share/native/sun/java2d/loops/FourByteAbgr.h
浏览文件 @
5c07bb3a
...
...
@@ -34,6 +34,8 @@
typedef
jint
FourByteAbgrPixelType
;
typedef
jubyte
FourByteAbgrDataType
;
#define FourByteAbgrIsOpaque 0
#define FourByteAbgrPixelStride 4
#define DeclareFourByteAbgrLoadVars(PREFIX)
...
...
src/share/native/sun/java2d/loops/FourByteAbgrPre.h
浏览文件 @
5c07bb3a
...
...
@@ -34,6 +34,8 @@
typedef
jint
FourByteAbgrPrePixelType
;
typedef
jubyte
FourByteAbgrPreDataType
;
#define FourByteAbgrPreIsOpaque 0
#define FourByteAbgrPrePixelStride 4
#define DeclareFourByteAbgrPreLoadVars(PREFIX)
...
...
src/share/native/sun/java2d/loops/Index12Gray.h
浏览文件 @
5c07bb3a
...
...
@@ -37,6 +37,8 @@
typedef
jushort
Index12GrayPixelType
;
typedef
jushort
Index12GrayDataType
;
#define Index12GrayIsOpaque 1
#define Index12GrayPixelStride 2
#define Index12GrayBitsPerPixel 12
...
...
src/share/native/sun/java2d/loops/Index8Gray.h
浏览文件 @
5c07bb3a
...
...
@@ -37,6 +37,8 @@
typedef
jubyte
Index8GrayPixelType
;
typedef
jubyte
Index8GrayDataType
;
#define Index8GrayIsOpaque 1
#define Index8GrayPixelStride 1
#define Index8GrayBitsPerPixel 8
...
...
src/share/native/sun/java2d/loops/IntArgb.h
浏览文件 @
5c07bb3a
...
...
@@ -38,6 +38,8 @@
typedef
jint
IntArgbPixelType
;
typedef
jint
IntArgbDataType
;
#define IntArgbIsOpaque 0
#define IntArgbPixelStride 4
#define DeclareIntArgbLoadVars(PREFIX)
...
...
src/share/native/sun/java2d/loops/IntArgbBm.h
浏览文件 @
5c07bb3a
...
...
@@ -38,6 +38,8 @@
typedef
jint
IntArgbBmPixelType
;
typedef
jint
IntArgbBmDataType
;
#define IntArgbBmIsOpaque 0
#define IntArgbBmPixelStride 4
#define DeclareIntArgbBmLoadVars(PREFIX)
...
...
src/share/native/sun/java2d/loops/IntArgbPre.h
浏览文件 @
5c07bb3a
...
...
@@ -36,6 +36,8 @@
typedef
jint
IntArgbPrePixelType
;
typedef
jint
IntArgbPreDataType
;
#define IntArgbPreIsOpaque 0
#define IntArgbPrePixelStride 4
#define DeclareIntArgbPreLoadVars(PREFIX)
...
...
src/share/native/sun/java2d/loops/IntBgr.h
浏览文件 @
5c07bb3a
...
...
@@ -38,6 +38,8 @@
typedef
jint
IntBgrPixelType
;
typedef
jint
IntBgrDataType
;
#define IntBgrIsOpaque 1
#define IntBgrPixelStride 4
#define DeclareIntBgrLoadVars(PREFIX)
...
...
src/share/native/sun/java2d/loops/IntRgb.h
浏览文件 @
5c07bb3a
...
...
@@ -38,6 +38,8 @@
typedef
jint
IntRgbPixelType
;
typedef
jint
IntRgbDataType
;
#define IntRgbIsOpaque 1
#define IntRgbPixelStride 4
#define DeclareIntRgbLoadVars(PREFIX)
...
...
src/share/native/sun/java2d/loops/IntRgbx.h
浏览文件 @
5c07bb3a
...
...
@@ -36,6 +36,8 @@
typedef
jint
IntRgbxPixelType
;
typedef
jint
IntRgbxDataType
;
#define IntRgbxIsOpaque 1
#define IntRgbxPixelStride 4
#define DeclareIntRgbxLoadVars(PREFIX)
...
...
src/share/native/sun/java2d/loops/LoopMacros.h
浏览文件 @
5c07bb3a
...
...
@@ -1610,8 +1610,12 @@ void NAME_SOLID_DRAWGLYPHLIST(DST)(SurfaceDataRasInfo *pRasInfo, \
MUL8(SRC_PREFIX ## A, mixValSrc); \
MultMultAddAndStore4ByteArgbComps(dst, mixValDst, dst, \
mixValSrc, SRC_PREFIX); \
Store ## DST ## From4ByteArgb(DST_PTR, pix, PIXEL_INDEX, \
dstA, dstR, dstG, dstB); \
if (!(DST ## IsOpaque) && \
!(DST ## IsPremultiplied) && dstA && dstA < 255) { \
DivideAndStore4ByteArgbComps(dst, dst, dstA); \
} \
Store ## DST ## From4ByteArgbComps(DST_PTR, pix, \
PIXEL_INDEX, dst); \
} else { \
Store ## DST ## PixelData(DST_PTR, PIXEL_INDEX, \
FG_PIXEL, PREFIX); \
...
...
@@ -1793,8 +1797,12 @@ void NAME_SOLID_DRAWGLYPHLISTAA(DST)(SurfaceDataRasInfo *pRasInfo, \
dstR = gammaLut[dstR]; \
dstG = gammaLut[dstG]; \
dstB = gammaLut[dstB]; \
Store ## DST ## From4ByteArgb(DST_PTR, pix, PIXEL_INDEX, \
dstA, dstR, dstG, dstB); \
if (!(DST ## IsOpaque) && \
!(DST ## IsPremultiplied) && dstA && dstA < 255) { \
DivideAndStore4ByteArgbComps(dst, dst, dstA); \
} \
Store ## DST ## From4ByteArgbComps(DST_PTR, pix, \
PIXEL_INDEX, dst); \
} else { \
Store ## DST ## PixelData(DST_PTR, PIXEL_INDEX, \
FG_PIXEL, PREFIX); \
...
...
src/share/native/sun/java2d/loops/ThreeByteBgr.h
浏览文件 @
5c07bb3a
...
...
@@ -34,6 +34,8 @@
typedef
jint
ThreeByteBgrPixelType
;
typedef
jubyte
ThreeByteBgrDataType
;
#define ThreeByteBgrIsOpaque 1
#define ThreeByteBgrPixelStride 3
#define DeclareThreeByteBgrLoadVars(PREFIX)
...
...
src/share/native/sun/java2d/loops/Ushort4444Argb.h
浏览文件 @
5c07bb3a
...
...
@@ -34,6 +34,8 @@
typedef
jushort
Ushort4444ArgbPixelType
;
typedef
jushort
Ushort4444ArgbDataType
;
#define Ushort4444ArgbIsOpaque 0
#define Ushort4444ArgbPixelStride 2
#define DeclareUshort4444ArgbLoadVars(PREFIX)
...
...
src/share/native/sun/java2d/loops/Ushort555Rgb.h
浏览文件 @
5c07bb3a
...
...
@@ -34,6 +34,8 @@
typedef
jushort
Ushort555RgbPixelType
;
typedef
jushort
Ushort555RgbDataType
;
#define Ushort555RgbIsOpaque 1
#define Ushort555RgbPixelStride 2
#define DeclareUshort555RgbLoadVars(PREFIX)
...
...
src/share/native/sun/java2d/loops/Ushort555Rgbx.h
浏览文件 @
5c07bb3a
...
...
@@ -34,6 +34,8 @@
typedef
jushort
Ushort555RgbxPixelType
;
typedef
jushort
Ushort555RgbxDataType
;
#define Ushort555RgbxIsOpaque 1
#define Ushort555RgbxPixelStride 2
#define DeclareUshort555RgbxLoadVars(PREFIX)
...
...
src/share/native/sun/java2d/loops/Ushort565Rgb.h
浏览文件 @
5c07bb3a
...
...
@@ -34,6 +34,8 @@
typedef
jushort
Ushort565RgbPixelType
;
typedef
jushort
Ushort565RgbDataType
;
#define Ushort565RgbIsOpaque 1
#define Ushort565RgbPixelStride 2
#define DeclareUshort565RgbLoadVars(PREFIX)
...
...
src/share/native/sun/java2d/loops/UshortGray.h
浏览文件 @
5c07bb3a
...
...
@@ -36,6 +36,8 @@
typedef
jushort
UshortGrayPixelType
;
typedef
jushort
UshortGrayDataType
;
#define UshortGrayIsOpaque 1
#define UshortGrayPixelStride 2
#define UshortGrayBitsPerPixel 16
...
...
src/solaris/native/sun/java2d/loops/vis_FourByteAbgr.c
浏览文件 @
5c07bb3a
...
...
@@ -1936,6 +1936,7 @@ void ADD_SUFF(FourByteAbgrDrawGlyphListAA)(SurfaceDataRasInfo * pRasInfo,
for
(
j
=
0
;
j
<
height
;
j
++
)
{
mlib_u8
*
src
=
(
void
*
)
pixels
;
mlib_s32
*
dst
,
*
dst_end
;
mlib_u8
*
dst_start
;
if
((
mlib_s32
)
dstBase
&
3
)
{
COPY_NA
(
dstBase
,
pbuff
,
width
*
sizeof
(
mlib_s32
));
...
...
@@ -1943,8 +1944,14 @@ void ADD_SUFF(FourByteAbgrDrawGlyphListAA)(SurfaceDataRasInfo * pRasInfo,
}
else
{
dst
=
(
void
*
)
dstBase
;
}
dst_start
=
(
void
*
)
dst
;
dst_end
=
dst
+
width
;
/* Need to reset the GSR from the values set by the
* convert call near the end of this loop.
*/
vis_write_gsr
(
7
<<
0
);
if
((
mlib_s32
)
dst
&
7
)
{
pix
=
*
src
++
;
dd
=
vis_fpadd16
(
MUL8_VIS
(
srcG_f
,
pix
),
d_half
);
...
...
@@ -1984,8 +1991,13 @@ void ADD_SUFF(FourByteAbgrDrawGlyphListAA)(SurfaceDataRasInfo * pRasInfo,
dst
++
;
}
ADD_SUFF
(
IntArgbPreToIntArgbConvert
)(
dst_start
,
dst_start
,
width
,
1
,
pRasInfo
,
pRasInfo
,
pPrim
,
pCompInfo
);
if
((
mlib_s32
)
dstBase
&
3
)
{
COPY_NA
(
pbuff
,
dstBase
,
width
*
sizeof
(
mlib_s32
));
COPY_NA
(
dst_start
,
dstBase
,
width
*
sizeof
(
mlib_s32
));
}
PTR_ADD
(
dstBase
,
scan
);
...
...
src/solaris/native/sun/java2d/loops/vis_FourByteAbgrPre.c
浏览文件 @
5c07bb3a
...
...
@@ -181,6 +181,7 @@ void ADD_SUFF(FourByteAbgrPreDrawGlyphListAA)(SurfaceDataRasInfo * pRasInfo,
d_half
=
vis_to_double_dup
((
1
<<
(
16
+
6
))
|
(
1
<<
6
));
srcG_f
=
vis_to_float
(
argbcolor
);
ARGB2ABGR_FL
(
srcG_f
);
for
(
glyphCounter
=
0
;
glyphCounter
<
totalGlyphs
;
glyphCounter
++
)
{
const
jubyte
*
pixels
;
...
...
@@ -238,8 +239,33 @@ void ADD_SUFF(FourByteAbgrPreDrawGlyphListAA)(SurfaceDataRasInfo * pRasInfo,
mlib_u8
*
src
=
(
void
*
)
pixels
;
mlib_s32
*
dst
,
*
dst_end
;
mlib_u8
*
dst8
;
ADD_SUFF
(
FourByteAbgrPreToIntArgbConvert
)(
dstBase
,
pbuff
,
width
,
1
,
mlib_u8
*
dst_start
=
dstBase
;
/*
* Typically the inner loop here works on Argb input data, an
* Argb color, and produces ArgbPre output data. To use that
* standard approach we would need a FourByteAbgrPre to IntArgb
* converter for the front end and an IntArgbPre to FourByteAbgrPre
* converter for the back end. The converter exists for the
* front end, but it is a workaround implementation that uses a 2
* stage conversion and an intermediate buffer that is allocated
* on every call. The converter for the back end doesn't really
* exist, but we could reuse the IntArgb to FourByteAbgr converter
* to do the same work - at the cost of swapping the components as
* we copy the data back. All of this is more work than we really
* need so we use an alternate procedure:
* - Copy the data into an int-aligned temporary buffer (if needed)
* - Convert the data from FourByteAbgrPre to IntAbgr by using the
* IntArgbPre to IntArgb converter in the int-aligned buffer.
* - Swap the color data to Abgr so that the inner loop goes from
* IntAbgr data to IntAbgrPre data
* - Simply copy the IntAbgrPre data back into place.
*/
if
(((
mlib_s32
)
dstBase
)
&
3
)
{
COPY_NA
(
dstBase
,
pbuff
,
width
*
sizeof
(
mlib_s32
));
dst_start
=
pbuff
;
}
ADD_SUFF
(
IntArgbPreToIntArgbConvert
)(
dst_start
,
pbuff
,
width
,
1
,
pRasInfo
,
pRasInfo
,
pPrim
,
pCompInfo
);
...
...
@@ -283,9 +309,7 @@ void ADD_SUFF(FourByteAbgrPreDrawGlyphListAA)(SurfaceDataRasInfo * pRasInfo,
dst
++
;
}
ADD_SUFF
(
IntArgbToFourByteAbgrPreConvert
)(
pbuff
,
dstBase
,
width
,
1
,
pRasInfo
,
pRasInfo
,
pPrim
,
pCompInfo
);
COPY_NA
(
pbuff
,
dstBase
,
width
*
sizeof
(
mlib_s32
));
src
=
(
void
*
)
pixels
;
dst8
=
(
void
*
)
dstBase
;
...
...
src/solaris/native/sun/java2d/loops/vis_IntArgb.c
浏览文件 @
5c07bb3a
...
...
@@ -428,6 +428,11 @@ void ADD_SUFF(IntArgbDrawGlyphListAA)(GLYPH_LIST_PARAMS)
dst
=
(
void
*
)
dstBase
;
dst_end
=
dst
+
width
;
/* Clearing the Graphics Status Register is necessary otherwise
* left over scale settings affect the pack instructions.
*/
vis_write_gsr
(
0
<<
3
);
if
((
mlib_s32
)
dst
&
7
)
{
pix
=
*
src
++
;
dd
=
vis_fpadd16
(
MUL8_VIS
(
srcG_f
,
pix
),
d_half
);
...
...
@@ -467,6 +472,9 @@ void ADD_SUFF(IntArgbDrawGlyphListAA)(GLYPH_LIST_PARAMS)
dst
++
;
}
ADD_SUFF
(
IntArgbPreToIntArgbConvert
)(
dstBase
,
dstBase
,
width
,
1
,
pRasInfo
,
pRasInfo
,
pPrim
,
pCompInfo
);
PTR_ADD
(
dstBase
,
scan
);
pixels
+=
rowBytes
;
}
...
...
src/solaris/native/sun/java2d/loops/vis_IntArgbPre.c
浏览文件 @
5c07bb3a
...
...
@@ -1193,10 +1193,6 @@ void ADD_SUFF(IntArgbPreDrawGlyphListAA)(SurfaceDataRasInfo * pRasInfo,
dst
++
;
}
ADD_SUFF
(
IntArgbToIntArgbPreConvert
)(
dstBase
,
dstBase
,
width
,
1
,
pRasInfo
,
pRasInfo
,
pPrim
,
pCompInfo
);
PTR_ADD
(
dstBase
,
scan
);
pixels
+=
rowBytes
;
}
...
...
test/java/awt/Graphics2D/DrawString/AlphaSurfaceText.java
0 → 100644
浏览文件 @
5c07bb3a
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/**
* @test
* @bug 6679308
* @summary test drawing to Alpha surfaces
*/
import
java.awt.*
;
import
java.awt.image.*
;
public
class
AlphaSurfaceText
{
int
wid
=
400
,
hgt
=
200
;
public
AlphaSurfaceText
(
int
biType
,
Color
c
)
{
BufferedImage
opaquebi0
=
new
BufferedImage
(
wid
,
hgt
,
BufferedImage
.
TYPE_INT_RGB
);
drawText
(
opaquebi0
,
c
);
BufferedImage
alphabi
=
new
BufferedImage
(
wid
,
hgt
,
biType
);
drawText
(
alphabi
,
c
);
BufferedImage
opaquebi1
=
new
BufferedImage
(
wid
,
hgt
,
BufferedImage
.
TYPE_INT_RGB
);
Graphics2D
g2d
=
opaquebi1
.
createGraphics
();
g2d
.
drawImage
(
alphabi
,
0
,
0
,
null
);
compare
(
opaquebi0
,
opaquebi1
,
biType
,
c
);
}
private
void
drawText
(
BufferedImage
bi
,
Color
c
)
{
Graphics2D
g
=
bi
.
createGraphics
();
g
.
setRenderingHint
(
RenderingHints
.
KEY_TEXT_ANTIALIASING
,
RenderingHints
.
VALUE_TEXT_ANTIALIAS_ON
);
g
.
setColor
(
c
);
g
.
setFont
(
new
Font
(
"sansserif"
,
Font
.
PLAIN
,
70
));
g
.
drawString
(
"Hello!"
,
20
,
100
);
g
.
setFont
(
new
Font
(
"sansserif"
,
Font
.
PLAIN
,
12
));
g
.
drawString
(
"Hello!"
,
20
,
130
);
g
.
setFont
(
new
Font
(
"sansserif"
,
Font
.
PLAIN
,
10
));
g
.
drawString
(
"Hello!"
,
20
,
150
);
}
// Need to allow for minimal rounding error, so allow each component
// to differ by 1.
void
compare
(
BufferedImage
bi0
,
BufferedImage
bi1
,
int
biType
,
Color
c
)
{
for
(
int
x
=
0
;
x
<
wid
;
x
++)
{
for
(
int
y
=
0
;
y
<
hgt
;
y
++)
{
int
rgb0
=
bi0
.
getRGB
(
x
,
y
);
int
rgb1
=
bi1
.
getRGB
(
x
,
y
);
if
(
rgb0
==
rgb1
)
continue
;
int
r0
=
(
rgb0
&
0xff0000
)
>>
16
;
int
r1
=
(
rgb1
&
0xff0000
)
>>
16
;
int
rdiff
=
r0
-
r1
;
if
(
rdiff
<
0
)
rdiff
=
-
rdiff
;
int
g0
=
(
rgb0
&
0x00ff00
)
>>
8
;
int
g1
=
(
rgb1
&
0x00ff00
)
>>
8
;
int
gdiff
=
g0
-
g1
;
if
(
gdiff
<
0
)
gdiff
=
-
gdiff
;
int
b0
=
(
rgb0
&
0x0000ff
);
int
b1
=
(
rgb1
&
0x0000ff
);
int
bdiff
=
b0
-
b1
;
if
(
bdiff
<
0
)
bdiff
=
-
bdiff
;
if
(
rdiff
>
1
||
gdiff
>
1
||
bdiff
>
1
)
{
throw
new
RuntimeException
(
"Images differ for type "
+
biType
+
" col="
+
c
+
" at x="
+
x
+
" y="
+
y
+
" "
+
Integer
.
toHexString
(
rgb0
)
+
" vs "
+
Integer
.
toHexString
(
rgb1
));
}
}
}
}
public
static
void
main
(
String
[]
args
)
{
new
AlphaSurfaceText
(
BufferedImage
.
TYPE_INT_ARGB
,
Color
.
white
);
new
AlphaSurfaceText
(
BufferedImage
.
TYPE_INT_ARGB
,
Color
.
red
);
new
AlphaSurfaceText
(
BufferedImage
.
TYPE_INT_ARGB
,
Color
.
blue
);
new
AlphaSurfaceText
(
BufferedImage
.
TYPE_INT_ARGB_PRE
,
Color
.
white
);
new
AlphaSurfaceText
(
BufferedImage
.
TYPE_INT_ARGB_PRE
,
Color
.
red
);
new
AlphaSurfaceText
(
BufferedImage
.
TYPE_INT_ARGB_PRE
,
Color
.
blue
);
new
AlphaSurfaceText
(
BufferedImage
.
TYPE_4BYTE_ABGR
,
Color
.
white
);
new
AlphaSurfaceText
(
BufferedImage
.
TYPE_4BYTE_ABGR
,
Color
.
red
);
new
AlphaSurfaceText
(
BufferedImage
.
TYPE_4BYTE_ABGR
,
Color
.
blue
);
new
AlphaSurfaceText
(
BufferedImage
.
TYPE_4BYTE_ABGR_PRE
,
Color
.
white
);
new
AlphaSurfaceText
(
BufferedImage
.
TYPE_4BYTE_ABGR_PRE
,
Color
.
red
);
new
AlphaSurfaceText
(
BufferedImage
.
TYPE_4BYTE_ABGR_PRE
,
Color
.
blue
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录