
public class MediaPictureConverterFactory extends Object
MediaPictureConverter objects for
translation between a
number of MediaPicture and BufferedImage types. Not
all image and picture types are supported. When an unsupported
converter is requested, a descriptive UnsupportedOperationException is thrown.
Each converter can
translate between any supported PixelFormat.Type
and a single BufferedImage type. Converters can optionally resize during the
conversion process.
Each converter will re-sample the MediaPicture it is converting
to get the data in the same native byte layout as a BufferedImage
if needed (using MediaPictureResampler). This step takes time and creates
a new temporary copy of the image data. To avoid this step
you can make sure the MediaPicture#getPixelType() is of the same
binary type as a BufferedImage.
Put another way, if you're
converting to BufferedImage.TYPE_3BYTE_BGR, we will not resample
if the MediaPicture#getPixelType() is
io.humble.video.PixelFormat.Type#BGR24.
| Modifier and Type | Class and Description |
|---|---|
static class |
MediaPictureConverterFactory.Type
This class describes a converter type and is used to register and
unregister types with
MediaPictureConverterFactory. |
| Modifier and Type | Field and Description |
|---|---|
static String |
HUMBLE_BGR_24
Converts between MediaPictures and
BufferedImage of type
BufferedImage.TYPE_3BYTE_BGR |
| Modifier and Type | Method and Description |
|---|---|
static BufferedImage |
convertToType(BufferedImage sourceImage,
int targetType)
Convert a
BufferedImage of any type, to BufferedImage of a specified type. |
static MediaPictureConverter |
createConverter(BufferedImage image,
MediaPicture picture)
Create a converter which translates between
BufferedImage
and MediaPicture. |
static MediaPictureConverter |
createConverter(BufferedImage image,
PixelFormat.Type pictureType)
Create a converter which translates between
BufferedImage
and MediaPicture types. |
static MediaPictureConverter |
createConverter(String converterDescriptor,
MediaPicture picture)
Create a converter which translates betewen
BufferedImage
and MediaPicture types. |
static MediaPictureConverter |
createConverter(String converterDescriptor,
PixelFormat.Type pictureType,
int width,
int height)
Create a converter which translates between
BufferedImage
and MediaPicture types. |
static MediaPictureConverter |
createConverter(String converterDescriptor,
PixelFormat.Type pictureType,
int pictureWidth,
int pictureHeight,
int imageWidth,
int imageHeight)
Create a converter which translates betewen
BufferedImage
and MediaPicture types. |
static String |
findDescriptor(BufferedImage image)
Find a descriptor given a
BufferedImage. |
static MediaPictureConverterFactory.Type |
findRegisteredConverter(String descriptor)
Find a converter given a type descriptor.
|
static Collection<MediaPictureConverterFactory.Type> |
getRegisteredConverters()
Get a collection of the registered converters.
|
static MediaPictureConverterFactory.Type |
registerConverter(MediaPictureConverterFactory.Type converterType)
Register a converter with this factory.
|
static MediaPictureConverterFactory.Type |
unregisterConverter(MediaPictureConverterFactory.Type converterType)
Unregister a converter with this factory.
|
public static final String HUMBLE_BGR_24
BufferedImage of type
BufferedImage.TYPE_3BYTE_BGRpublic static MediaPictureConverterFactory.Type registerConverter(MediaPictureConverterFactory.Type converterType)
converterType - the type for the converter to be registeredpublic static MediaPictureConverterFactory.Type unregisterConverter(MediaPictureConverterFactory.Type converterType)
converterType - the type for the converter to be unregisteredpublic static Collection<MediaPictureConverterFactory.Type> getRegisteredConverters()
public static MediaPictureConverterFactory.Type findRegisteredConverter(String descriptor)
descriptor - a unique string which describes this converterpublic static String findDescriptor(BufferedImage image)
BufferedImage.image - a buffered image for which to find a descriptorpublic static MediaPictureConverter createConverter(String converterDescriptor, MediaPicture picture)
BufferedImage
and MediaPicture types. The PixelFormat.Type and size are extracted from
the passed in picture. This factory will attempt to create a
converter which can perform the translation. If no converter can
be created, a descriptive UnsupportedOperationException is
thrown.converterDescriptor - the unique string descriptor of the
converter which is to be createdpicture - the picture from which size and type are extractedUnsupportedOperationException - if the converter can not be
foundUnsupportedOperationException - if the found converter can
not be properly initializedIllegalArgumentException - if the passed MediaPicture is NULL;public static MediaPictureConverter createConverter(BufferedImage image, MediaPicture picture)
BufferedImage
and MediaPicture. This factory will attempt to
create a converter which can perform the translation. If no
converter can be created, a descriptive UnsupportedOperationException is thrown.image - a prototypical BufferedImage that is in the format you want to convert to/from.picture - a prototypical MediaPicture in the format you want to convert to/from.UnsupportedOperationException - if the converter can not be
foundUnsupportedOperationException - if the found converter can
not be properly initializedpublic static MediaPictureConverter createConverter(BufferedImage image, PixelFormat.Type pictureType)
BufferedImage
and MediaPicture types. The BufferedImage type and
size are extracted from the passed in image. This factory will
attempt to create a converter which can perform the translation.
If no converter can be created, a descriptive UnsupportedOperationException is thrown.image - the image from which size and type are extractedpictureType - the picture type of the converterUnsupportedOperationException - if no converter for the
specified BufferedImage type existsUnsupportedOperationException - if the found converter can
not be properly initializedIllegalArgumentException - if the passed BufferedImage is NULL;public static MediaPictureConverter createConverter(String converterDescriptor, PixelFormat.Type pictureType, int width, int height)
BufferedImage
and MediaPicture types. This factory will attempt to
create a converter which can perform the translation. If no
converter can be created, a descriptive UnsupportedOperationException is thrown.converterDescriptor - the unique string descriptor of the
converter which is to be createdpictureType - the picture type of the converterwidth - the width of pictures and imagesheight - the height of pictures and imagesUnsupportedOperationException - if the converter can not be
foundUnsupportedOperationException - if the found converter can
not be properly initializedpublic static MediaPictureConverter createConverter(String converterDescriptor, PixelFormat.Type pictureType, int pictureWidth, int pictureHeight, int imageWidth, int imageHeight)
BufferedImage
and MediaPicture types. This factory will attempt to
create a converter which can perform the translation. If different
image and pictures sizes are passed the converter will resize
during translation. If no converter can be created, a descriptive
UnsupportedOperationException is thrown.converterDescriptor - the unique string descriptor of the
converter which is to be createdpictureType - the picture type of the converterpictureWidth - the width of picturespictureHeight - the height of picturesimageWidth - the width of imagesimageHeight - the height of imagesUnsupportedOperationException - if the converter can not be
foundUnsupportedOperationException - if the converter can not be
properly created or initializedpublic static BufferedImage convertToType(BufferedImage sourceImage, int targetType)
BufferedImage of any type, to BufferedImage of a specified type. If the source image is the
same type as the target type, then original image is returned,
otherwise new image of the correct type is created and the content
of the source image is copied into the new image.sourceImage - the image to be convertedtargetType - the desired BufferedImage typeBufferedImageCopyright © 2018 Humble Software. All rights reserved.