Class NativeImage

java.lang.Object
net.minecraft.client.texture.NativeImage
All Implemented Interfaces:
AutoCloseable

@Environment(CLIENT)
public final class NativeImage
extends Object
implements AutoCloseable
  • Field Details

    • LOGGER

      private static final Logger LOGGER
    • WRITE_TO_FILE_OPEN_OPTIONS

      private static final Set<StandardOpenOption> WRITE_TO_FILE_OPEN_OPTIONS
    • format

      private final NativeImage.Format 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

      public NativeImage​(NativeImage.Format format, int width, int height, boolean useStb)
    • NativeImage

      private NativeImage​(NativeImage.Format format, int width, int height, boolean useStb, long pointer)
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • read

      public static NativeImage read​(InputStream inputStream) throws IOException
      Throws:
      IOException
    • read

      public static NativeImage read​(@Nullable NativeImage.Format format, InputStream inputStream) throws IOException
      Throws:
      IOException
    • read

      public static NativeImage read​(ByteBuffer byteBuffer) throws IOException
      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 interface AutoCloseable
    • getWidth

      public int getWidth()
    • getHeight

      public int getHeight()
    • getFormat

      public NativeImage.Format 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 public int[] 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

      public void writeFile​(File file) throws IOException
      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

      public void writeFile​(Path path) throws IOException
      Throws:
      IOException
    • getBytes

      public byte[] getBytes() throws IOException
      Throws:
      IOException
    • write

      private boolean write​(WritableByteChannel writableByteChannel) throws IOException
      Throws:
      IOException
    • copyFrom

      public void copyFrom​(NativeImage image)
    • 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

      public void resizeSubRectTo​(int x, int y, int width, int height, NativeImage targetImage)
    • untrack

      public void untrack()
    • read

      public static NativeImage read​(String dataUri) throws IOException
      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.