public class BMPEncoder extends Object
| 限定符和类型 | 方法和说明 |
|---|---|
static InfoHeader |
createInfoHeader(BufferedImage img)
Creates an InfoHeader from the source image.
|
static int |
getBitmapSize(int w,
int h,
int bpp)
Calculates the size in bytes of a bitmap with the specified size and colour depth.
|
static int |
getBytesPerLine1(int width)
Calculates the number of bytes per line required for the given width in pixels,
for a 1-bit bitmap.
|
static int |
getBytesPerLine24(int width)
Calculates the number of bytes per line required for the given with in pixels,
for a 24-bit bitmap.
|
static int |
getBytesPerLine4(int width)
Calculates the number of bytes per line required for the given with in pixels,
for a 4-bit bitmap.
|
static int |
getBytesPerLine8(int width)
Calculates the number of bytes per line required for the given with in pixels,
for a 8-bit bitmap.
|
static int |
getColorMapSize(short sBitCount)
Calculates the size in bytes for a colour map with the specified bit count.
|
static void |
write(BufferedImage img,
File file)
Encodes and writes BMP data the output file
|
static void |
write(BufferedImage img,
OutputStream os)
Encodes and writes BMP data to the output
|
static void |
write1(Raster raster,
LittleEndianOutputStream out)
Encodes and writes raster data as a 1-bit bitmap.
|
static void |
write24(Raster raster,
LittleEndianOutputStream out)
Encodes and writes raster data as a 24-bit bitmap.
|
static void |
write32(Raster raster,
Raster alpha,
LittleEndianOutputStream out)
Encodes and writes raster data, together with alpha (transparency) data, as a 32-bit bitmap.
|
static void |
write4(Raster raster,
LittleEndianOutputStream out)
Encodes and writes raster data as a 4-bit bitmap.
|
static void |
write8(Raster raster,
LittleEndianOutputStream out)
Encodes and writes raster data as an 8-bit bitmap.
|
static void |
writeColorMap(IndexColorModel icm,
LittleEndianOutputStream out)
Writes the colour map resulting from the source IndexColorModel.
|
static void |
writeFileHeader(int fileSize,
int dataOffset,
LittleEndianOutputStream out)
Writes the file header.
|
public static void write(BufferedImage img, File file) throws IOException
img - the image to encodefile - the file to which encoded data will be writtenIOException - if an error occurspublic static void write(BufferedImage img, OutputStream os) throws IOException
img - the image to encodeos - the output to which encoded data will be writtenIOException - if an error occurspublic static InfoHeader createInfoHeader(BufferedImage img)
img - the source imagepublic static void writeFileHeader(int fileSize,
int dataOffset,
LittleEndianOutputStream out)
throws IOException
fileSize - the calculated file size for the BMP data being writtendataOffset - the calculated offset within the BMP data where the actual bitmap beginsout - the output to which the file header will be writtenIOException - if an error occurspublic static void writeColorMap(IndexColorModel icm, LittleEndianOutputStream out) throws IOException
icm - the source IndexColorModelout - the output to which the colour map will be writtenIOException - if an error occurspublic static int getBytesPerLine1(int width)
width - the width in pixelspublic static int getBytesPerLine4(int width)
width - the width in pixelspublic static int getBytesPerLine8(int width)
width - the width in pixelspublic static int getBytesPerLine24(int width)
width - the width in pixelspublic static int getBitmapSize(int w,
int h,
int bpp)
w - the width in pixelsh - the height in pixelsbpp - the colour depth (bits per pixel)public static void write1(Raster raster, LittleEndianOutputStream out) throws IOException
raster - the source raster dataout - the output to which the bitmap will be writtenIOException - if an error occurspublic static void write4(Raster raster, LittleEndianOutputStream out) throws IOException
raster - the source raster dataout - the output to which the bitmap will be writtenIOException - if an error occurspublic static void write8(Raster raster, LittleEndianOutputStream out) throws IOException
raster - the source raster dataout - the output to which the bitmap will be writtenIOException - if an error occurspublic static void write24(Raster raster, LittleEndianOutputStream out) throws IOException
raster - the source raster dataout - the output to which the bitmap will be writtenIOException - if an error occurspublic static void write32(Raster raster, Raster alpha, LittleEndianOutputStream out) throws IOException
raster - the source raster dataalpha - the source alpha dataout - the output to which the bitmap will be writtenIOException - if an error occurspublic static int getColorMapSize(short sBitCount)
sBitCount - the bit count, which represents the colour depthCopyright © 2021. All rights reserved.