简体   繁体   中英

How to make a BufferedImage work with this image? (java)

I've got this picture: 第一张图片

Imagine this as a 4x4 tile world of which the tiles are 32x32 pixels each.

then take a look at picture: 另一个示例图片:

Look at the stone tile, it has edges which are outside the grid. Can I use a bufferedImage for this or do I need to do something else to make this work?

If so, could you help me with it by explain it because I've got no clue on how to achieve this is my game?

another example picture: 另一个示例图片:

Let me explain it More Clearly... 1st image = Grid, 2nd Image = Tile Overlapping the grid... (thats what i want to have because then it's a new tile which I can use to make my game look better!), 3d Image = An example of how it would tile!

Simply use PhotoShop to edit the image to 32x32 pixel size....then use it in your game....

/////////////EDITED//////////////////

As shown here , AffineTransformOp offers the additional flexibility of choosing the interpolation type.

BufferedImage before = getBufferedImage(encoded);
int w = before.getWidth();
int h = before.getHeight();
BufferedImage after = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
AffineTransform at = new AffineTransform();
at.scale(2.0, 2.0);
AffineTransformOp scaleOp = 
   new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR);
after = scaleOp.filter(before, after);

To completely eliminate boundary artifact, you can use Penrose tiles .

You can mitigate the edge artifact using anti-aliasing . This example uses TexturePaint with three variant shades of each color: original, darker and lighter. You can experiment with a larger number of shades for better results.

图片

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM