public class WebPFrameBlock extends RasterCachedImage implements IFrame, IAnimationFrame
Represents the webp blocks openers registry.
| Constructor and Description |
|---|
WebPFrameBlock(int width,
int height)
Initializes a new instance of the
WebPFrameBlock class. |
WebPFrameBlock(RasterImage rasterImage)
Initializes a new instance of the
WebPFrameBlock class. |
| Modifier and Type | Method and Description |
|---|---|
int |
getBitsPerPixel()
Gets the image bits per pixel count.
|
int |
getDisposalMethod()
Gets the disposal method.
|
short |
getDuration()
Gets or sets the frame duration.
|
int |
getFrameLeft()
Gets the frame left offset.
|
int |
getFrameTime()
Gets the frame duration.
|
int |
getFrameTop()
Gets the frame top offset.
|
RasterImage |
getFullFrame()
Gets the full frame.
|
int |
getHeight()
Gets the image height.
|
short |
getLeft()
Gets or sets the frame position left.
|
short |
getTop()
Gets or sets the frame position top.
|
int |
getWidth()
Gets the image width.
|
boolean |
hasAlpha()
Gets a value indicating whether this instance has alpha.
|
void |
setDuration(short value)
Gets or sets the frame duration.
|
void |
setLeft(short value)
Gets or sets the frame position left.
|
void |
setTop(short value)
Gets or sets the frame position top.
|
adjustBrightness, adjustContrast, adjustGamma, adjustGamma, binarizeBradley, binarizeBradley, binarizeFixed, binarizeOtsu, cacheData, crop, dither, grayscale, isCached, resize, resize, rotate, rotateFlipcrop, dither, filter, getArgb32Pixel, getDefaultArgb32Pixels, getDefaultPixels, getDefaultRawData, getDefaultRawData, getHorizontalResolution, getImageOpacity, getModifyDate, getPixel, getPremultiplyComponents, getRawCustomColorConverter, getRawDataFormat, getRawDataSettings, getRawFallbackIndex, getRawIndexedColorConverter, getRawLineSize, getSkewAngle, getTransparentColor, getUpdateXmpData, getUseRawData, getVerticalResolution, getXmpData, hasTransparentColor, isRawDataAvailable, isUsePalette, loadArgb32Pixels, loadArgb64Pixels, loadCmyk32Pixels, loadCmykPixels, loadPartialArgb32Pixels, loadPartialPixels, loadPixels, loadRawData, loadRawData, normalizeAngle, normalizeAngle, readArgb32ScanLine, readScanLine, replaceColor, replaceColor, replaceNonTransparentColors, replaceNonTransparentColors, rotate, saveArgb32Pixels, saveCmyk32Pixels, saveCmykPixels, savePixels, saveRawData, setArgb32Pixel, setHorizontalResolution, setPalette, setPixel, setPremultiplyComponents, setRawCustomColorConverter, setRawFallbackIndex, setRawIndexedColorConverter, setResolution, setTransparentColor, setTransparentColor, setUpdateXmpData, setUseRawData, setVerticalResolution, setXmpData, toBitmap, writeArgb32ScanLine, writeScanLinecanLoad, canLoad, canLoad, canLoad, canSave, create, create, create, getBackgroundColor, getBounds, getBufferSizeHint, getContainer, getDefaultOptions, getFileFormat, getFileFormat, getFileFormat, getFittingRectangle, getFittingRectangle, getInterruptMonitor, getOriginalOptions, getPalette, getProgressEventHandler, getProgressEventHandlerInfo, getProportionalHeight, getProportionalWidth, getSize, hasBackgroundColor, isAutoAdjustPalette, load, load, load, load, load, load, resize, resizeHeightProportionally, resizeHeightProportionally, resizeHeightProportionally, resizeWidthProportionally, resizeWidthProportionally, resizeWidthProportionally, save, save, save, save, save, save, save, save, setAutoAdjustPalette, setBackgroundColor, setBackgroundColor, setBufferSizeHint, setInterruptMonitor, setPalettegetDataStreamContainer, save, save, saveclose, dispose, getDisposedpublic WebPFrameBlock(RasterImage rasterImage)
Initializes a new instance of the WebPFrameBlock class.
rasterImage - The raster image.public WebPFrameBlock(int width,
int height)
Initializes a new instance of the WebPFrameBlock class.
width - The width.height - The height.This example shows how to create a multi-frame animated WebP image with the specified options.
String dir = "c:\\temp\\";
com.aspose.imaging.imageoptions.WebPOptions createOptions = new com.aspose.imaging.imageoptions.WebPOptions();
createOptions.setLossless(true);
createOptions.setQuality(100f);
createOptions.setAnimBackgroundColor((long) com.aspose.imaging.Color.getGray().toArgb());
// The default frame plus 36 + 36 additional frames.
createOptions.setAnimLoopCount(36 + 36 + 1);
// Create a WebP image of 100x100 px.
com.aspose.imaging.fileformats.webp.WebPImage webPImage = new com.aspose.imaging.fileformats.webp.WebPImage(100, 100, createOptions);
try {
// The first circle is red
com.aspose.imaging.brushes.SolidBrush brush1 = new com.aspose.imaging.brushes.SolidBrush(com.aspose.imaging.Color.getRed());
// The second circle is black
com.aspose.imaging.brushes.SolidBrush brush2 = new com.aspose.imaging.brushes.SolidBrush(com.aspose.imaging.Color.getBlack());
// Gradually increase the angle of the red arc shape.
for (int angle = 10; angle <= 360; angle += 10) {
com.aspose.imaging.fileformats.webp.WebPFrameBlock block = new com.aspose.imaging.fileformats.webp.WebPFrameBlock(100, 100);
com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(block);
graphics.fillPie(brush1, block.getBounds(), 0, angle);
webPImage.addBlock(block);
}
// Gradually increase the angle of the black arc and wipe out the red arc.
for (int angle = 10; angle <= 360; angle += 10) {
com.aspose.imaging.fileformats.webp.WebPFrameBlock block = new com.aspose.imaging.fileformats.webp.WebPFrameBlock(100, 100);
com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(block);
graphics.fillPie(brush2, block.getBounds(), 0, angle);
graphics.fillPie(brush1, block.getBounds(), angle, 360 - angle);
webPImage.addBlock(block);
}
// Save to a WebP file
webPImage.save(dir + "output.webp");
} finally {
webPImage.dispose();
}
public int getBitsPerPixel()
Gets the image bits per pixel count.
getBitsPerPixel in class Imagepublic int getHeight()
Gets the image height.
getHeight in interface IObjectWithBoundsgetHeight in class Imagepublic int getWidth()
Gets the image width.
getWidth in interface IObjectWithBoundsgetWidth in class Imagepublic boolean hasAlpha()
Gets a value indicating whether this instance has alpha.
hasAlpha in class RasterImagetrue if this instance has alpha; otherwise, false.The following example loads a WEBP image and prints information about raw data format and alpha channel.
String dir = "c:\\temp\\";
String fileName = dir + "sample.webp";
com.aspose.imaging.Image image = com.aspose.imaging.Image.load(fileName);
try {
com.aspose.imaging.fileformats.webp.WebPImage webpImage = (com.aspose.imaging.fileformats.webp.WebPImage) image;
// If the active TIFF frame has alpha channel, then the entire TIFF image is considered to have alpha channel.
System.out.printf("ImageFile=%s, FileFormat=%s, HasAlpha=%s\r\n", fileName, webpImage.getRawDataFormat(), webpImage.hasAlpha());
int i = 0;
for (com.aspose.imaging.fileformats.webp.IFrame frame : webpImage.getBlocks()) {
if (frame instanceof com.aspose.imaging.fileformats.webp.WebPFrameBlock) {
com.aspose.imaging.fileformats.webp.WebPFrameBlock frameBlock = (com.aspose.imaging.fileformats.webp.WebPFrameBlock) frame;
System.out.printf("Frame=%s, FileFormat=%s, HasAlpha=%s\r\n", i++, frameBlock.getRawDataFormat(), frameBlock.hasAlpha());
}
}
} finally {
image.dispose();
}
// The output may look like this:
// ImageFile=c:\temp\sample.webp, FileFormat=RgbIndexed1Bpp, used channels: 1, HasAlpha=False
// Frame=0, FileFormat=RgbIndexed1Bpp, used channels: 1, HasAlpha=False
public short getDuration()
Gets or sets the frame duration.
getDuration in interface IFramepublic void setDuration(short value)
Gets or sets the frame duration.
setDuration in interface IFramevalue - The duration.public short getLeft()
Gets or sets the frame position left.
public void setLeft(short value)
Gets or sets the frame position left.
public short getTop()
Gets or sets the frame position top.
public void setTop(short value)
Gets or sets the frame position top.
public final int getFrameTime()
Gets the frame duration.
getFrameTime in interface IAnimationFramepublic final int getFrameTop()
Gets the frame top offset.
getFrameTop in interface IAnimationFramepublic final int getFrameLeft()
Gets the frame left offset.
getFrameLeft in interface IAnimationFramepublic final int getDisposalMethod()
Gets the disposal method.
getDisposalMethod in interface IAnimationFrameAnimationDisposalMethodspublic final RasterImage getFullFrame()
Gets the full frame.
getFullFrame in interface IAnimationFrameCopyright (c) 2008-2022 Aspose Pty Ltd. All Rights Reserved.