History

My first initial commit with all of mine experimental changes.

Dmitry Kabak (userdima committed 13 years ago

Commit d37b88d1 parent 3f5b46618352 files · +2598093 −-8690Browse files

Showing the changes to java/pkg/com/sun/imageio/plugins/bmp/BMPImageWriterSpi.java (1 of 18352 files). Show all

Unified · Split

java/pkg/com/sun/imageio/plugins/bmp/BMPImageWriterSpi.java+106−0
@@ -0,0 +1,106 @@
1/*
2 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26package com.sun.imageio.plugins.bmp;
27
28import java.awt.image.DataBuffer;
29import java.awt.image.SampleModel;
30import java.awt.image.SinglePixelPackedSampleModel;
31
32import javax.imageio.spi.ImageWriterSpi;
33import javax.imageio.spi.ServiceRegistry;
34import javax.imageio.spi.IIORegistry;
35import javax.imageio.stream.ImageOutputStream;
36import javax.imageio.ImageWriter;
37import javax.imageio.ImageTypeSpecifier;
38import javax.imageio.IIOException;
39import java.util.Locale;
40
41import javax.imageio.plugins.bmp.BMPImageWriteParam;
42
43public class BMPImageWriterSpi extends ImageWriterSpi {
44 private static String [] readerSpiNames =
45 {"com.sun.imageio.plugins.bmp.BMPImageReaderSpi"};
46 private static String[] formatNames = {"bmp", "BMP"};
47 private static String[] entensions = {"bmp"};
48 private static String[] mimeType = {"image/bmp"};
49
50 private boolean registered = false;
51
52 public BMPImageWriterSpi() {
53 super("Oracle Corporation",
54 "1.0",
55 formatNames,
56 entensions,
57 mimeType,
58 "com.sun.imageio.plugins.bmp.BMPImageWriter",
59 new Class[] { ImageOutputStream.class },
60 readerSpiNames,
61 false,
62 null, null, null, null,
63 true,
64 BMPMetadata.nativeMetadataFormatName,
65 "com.sun.imageio.plugins.bmp.BMPMetadataFormat",
66 null, null);
67 }
68
69 public String getDescription(Locale locale) {
70 return "Standard BMP Image Writer";
71 }
72
73 public void onRegistration(ServiceRegistry registry,
74 Class<?> category) {
75 if (registered) {
76 return;
77 }
78
79 registered = true;
80 }
81
82 public boolean canEncodeImage(ImageTypeSpecifier type) {
83 int dataType= type.getSampleModel().getDataType();
84 if (dataType < DataBuffer.TYPE_BYTE || dataType > DataBuffer.TYPE_INT)
85 return false;
86
87 SampleModel sm = type.getSampleModel();
88 int numBands = sm.getNumBands();
89 if (!(numBands == 1 || numBands == 3))
90 return false;
91
92 if (numBands == 1 && dataType != DataBuffer.TYPE_BYTE)
93 return false;
94
95 if (dataType > DataBuffer.TYPE_BYTE &&
96 !(sm instanceof SinglePixelPackedSampleModel))
97 return false;
98
99 return true;
100 }
101
102 public ImageWriter createWriterInstance(Object extension)
103 throws IIOException {
104 return new BMPImageWriter(this);
105 }
106}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t