本文整理汇总了Java中javax.imageio.ImageTypeSpecifier类的典型用法代码示例。如果您正苦于以下问题:Java ImageTypeSpecifier类的具体用法?Java ImageTypeSpecifier怎么用?Java ImageTypeSpecifier使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ImageTypeSpecifier类属于javax.imageio包,在下文中一共展示了ImageTypeSpecifier类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: canEncodeImage
import javax.imageio.ImageTypeSpecifier; //导入依赖的package包/类
public boolean canEncodeImage(ImageTypeSpecifier type) {
SampleModel sampleModel = type.getSampleModel();
// Find the maximum bit depth across all channels
int[] sampleSize = sampleModel.getSampleSize();
int bitDepth = sampleSize[0];
for (int i = 1; i < sampleSize.length; i++) {
if (sampleSize[i] > bitDepth) {
bitDepth = sampleSize[i];
}
}
// 4450894: Ensure bitDepth is between 1 and 8
if (bitDepth < 1 || bitDepth > 8) {
return false;
}
return true;
}
示例2: getRawImageType
import javax.imageio.ImageTypeSpecifier; //导入依赖的package包/类
public ImageTypeSpecifier getRawImageType(int imageIndex)
throws IOException {
setThreadLock();
try {
if (currentImage != imageIndex) {
cbLock.check();
readHeader(imageIndex, true);
}
// Returns null if it can't be represented
return getImageType(colorSpaceCode).getType();
} finally {
clearThreadLock();
}
}
示例3: canNodeAppear
import javax.imageio.ImageTypeSpecifier; //导入依赖的package包/类
public boolean canNodeAppear(String elementName,
ImageTypeSpecifier imageType) {
// All images can have these
if (elementName.equals(getRootName())
|| elementName.equals("JPEGvariety")
|| isInSubtree(elementName, "markerSequence")) {
return true;
}
// If it is an element in the app0jfif subtree, just check
// that the image type is JFIF compliant.
if ((isInSubtree(elementName, "app0JFIF"))
&& JPEG.isJFIFcompliant(imageType, true)) {
return true;
}
return false;
}
示例4: checkAdobe
import javax.imageio.ImageTypeSpecifier; //导入依赖的package包/类
private void checkAdobe(AdobeMarkerSegment adobe,
ImageTypeSpecifier type,
boolean input) {
if (adobe != null) {
int rightTransform = JPEG.transformForType(type, input);
if (adobe.transform != rightTransform) {
warningOccurred(input
? WARNING_IMAGE_METADATA_ADOBE_MISMATCH
: WARNING_DEST_METADATA_ADOBE_MISMATCH);
if (rightTransform == JPEG.ADOBE_IMPOSSIBLE) {
ignoreAdobe = true;
} else {
newAdobeTransform = rightTransform;
}
}
}
}
示例5: testGetAsTree
import javax.imageio.ImageTypeSpecifier; //导入依赖的package包/类
public void testGetAsTree() {
ImageWriteParam p = w.getDefaultWriteParam();
IIOMetadata m =
w.getDefaultImageMetadata(ImageTypeSpecifier.createFromBufferedImageType(type), p);
String format = m.getNativeMetadataFormatName();
System.out.println("native format: " + format);
int count = 0;
try {
while (count < 100) {
System.out.println(" test " + count++);
m.getAsTree(format);
}
} catch (OutOfMemoryError e) {
System.gc();
throw new RuntimeException("Test failed. Number of performed operations: " + count, e);
}
}
示例6: jfifOK
import javax.imageio.ImageTypeSpecifier; //导入依赖的package包/类
private boolean jfifOK(ImageTypeSpecifier imageType,
ImageWriteParam param,
IIOMetadata streamMetadata,
IIOMetadata imageMetadata) {
// If the image type and metadata are JFIF compatible, return true
if ((imageType != null) &&
(!JPEG.isJFIFcompliant(imageType, true))) {
return false;
}
if (imageMetadata != null) {
JPEGMetadata metadata = null;
if (imageMetadata instanceof JPEGMetadata) {
metadata = (JPEGMetadata) imageMetadata;
} else {
metadata = (JPEGMetadata)convertImageMetadata(imageMetadata,
imageType,
param);
}
// metadata must have a jfif node
if (metadata.findMarkerSegment
(JFIFMarkerSegment.class, true) == null){
return false;
}
}
return true;
}
示例7: canEncodeImage
import javax.imageio.ImageTypeSpecifier; //导入依赖的package包/类
public boolean canEncodeImage(ImageTypeSpecifier type) {
int dataType= type.getSampleModel().getDataType();
if (dataType < DataBuffer.TYPE_BYTE || dataType > DataBuffer.TYPE_INT)
return false;
SampleModel sm = type.getSampleModel();
int numBands = sm.getNumBands();
if (!(numBands == 1 || numBands == 3))
return false;
if (numBands == 1 && dataType != DataBuffer.TYPE_BYTE)
return false;
if (dataType > DataBuffer.TYPE_BYTE &&
!(sm instanceof SinglePixelPackedSampleModel))
return false;
return true;
}
示例8: prepareInsertEmpty
import javax.imageio.ImageTypeSpecifier; //导入依赖的package包/类
public void prepareInsertEmpty(int imageIndex,
ImageTypeSpecifier imageType,
int width,
int height,
IIOMetadata imageMetadata,
List<? extends BufferedImage> thumbnails,
ImageWriteParam param) throws IOException {
checkParamsEmpty(imageType, width, height, thumbnails);
this.isInsertingEmpty = true;
SampleModel emptySM = imageType.getSampleModel();
RenderedImage emptyImage =
new EmptyImage(0, 0, width, height,
0, 0, emptySM.getWidth(), emptySM.getHeight(),
emptySM, imageType.getColorModel());
insert(imageIndex, new IIOImage(emptyImage, null, imageMetadata),
param, false);
}
示例9: getImageTypes
import javax.imageio.ImageTypeSpecifier; //导入依赖的package包/类
public Iterator getImageTypes(int imageIndex) throws IOException {
if (input == null)
throw new IllegalStateException();
if (imageIndex >= 5 || imageIndex < 0)
throw new IndexOutOfBoundsException();
Vector imageTypes = new Vector();
imageTypes.add(ImageTypeSpecifier.createFromBufferedImageType
(BufferedImage.TYPE_BYTE_GRAY ));
return imageTypes.iterator();
}
示例10: canEncodeImage
import javax.imageio.ImageTypeSpecifier; //导入依赖的package包/类
public boolean canEncodeImage(ImageTypeSpecifier type) {
if (type == null) {
throw new IllegalArgumentException("type == null!");
}
SampleModel sm = type.getSampleModel();
ColorModel cm = type.getColorModel();
boolean canEncode = sm.getNumBands() == 1 &&
sm.getSampleSize(0) <= 8 &&
sm.getWidth() <= 65535 &&
sm.getHeight() <= 65535 &&
(cm == null || cm.getComponentSize()[0] <= 8);
if (canEncode) {
return true;
} else {
return PaletteBuilder.canCreatePalette(type);
}
}
示例11: getDefaultImageMetadata
import javax.imageio.ImageTypeSpecifier; //导入依赖的package包/类
public IIOMetadata
getDefaultImageMetadata(ImageTypeSpecifier imageType,
ImageWriteParam param) {
List<TIFFTagSet> tagSets = new ArrayList<TIFFTagSet>(1);
tagSets.add(BaselineTIFFTagSet.getInstance());
TIFFImageMetadata imageMetadata = new TIFFImageMetadata(tagSets);
if(imageType != null) {
TIFFImageMetadata im =
(TIFFImageMetadata)convertImageMetadata(imageMetadata,
imageType,
param);
if(im != null) {
imageMetadata = im;
}
}
return imageMetadata;
}
示例12: main
import javax.imageio.ImageTypeSpecifier; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
//nomarkers.jpg has YCbCr color space
String fileName = "nomarkers.jpg";
String sep = System.getProperty("file.separator");
String dir = System.getProperty("test.src", ".");
String filePath = dir+sep+fileName;
System.out.println("Test file: " + filePath);
File imageFile = new File(filePath);
ImageInputStream inputStream = ImageIO.
createImageInputStream(imageFile);
Iterator<ImageReader> readers = ImageIO.getImageReaders(inputStream);
if(readers.hasNext()) {
ImageReader reader = readers.next();
reader.setInput(inputStream);
ImageTypeSpecifier typeSpecifier = reader.getRawImageType(0);
//check if ImageTypeSpecifier is null for YCbCr JPEG Image
if (typeSpecifier == null) {
throw new RuntimeException("ImageReader returns null raw image"
+ " type");
}
}
}
示例13: doTest
import javax.imageio.ImageTypeSpecifier; //导入依赖的package包/类
private static void doTest(int mode) {
String fileFormat = "bmp";
try {
ImageWriter iw = (ImageWriter)ImageIO.getImageWritersBySuffix(fileFormat).next();
if(iw == null) {
throw new RuntimeException("No available image writer for "
+ fileFormat
+ " Test failed.");
}
File file = new File("image." + fileFormat);
ImageOutputStream ios = ImageIO.createImageOutputStream(file);
iw.setOutput(ios);
BufferedImage bimg = new BufferedImage(100,
100, BufferedImage.TYPE_INT_RGB);
Graphics g = bimg.getGraphics();
g.setColor(Color.green);
g.fillRect(0,0,100,100);
ImageWriteParam param = iw.getDefaultWriteParam();
param.setCompressionMode(mode);
IIOMetadata meta = iw.getDefaultImageMetadata(new ImageTypeSpecifier(bimg),
param);
IIOImage iioImg = new IIOImage(bimg, null, meta);
iw.write(null, iioImg, param);
} catch(Exception e) {
e.printStackTrace();
throw new RuntimeException("Test failed.");
}
}
示例14: prepareImageMetadata
import javax.imageio.ImageTypeSpecifier; //导入依赖的package包/类
protected IIOMetadata prepareImageMetadata(int i, BufferedImage img, ImageWriteParam wparam) {
GIFImageMetadata idata = (GIFImageMetadata)
writer.getDefaultImageMetadata(ImageTypeSpecifier.createFromRenderedImage(img), wparam);
idata.delayTime = 100;
idata.disposalMethod = 0;
idata.transparentColorFlag = false;
if (i == 0) {
ArrayList<byte[]> appIDs = new ArrayList<byte[]>();
appIDs.add(new String("NETSCAPE").getBytes());
ArrayList<byte[]> authCodes = new ArrayList<byte[]>();
authCodes.add(new String("2.0").getBytes());
ArrayList<byte[]> appData = new ArrayList<byte[]>();
byte[] authData = {1, 0, 0};
appData.add(authData);
idata.applicationIDs = appIDs;
idata.authenticationCodes = authCodes;
idata.applicationData = appData;
}
return idata;
}
示例15: main
import javax.imageio.ImageTypeSpecifier; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
String format = "javax_imageio_1.0";
BufferedImage img =
new BufferedImage(16, 16, BufferedImage.TYPE_INT_RGB);
ImageWriter iw = ImageIO.getImageWritersByMIMEType("image/png").next();
IIOMetadata meta =
iw.getDefaultImageMetadata(new ImageTypeSpecifier(img), null);
DOMImplementationRegistry registry;
registry = DOMImplementationRegistry.newInstance();
DOMImplementation impl = registry.getDOMImplementation("XML 3.0");
Document doc = impl.createDocument(null, format, null);
Element root, text, entry;
root = doc.getDocumentElement();
root.appendChild(text = doc.createElement("Text"));
text.appendChild(entry = doc.createElement("TextEntry"));
// keyword isn't #REQUIRED by the standard metadata format.
// However, it is required by the PNG format, so we include it here.
entry.setAttribute("keyword", "Comment");
entry.setAttribute("value", "Some demo comment");
meta.mergeTree(format, root);
}