您的位置:首页 > 其它

通过图片镜像drawString多国语言

2007-02-28 18:59 281 查看
public static void drawImageFont(Graphics g, Image imgnum, byte[] str,
int sx, int sy, int effect, int fontSizeX, int fontSizeY) {
if (str == null)
return;

int i = 0;
int j = 0;
int nX, nY;
Image fontImg = null;
fontImg = imgnum;
for (i = 0; i < str.length; i++) {
nX = 0;
nY = 0;
if (str[i] < 0) {
nX = 256;
nY = -1;
}
setClipImage(g, sx + i * (fontSizeX), sy, fontImg,
((str[i] + nX - 32) % 32) * fontSizeX,
(nY + ((str[i] + nX - 32) >> 5)) * fontSizeY, fontSizeX,
fontSizeY);
}
}
public static void setClipImage(Graphics g, int _i, int _j, Image image,
int _k, int _l, int _i1, int _j1) {
int clipX = g.getClipX();
int clipY = g.getClipY();
int clipWidth = g.getClipWidth();
int clipHeight = g.getClipHeight();
g.setClip(_i, _j, _i1, _j1);
g.drawImage(image, _i - _k, _j - _l, Graphics.LEFT | Graphics.TOP);
g.setClip(0, 0, WIDTH, HEIGHT);
g.setClip(clipX, clipY, clipWidth, clipHeight);
}

//****************************************************************使用
drawImageFont(_g, Constants.imgchangenum, "back"
.getBytes(), 2, 198, 0, FONT_DEFAULT_X_SIZE,
FONT_DEFAULT_Y_SIZE);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: