Package net.minecraft.client.texture
Class NativeImage
java.lang.Object
net.minecraft.client.texture.NativeImage
- All Implemented Interfaces:
AutoCloseable
@Environment(CLIENT) public final class NativeImage extends Object implements AutoCloseable
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
NativeImage.Format
static class
NativeImage.GLFormat
(package private) static class
NativeImage.WriteCallback
-
Field Summary
Fields Modifier and Type Field Description private NativeImage.Format
format
private int
height
private boolean
isStbImage
private static Logger
LOGGER
private long
pointer
private long
sizeBytes
private int
width
private static Set<StandardOpenOption>
WRITE_TO_FILE_OPEN_OPTIONS
-
Constructor Summary
Constructors Modifier Constructor Description NativeImage(int width, int height, boolean useStb)
NativeImage(NativeImage.Format format, int width, int height, boolean useStb)
private
NativeImage(NativeImage.Format format, int width, int height, boolean useStb, long pointer)
-
Method Summary
Modifier and Type Method Description private void
checkAllocated()
void
close()
void
copyFrom(NativeImage image)
void
copyRect(int x, int y, int translateX, int translateY, int width, int height, boolean flipX, boolean flipY)
void
fillRect(int x, int y, int width, int height, int color)
static int
getAbgrColor(int alpha, int blue, int green, int red)
The resulting color of this operation is stored as least to most significant bits.static int
getAlpha(int color)
static int
getBlue(int color)
byte[]
getBytes()
NativeImage.Format
getFormat()
static int
getGreen(int color)
int
getHeight()
int
getPixelColor(int x, int y)
Gets the color of a pixel on this native image.byte
getPixelOpacity(int x, int y)
static int
getRed(int color)
int
getWidth()
void
loadFromTextureImage(int level, boolean removeAlpha)
void
makeGlyphBitmapSubpixel(STBTTFontinfo fontInfo, int glyphIndex, int width, int height, float scaleX, float scaleY, float shiftX, float shiftY, int startX, int startY)
int[]
makePixelArray()
Deprecated.void
mirrorVertically()
static NativeImage
read(InputStream inputStream)
static NativeImage
read(String dataUri)
static NativeImage
read(ByteBuffer byteBuffer)
static NativeImage
read(NativeImage.Format format, InputStream inputStream)
static NativeImage
read(NativeImage.Format format, ByteBuffer byteBuffer)
void
resizeSubRectTo(int x, int y, int width, int height, NativeImage targetImage)
void
setPixelColor(int x, int y, int color)
Sets the color of a pixel on this native image.private static void
setTextureClamp(boolean clamp)
private static void
setTextureFilter(boolean blur, boolean mipmap)
String
toString()
void
untrack()
void
upload(int level, int offsetX, int offsetY, boolean close)
void
upload(int level, int offsetX, int offsetY, int unpackSkipPixels, int unpackSkipRows, int width, int height, boolean mipmap, boolean close)
void
upload(int level, int offsetX, int offsetY, int unpackSkipPixels, int unpackSkipRows, int width, int height, boolean blur, boolean clamp, boolean mipmap, boolean close)
private void
uploadInternal(int level, int xOffset, int yOffset, int unpackSkipPixels, int unpackSkipRows, int width, int height, boolean blur, boolean clamp, boolean mipmap, boolean close)
private boolean
write(WritableByteChannel writableByteChannel)
void
writeFile(File file)
void
writeFile(Path path)
-
Field Details
-
LOGGER
-
WRITE_TO_FILE_OPEN_OPTIONS
-
format
-
width
private final int width -
height
private final int height -
isStbImage
private final boolean isStbImage -
pointer
private long pointer -
sizeBytes
private final long sizeBytes
-
-
Constructor Details
-
NativeImage
public NativeImage(int width, int height, boolean useStb) -
NativeImage
-
NativeImage
private NativeImage(NativeImage.Format format, int width, int height, boolean useStb, long pointer)
-
-
Method Details
-
toString
-
read
- Throws:
IOException
-
read
public static NativeImage read(@Nullable NativeImage.Format format, InputStream inputStream) throws IOException- Throws:
IOException
-
read
- Throws:
IOException
-
read
public static NativeImage read(@Nullable NativeImage.Format format, ByteBuffer byteBuffer) throws IOException- Throws:
IOException
-
setTextureClamp
private static void setTextureClamp(boolean clamp) -
setTextureFilter
private static void setTextureFilter(boolean blur, boolean mipmap) -
checkAllocated
private void checkAllocated() -
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-
getWidth
public int getWidth() -
getHeight
public int getHeight() -
getFormat
-
getPixelColor
public int getPixelColor(int x, int y)Gets the color of a pixel on this native image. The color returned by this method will be in a ABGR format.This is only supported when this native image's format is
ABGR
. -
setPixelColor
public void setPixelColor(int x, int y, int color)Sets the color of a pixel on this native image. The color to be set using this method should be in a ABGR format.This is only supported when this native image's format is
ABGR
-
getPixelOpacity
public byte getPixelOpacity(int x, int y) -
makePixelArray
Deprecated. -
upload
public void upload(int level, int offsetX, int offsetY, boolean close) -
upload
public void upload(int level, int offsetX, int offsetY, int unpackSkipPixels, int unpackSkipRows, int width, int height, boolean mipmap, boolean close) -
upload
public void upload(int level, int offsetX, int offsetY, int unpackSkipPixels, int unpackSkipRows, int width, int height, boolean blur, boolean clamp, boolean mipmap, boolean close) -
uploadInternal
private void uploadInternal(int level, int xOffset, int yOffset, int unpackSkipPixels, int unpackSkipRows, int width, int height, boolean blur, boolean clamp, boolean mipmap, boolean close) -
loadFromTextureImage
public void loadFromTextureImage(int level, boolean removeAlpha) -
writeFile
- Throws:
IOException
-
makeGlyphBitmapSubpixel
public void makeGlyphBitmapSubpixel(STBTTFontinfo fontInfo, int glyphIndex, int width, int height, float scaleX, float scaleY, float shiftX, float shiftY, int startX, int startY) -
writeFile
- Throws:
IOException
-
getBytes
- Throws:
IOException
-
write
- Throws:
IOException
-
copyFrom
-
fillRect
public void fillRect(int x, int y, int width, int height, int color) -
copyRect
public void copyRect(int x, int y, int translateX, int translateY, int width, int height, boolean flipX, boolean flipY) -
mirrorVertically
public void mirrorVertically() -
resizeSubRectTo
-
untrack
public void untrack() -
read
- Throws:
IOException
-
getAlpha
public static int getAlpha(int color) -
getRed
public static int getRed(int color) -
getGreen
public static int getGreen(int color) -
getBlue
public static int getBlue(int color) -
getAbgrColor
public static int getAbgrColor(int alpha, int blue, int green, int red)The resulting color of this operation is stored as least to most significant bits.
-