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 classNativeImage.Formatstatic classNativeImage.GLFormat(package private) static classNativeImage.WriteCallback -
Field Summary
Fields Modifier and Type Field Description private NativeImage.Formatformatprivate intheightprivate booleanisStbImageprivate static LoggerLOGGERprivate longpointerprivate longsizeBytesprivate intwidthprivate 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)privateNativeImage(NativeImage.Format format, int width, int height, boolean useStb, long pointer) -
Method Summary
Modifier and Type Method Description private voidcheckAllocated()voidclose()voidcopyFrom(NativeImage image)voidcopyRect(int x, int y, int translateX, int translateY, int width, int height, boolean flipX, boolean flipY)voidfillRect(int x, int y, int width, int height, int color)static intgetAbgrColor(int alpha, int blue, int green, int red)The resulting color of this operation is stored as least to most significant bits.static intgetAlpha(int color)static intgetBlue(int color)byte[]getBytes()NativeImage.FormatgetFormat()static intgetGreen(int color)intgetHeight()intgetPixelColor(int x, int y)Gets the color of a pixel on this native image.bytegetPixelOpacity(int x, int y)static intgetRed(int color)intgetWidth()voidloadFromTextureImage(int level, boolean removeAlpha)voidmakeGlyphBitmapSubpixel(STBTTFontinfo fontInfo, int glyphIndex, int width, int height, float scaleX, float scaleY, float shiftX, float shiftY, int startX, int startY)int[]makePixelArray()Deprecated.voidmirrorVertically()static NativeImageread(InputStream inputStream)static NativeImageread(String dataUri)static NativeImageread(ByteBuffer byteBuffer)static NativeImageread(NativeImage.Format format, InputStream inputStream)static NativeImageread(NativeImage.Format format, ByteBuffer byteBuffer)voidresizeSubRectTo(int x, int y, int width, int height, NativeImage targetImage)voidsetPixelColor(int x, int y, int color)Sets the color of a pixel on this native image.private static voidsetTextureClamp(boolean clamp)private static voidsetTextureFilter(boolean blur, boolean mipmap)StringtoString()voiduntrack()voidupload(int level, int offsetX, int offsetY, boolean close)voidupload(int level, int offsetX, int offsetY, int unpackSkipPixels, int unpackSkipRows, int width, int height, boolean mipmap, boolean close)voidupload(int level, int offsetX, int offsetY, int unpackSkipPixels, int unpackSkipRows, int width, int height, boolean blur, boolean clamp, boolean mipmap, boolean close)private voiduploadInternal(int level, int xOffset, int yOffset, int unpackSkipPixels, int unpackSkipRows, int width, int height, boolean blur, boolean clamp, boolean mipmap, boolean close)private booleanwrite(WritableByteChannel writableByteChannel)voidwriteFile(File file)voidwriteFile(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:
closein 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.
-