下面列出了怎么用sun.awt.image.BufImgSurfaceData的API类实例代码及写法,或者点击链接到github查看源代码。
protected static SurfaceData convertFrom(Blit ob, SurfaceData srcData,
int srcX, int srcY, int w, int h,
SurfaceData dstData, int type)
{
if (dstData != null) {
Rectangle r = dstData.getBounds();
if (w > r.width || h > r.height) {
dstData = null;
}
}
if (dstData == null) {
BufferedImage dstBI = new BufferedImage(w, h, type);
dstData = BufImgSurfaceData.createData(dstBI);
}
ob.Blit(srcData, dstData, AlphaComposite.Src, null,
srcX, srcY, 0, 0, w, h);
return dstData;
}
public void MaskFill(SunGraphics2D sg2d,
SurfaceData sData,
Composite comp,
int x, int y, int w, int h,
byte mask[], int offset, int scan)
{
BufferedImage dstBI =
new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
SurfaceData tmpData = BufImgSurfaceData.createData(dstBI);
// REMIND: This is not pretty. It would be nicer if we
// passed a "FillData" object to the Pixel loops, instead
// of a SunGraphics2D parameter...
Region clip = sg2d.clipRegion;
sg2d.clipRegion = null;
int pixel = sg2d.pixel;
sg2d.pixel = tmpData.pixelFor(sg2d.getColor());
fillop.FillRect(sg2d, tmpData, 0, 0, w, h);
sg2d.pixel = pixel;
sg2d.clipRegion = clip;
maskop.MaskBlit(tmpData, sData, comp, null,
0, 0, x, y, w, h,
mask, offset, scan);
}
protected static SurfaceData convertFrom(Blit ob, SurfaceData srcData,
int srcX, int srcY, int w, int h,
SurfaceData dstData, int type)
{
if (dstData != null) {
Rectangle r = dstData.getBounds();
if (w > r.width || h > r.height) {
dstData = null;
}
}
if (dstData == null) {
BufferedImage dstBI = new BufferedImage(w, h, type);
dstData = BufImgSurfaceData.createData(dstBI);
}
ob.Blit(srcData, dstData, AlphaComposite.Src, null,
srcX, srcY, 0, 0, w, h);
return dstData;
}
public void MaskFill(SunGraphics2D sg2d,
SurfaceData sData,
Composite comp,
int x, int y, int w, int h,
byte mask[], int offset, int scan)
{
BufferedImage dstBI =
new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
SurfaceData tmpData = BufImgSurfaceData.createData(dstBI);
// REMIND: This is not pretty. It would be nicer if we
// passed a "FillData" object to the Pixel loops, instead
// of a SunGraphics2D parameter...
Region clip = sg2d.clipRegion;
sg2d.clipRegion = null;
int pixel = sg2d.pixel;
sg2d.pixel = tmpData.pixelFor(sg2d.getColor());
fillop.FillRect(sg2d, tmpData, 0, 0, w, h);
sg2d.pixel = pixel;
sg2d.clipRegion = clip;
maskop.MaskBlit(tmpData, sData, comp, null,
0, 0, x, y, w, h,
mask, offset, scan);
}
protected static SurfaceData convertFrom(Blit ob, SurfaceData srcData,
int srcX, int srcY, int w, int h,
SurfaceData dstData, int type)
{
if (dstData != null) {
Rectangle r = dstData.getBounds();
if (w > r.width || h > r.height) {
dstData = null;
}
}
if (dstData == null) {
BufferedImage dstBI = new BufferedImage(w, h, type);
dstData = BufImgSurfaceData.createData(dstBI);
}
ob.Blit(srcData, dstData, AlphaComposite.Src, null,
srcX, srcY, 0, 0, w, h);
return dstData;
}
public void MaskFill(SunGraphics2D sg2d,
SurfaceData sData,
Composite comp,
int x, int y, int w, int h,
byte mask[], int offset, int scan)
{
BufferedImage dstBI =
new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
SurfaceData tmpData = BufImgSurfaceData.createData(dstBI);
// REMIND: This is not pretty. It would be nicer if we
// passed a "FillData" object to the Pixel loops, instead
// of a SunGraphics2D parameter...
Region clip = sg2d.clipRegion;
sg2d.clipRegion = null;
int pixel = sg2d.pixel;
sg2d.pixel = tmpData.pixelFor(sg2d.getColor());
fillop.FillRect(sg2d, tmpData, 0, 0, w, h);
sg2d.pixel = pixel;
sg2d.clipRegion = clip;
maskop.MaskBlit(tmpData, sData, comp, null,
0, 0, x, y, w, h,
mask, offset, scan);
}
protected static SurfaceData convertFrom(Blit ob, SurfaceData srcData,
int srcX, int srcY, int w, int h,
SurfaceData dstData, int type)
{
if (dstData != null) {
Rectangle r = dstData.getBounds();
if (w > r.width || h > r.height) {
dstData = null;
}
}
if (dstData == null) {
BufferedImage dstBI = new BufferedImage(w, h, type);
dstData = BufImgSurfaceData.createData(dstBI);
}
ob.Blit(srcData, dstData, AlphaComposite.Src, null,
srcX, srcY, 0, 0, w, h);
return dstData;
}
public void MaskFill(SunGraphics2D sg2d,
SurfaceData sData,
Composite comp,
int x, int y, int w, int h,
byte mask[], int offset, int scan)
{
BufferedImage dstBI =
new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
SurfaceData tmpData = BufImgSurfaceData.createData(dstBI);
// REMIND: This is not pretty. It would be nicer if we
// passed a "FillData" object to the Pixel loops, instead
// of a SunGraphics2D parameter...
Region clip = sg2d.clipRegion;
sg2d.clipRegion = null;
int pixel = sg2d.pixel;
sg2d.pixel = tmpData.pixelFor(sg2d.getColor());
fillop.FillRect(sg2d, tmpData, 0, 0, w, h);
sg2d.pixel = pixel;
sg2d.clipRegion = clip;
maskop.MaskBlit(tmpData, sData, comp, null,
0, 0, x, y, w, h,
mask, offset, scan);
}
protected static SurfaceData convertFrom(Blit ob, SurfaceData srcData,
int srcX, int srcY, int w, int h,
SurfaceData dstData, int type)
{
if (dstData != null) {
Rectangle r = dstData.getBounds();
if (w > r.width || h > r.height) {
dstData = null;
}
}
if (dstData == null) {
BufferedImage dstBI = new BufferedImage(w, h, type);
dstData = BufImgSurfaceData.createData(dstBI);
}
ob.Blit(srcData, dstData, AlphaComposite.Src, null,
srcX, srcY, 0, 0, w, h);
return dstData;
}
public void MaskFill(SunGraphics2D sg2d,
SurfaceData sData,
Composite comp,
int x, int y, int w, int h,
byte mask[], int offset, int scan)
{
BufferedImage dstBI =
new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
SurfaceData tmpData = BufImgSurfaceData.createData(dstBI);
// REMIND: This is not pretty. It would be nicer if we
// passed a "FillData" object to the Pixel loops, instead
// of a SunGraphics2D parameter...
Region clip = sg2d.clipRegion;
sg2d.clipRegion = null;
int pixel = sg2d.pixel;
sg2d.pixel = tmpData.pixelFor(sg2d.getColor());
fillop.FillRect(sg2d, tmpData, 0, 0, w, h);
sg2d.pixel = pixel;
sg2d.clipRegion = clip;
maskop.MaskBlit(tmpData, sData, comp, null,
0, 0, x, y, w, h,
mask, offset, scan);
}
protected static SurfaceData convertFrom(Blit ob, SurfaceData srcData,
int srcX, int srcY, int w, int h,
SurfaceData dstData, int type)
{
if (dstData != null) {
Rectangle r = dstData.getBounds();
if (w > r.width || h > r.height) {
dstData = null;
}
}
if (dstData == null) {
BufferedImage dstBI = new BufferedImage(w, h, type);
dstData = BufImgSurfaceData.createData(dstBI);
}
ob.Blit(srcData, dstData, AlphaComposite.Src, null,
srcX, srcY, 0, 0, w, h);
return dstData;
}
public void MaskFill(SunGraphics2D sg2d,
SurfaceData sData,
Composite comp,
int x, int y, int w, int h,
byte[] mask, int offset, int scan)
{
BufferedImage dstBI =
new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
SurfaceData tmpData = BufImgSurfaceData.createData(dstBI);
// REMIND: This is not pretty. It would be nicer if we
// passed a "FillData" object to the Pixel loops, instead
// of a SunGraphics2D parameter...
Region clip = sg2d.clipRegion;
sg2d.clipRegion = null;
int pixel = sg2d.pixel;
sg2d.pixel = tmpData.pixelFor(sg2d.getColor());
fillop.FillRect(sg2d, tmpData, 0, 0, w, h);
sg2d.pixel = pixel;
sg2d.clipRegion = clip;
maskop.MaskBlit(tmpData, sData, comp, null,
0, 0, x, y, w, h,
mask, offset, scan);
}
protected static SurfaceData convertFrom(Blit ob, SurfaceData srcData,
int srcX, int srcY, int w, int h,
SurfaceData dstData, int type)
{
if (dstData != null) {
Rectangle r = dstData.getBounds();
if (w > r.width || h > r.height) {
dstData = null;
}
}
if (dstData == null) {
BufferedImage dstBI = new BufferedImage(w, h, type);
dstData = BufImgSurfaceData.createData(dstBI);
}
ob.Blit(srcData, dstData, AlphaComposite.Src, null,
srcX, srcY, 0, 0, w, h);
return dstData;
}
public void MaskFill(SunGraphics2D sg2d,
SurfaceData sData,
Composite comp,
int x, int y, int w, int h,
byte mask[], int offset, int scan)
{
BufferedImage dstBI =
new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
SurfaceData tmpData = BufImgSurfaceData.createData(dstBI);
// REMIND: This is not pretty. It would be nicer if we
// passed a "FillData" object to the Pixel loops, instead
// of a SunGraphics2D parameter...
Region clip = sg2d.clipRegion;
sg2d.clipRegion = null;
int pixel = sg2d.pixel;
sg2d.pixel = tmpData.pixelFor(sg2d.getColor());
fillop.FillRect(sg2d, tmpData, 0, 0, w, h);
sg2d.pixel = pixel;
sg2d.clipRegion = clip;
maskop.MaskBlit(tmpData, sData, comp, null,
0, 0, x, y, w, h,
mask, offset, scan);
}
protected static SurfaceData convertFrom(Blit ob, SurfaceData srcData,
int srcX, int srcY, int w, int h,
SurfaceData dstData, int type)
{
if (dstData != null) {
Rectangle r = dstData.getBounds();
if (w > r.width || h > r.height) {
dstData = null;
}
}
if (dstData == null) {
BufferedImage dstBI = new BufferedImage(w, h, type);
dstData = BufImgSurfaceData.createData(dstBI);
}
ob.Blit(srcData, dstData, AlphaComposite.Src, null,
srcX, srcY, 0, 0, w, h);
return dstData;
}
public void MaskFill(SunGraphics2D sg2d,
SurfaceData sData,
Composite comp,
int x, int y, int w, int h,
byte mask[], int offset, int scan)
{
BufferedImage dstBI =
new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
SurfaceData tmpData = BufImgSurfaceData.createData(dstBI);
// REMIND: This is not pretty. It would be nicer if we
// passed a "FillData" object to the Pixel loops, instead
// of a SunGraphics2D parameter...
Region clip = sg2d.clipRegion;
sg2d.clipRegion = null;
int pixel = sg2d.pixel;
sg2d.pixel = tmpData.pixelFor(sg2d.getColor());
fillop.FillRect(sg2d, tmpData, 0, 0, w, h);
sg2d.pixel = pixel;
sg2d.clipRegion = clip;
maskop.MaskBlit(tmpData, sData, comp, null,
0, 0, x, y, w, h,
mask, offset, scan);
}
protected static SurfaceData convertFrom(Blit ob, SurfaceData srcData,
int srcX, int srcY, int w, int h,
SurfaceData dstData, int type)
{
if (dstData != null) {
Rectangle r = dstData.getBounds();
if (w > r.width || h > r.height) {
dstData = null;
}
}
if (dstData == null) {
BufferedImage dstBI = new BufferedImage(w, h, type);
dstData = BufImgSurfaceData.createData(dstBI);
}
ob.Blit(srcData, dstData, AlphaComposite.Src, null,
srcX, srcY, 0, 0, w, h);
return dstData;
}
public void MaskFill(SunGraphics2D sg2d,
SurfaceData sData,
Composite comp,
int x, int y, int w, int h,
byte mask[], int offset, int scan)
{
BufferedImage dstBI =
new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
SurfaceData tmpData = BufImgSurfaceData.createData(dstBI);
// REMIND: This is not pretty. It would be nicer if we
// passed a "FillData" object to the Pixel loops, instead
// of a SunGraphics2D parameter...
Region clip = sg2d.clipRegion;
sg2d.clipRegion = null;
int pixel = sg2d.pixel;
sg2d.pixel = tmpData.pixelFor(sg2d.getColor());
fillop.FillRect(sg2d, tmpData, 0, 0, w, h);
sg2d.pixel = pixel;
sg2d.clipRegion = clip;
maskop.MaskBlit(tmpData, sData, comp, null,
0, 0, x, y, w, h,
mask, offset, scan);
}
protected static SurfaceData convertFrom(Blit ob, SurfaceData srcData,
int srcX, int srcY, int w, int h,
SurfaceData dstData, int type)
{
if (dstData != null) {
Rectangle r = dstData.getBounds();
if (w > r.width || h > r.height) {
dstData = null;
}
}
if (dstData == null) {
BufferedImage dstBI = new BufferedImage(w, h, type);
dstData = BufImgSurfaceData.createData(dstBI);
}
ob.Blit(srcData, dstData, AlphaComposite.Src, null,
srcX, srcY, 0, 0, w, h);
return dstData;
}
public void MaskFill(SunGraphics2D sg2d,
SurfaceData sData,
Composite comp,
int x, int y, int w, int h,
byte mask[], int offset, int scan)
{
BufferedImage dstBI =
new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
SurfaceData tmpData = BufImgSurfaceData.createData(dstBI);
// REMIND: This is not pretty. It would be nicer if we
// passed a "FillData" object to the Pixel loops, instead
// of a SunGraphics2D parameter...
Region clip = sg2d.clipRegion;
sg2d.clipRegion = null;
int pixel = sg2d.pixel;
sg2d.pixel = tmpData.pixelFor(sg2d.getColor());
fillop.FillRect(sg2d, tmpData, 0, 0, w, h);
sg2d.pixel = pixel;
sg2d.clipRegion = clip;
maskop.MaskBlit(tmpData, sData, comp, null,
0, 0, x, y, w, h,
mask, offset, scan);
}
protected static SurfaceData convertFrom(Blit ob, SurfaceData srcData,
int srcX, int srcY, int w, int h,
SurfaceData dstData, int type)
{
if (dstData != null) {
Rectangle r = dstData.getBounds();
if (w > r.width || h > r.height) {
dstData = null;
}
}
if (dstData == null) {
BufferedImage dstBI = new BufferedImage(w, h, type);
dstData = BufImgSurfaceData.createData(dstBI);
}
ob.Blit(srcData, dstData, AlphaComposite.Src, null,
srcX, srcY, 0, 0, w, h);
return dstData;
}
public void MaskFill(SunGraphics2D sg2d,
SurfaceData sData,
Composite comp,
int x, int y, int w, int h,
byte mask[], int offset, int scan)
{
BufferedImage dstBI =
new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
SurfaceData tmpData = BufImgSurfaceData.createData(dstBI);
// REMIND: This is not pretty. It would be nicer if we
// passed a "FillData" object to the Pixel loops, instead
// of a SunGraphics2D parameter...
Region clip = sg2d.clipRegion;
sg2d.clipRegion = null;
int pixel = sg2d.pixel;
sg2d.pixel = tmpData.pixelFor(sg2d.getColor());
fillop.FillRect(sg2d, tmpData, 0, 0, w, h);
sg2d.pixel = pixel;
sg2d.clipRegion = clip;
maskop.MaskBlit(tmpData, sData, comp, null,
0, 0, x, y, w, h,
mask, offset, scan);
}
protected static SurfaceData convertFrom(Blit ob, SurfaceData srcData,
int srcX, int srcY, int w, int h,
SurfaceData dstData, int type)
{
if (dstData != null) {
Rectangle r = dstData.getBounds();
if (w > r.width || h > r.height) {
dstData = null;
}
}
if (dstData == null) {
BufferedImage dstBI = new BufferedImage(w, h, type);
dstData = BufImgSurfaceData.createData(dstBI);
}
ob.Blit(srcData, dstData, AlphaComposite.Src, null,
srcX, srcY, 0, 0, w, h);
return dstData;
}
public void MaskFill(SunGraphics2D sg2d,
SurfaceData sData,
Composite comp,
int x, int y, int w, int h,
byte mask[], int offset, int scan)
{
BufferedImage dstBI =
new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
SurfaceData tmpData = BufImgSurfaceData.createData(dstBI);
// REMIND: This is not pretty. It would be nicer if we
// passed a "FillData" object to the Pixel loops, instead
// of a SunGraphics2D parameter...
Region clip = sg2d.clipRegion;
sg2d.clipRegion = null;
int pixel = sg2d.pixel;
sg2d.pixel = tmpData.pixelFor(sg2d.getColor());
fillop.FillRect(sg2d, tmpData, 0, 0, w, h);
sg2d.pixel = pixel;
sg2d.clipRegion = clip;
maskop.MaskBlit(tmpData, sData, comp, null,
0, 0, x, y, w, h,
mask, offset, scan);
}
protected static SurfaceData convertFrom(Blit ob, SurfaceData srcData,
int srcX, int srcY, int w, int h,
SurfaceData dstData, int type)
{
if (dstData != null) {
Rectangle r = dstData.getBounds();
if (w > r.width || h > r.height) {
dstData = null;
}
}
if (dstData == null) {
BufferedImage dstBI = new BufferedImage(w, h, type);
dstData = BufImgSurfaceData.createData(dstBI);
}
ob.Blit(srcData, dstData, AlphaComposite.Src, null,
srcX, srcY, 0, 0, w, h);
return dstData;
}
public void MaskFill(SunGraphics2D sg2d,
SurfaceData sData,
Composite comp,
int x, int y, int w, int h,
byte mask[], int offset, int scan)
{
BufferedImage dstBI =
new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
SurfaceData tmpData = BufImgSurfaceData.createData(dstBI);
// REMIND: This is not pretty. It would be nicer if we
// passed a "FillData" object to the Pixel loops, instead
// of a SunGraphics2D parameter...
Region clip = sg2d.clipRegion;
sg2d.clipRegion = null;
int pixel = sg2d.pixel;
sg2d.pixel = tmpData.pixelFor(sg2d.getColor());
fillop.FillRect(sg2d, tmpData, 0, 0, w, h);
sg2d.pixel = pixel;
sg2d.clipRegion = clip;
maskop.MaskBlit(tmpData, sData, comp, null,
0, 0, x, y, w, h,
mask, offset, scan);
}
protected static SurfaceData convertFrom(Blit ob, SurfaceData srcData,
int srcX, int srcY, int w, int h,
SurfaceData dstData, int type)
{
if (dstData != null) {
Rectangle r = dstData.getBounds();
if (w > r.width || h > r.height) {
dstData = null;
}
}
if (dstData == null) {
BufferedImage dstBI = new BufferedImage(w, h, type);
dstData = BufImgSurfaceData.createData(dstBI);
}
ob.Blit(srcData, dstData, AlphaComposite.Src, null,
srcX, srcY, 0, 0, w, h);
return dstData;
}
public void MaskFill(SunGraphics2D sg2d,
SurfaceData sData,
Composite comp,
int x, int y, int w, int h,
byte mask[], int offset, int scan)
{
BufferedImage dstBI =
new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
SurfaceData tmpData = BufImgSurfaceData.createData(dstBI);
// REMIND: This is not pretty. It would be nicer if we
// passed a "FillData" object to the Pixel loops, instead
// of a SunGraphics2D parameter...
Region clip = sg2d.clipRegion;
sg2d.clipRegion = null;
int pixel = sg2d.pixel;
sg2d.pixel = tmpData.pixelFor(sg2d.getColor());
fillop.FillRect(sg2d, tmpData, 0, 0, w, h);
sg2d.pixel = pixel;
sg2d.clipRegion = clip;
maskop.MaskBlit(tmpData, sData, comp, null,
0, 0, x, y, w, h,
mask, offset, scan);
}
@Override
public void BlitBg(SurfaceData srcData,
SurfaceData dstData,
Composite comp,
Region clip,
int bgArgb,
int srcx, int srcy,
int dstx, int dsty,
int width, int height)
{
ColorModel dstModel = dstData.getColorModel();
boolean bgHasAlpha = (bgArgb >>> 24) != 0xff;
if (!dstModel.hasAlpha() && bgHasAlpha) {
dstModel = ColorModel.getRGBdefault();
}
WritableRaster wr =
dstModel.createCompatibleWritableRaster(width, height);
boolean isPremult = dstModel.isAlphaPremultiplied();
BufferedImage bimg =
new BufferedImage(dstModel, wr, isPremult, null);
SurfaceData tmpData = BufImgSurfaceData.createData(bimg);
Color bgColor = new Color(bgArgb, bgHasAlpha);
SunGraphics2D sg2d = new SunGraphics2D(tmpData, bgColor, bgColor,
defaultFont);
FillRect fillop = FillRect.locate(SurfaceType.AnyColor,
CompositeType.SrcNoEa,
tmpData.getSurfaceType());
Blit combineop = Blit.getFromCache(srcData.getSurfaceType(),
CompositeType.SrcOverNoEa,
tmpData.getSurfaceType());
Blit blitop = Blit.getFromCache(tmpData.getSurfaceType(), compositeType,
dstData.getSurfaceType());
fillop.FillRect(sg2d, tmpData, 0, 0, width, height);
combineop.Blit(srcData, tmpData, AlphaComposite.SrcOver, null,
srcx, srcy, 0, 0, width, height);
blitop.Blit(tmpData, dstData, comp, clip,
0, 0, dstx, dsty, width, height);
}
@Override
public void BlitBg(SurfaceData srcData,
SurfaceData dstData,
Composite comp,
Region clip,
int bgArgb,
int srcx, int srcy,
int dstx, int dsty,
int width, int height)
{
ColorModel dstModel = dstData.getColorModel();
boolean bgHasAlpha = (bgArgb >>> 24) != 0xff;
if (!dstModel.hasAlpha() && bgHasAlpha) {
dstModel = ColorModel.getRGBdefault();
}
WritableRaster wr =
dstModel.createCompatibleWritableRaster(width, height);
boolean isPremult = dstModel.isAlphaPremultiplied();
BufferedImage bimg =
new BufferedImage(dstModel, wr, isPremult, null);
SurfaceData tmpData = BufImgSurfaceData.createData(bimg);
Color bgColor = new Color(bgArgb, bgHasAlpha);
SunGraphics2D sg2d = new SunGraphics2D(tmpData, bgColor, bgColor,
defaultFont);
FillRect fillop = FillRect.locate(SurfaceType.AnyColor,
CompositeType.SrcNoEa,
tmpData.getSurfaceType());
Blit combineop = Blit.getFromCache(srcData.getSurfaceType(),
CompositeType.SrcOverNoEa,
tmpData.getSurfaceType());
Blit blitop = Blit.getFromCache(tmpData.getSurfaceType(), compositeType,
dstData.getSurfaceType());
fillop.FillRect(sg2d, tmpData, 0, 0, width, height);
combineop.Blit(srcData, tmpData, AlphaComposite.SrcOver, null,
srcx, srcy, 0, 0, width, height);
blitop.Blit(tmpData, dstData, comp, clip,
0, 0, dstx, dsty, width, height);
}