generated from jaredlll08/MultiLoader-Template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scale textures. Make animated if appropriate.
- Loading branch information
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
buildSrc/src/main/java/de/griefed/generation/blocks/TextureScaler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package de.griefed.generation.blocks; | ||
|
||
import java.awt.*; | ||
import java.awt.image.BufferedImage; | ||
|
||
public class TextureScaler { | ||
public static BufferedImage getScaledInstance(BufferedImage sourceImage) { | ||
Dimension imgSize = new Dimension(sourceImage.getWidth(), sourceImage.getHeight()); | ||
double widthRatio; | ||
Image scaledImage; | ||
BufferedImage output; | ||
int newWidth = 16; | ||
int newHeight; | ||
widthRatio = (double) newWidth / imgSize.width; | ||
newHeight = (int) (sourceImage.getHeight() * widthRatio); | ||
while (newHeight % 16 != 0) { | ||
newHeight++; | ||
} | ||
scaledImage = sourceImage.getScaledInstance(newWidth, newHeight, Image.SCALE_SMOOTH); | ||
output = new BufferedImage(scaledImage.getWidth(null), scaledImage.getHeight(null), BufferedImage.TYPE_INT_ARGB); | ||
output.getGraphics().drawImage(scaledImage,0, 0, null); | ||
return output; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters