faster imageToShape

This commit is contained in:
2015-03-17 07:03:56 +01:00
parent 22ad9655c2
commit 2664d692ba
42 changed files with 117 additions and 103 deletions
@@ -36,9 +36,9 @@ public class BMPFile extends Component {
//--- Private variable declaration
//--- Bitmap file header
private final byte bitmapFileHeader[] = new byte[14];
private final byte[] bitmapFileHeader = new byte[14];
private final byte bfType[] = {'B', 'M'};
private final byte[] bfType = {'B', 'M'};
private int bfSize = 0;
@@ -49,7 +49,7 @@ public class BMPFile extends Component {
private final int bfOffBits = BITMAPFILEHEADER_SIZE + BITMAPINFOHEADER_SIZE;
//--- Bitmap info header
private final byte bitmapInfoHeader[] = new byte[40];
private final byte[] bitmapInfoHeader = new byte[40];
private final int biSize = BITMAPINFOHEADER_SIZE;
@@ -74,7 +74,7 @@ public class BMPFile extends Component {
private final int biClrImportant = 0;
//--- Bitmap raw data
private int bitmap[];
private int[] bitmap;
//--- File section
private FileOutputStream fo;
@@ -148,7 +148,7 @@ public class BMPFile extends Component {
int lastRowIndex;
int pad;
int padCount;
byte rgb[] = new byte[3];
byte[] rgb = new byte[3];
size = (biWidth * biHeight);
pad = (biWidth * 3) % 4;
rowCount = 1;
@@ -221,7 +221,7 @@ public class BMPFile extends Component {
*/
private byte[] intToWord(int parValue) {
byte retValue[] = new byte[2];
byte[] retValue = new byte[2];
retValue[0] = (byte) (parValue & 0x00FF);
retValue[1] = (byte) ((parValue >> 8) & 0x00FF);
return (retValue);
@@ -234,7 +234,7 @@ public class BMPFile extends Component {
*/
private byte[] intToDWord(int parValue) {
byte retValue[] = new byte[4];
byte[] retValue = new byte[4];
retValue[0] = (byte) (parValue & 0x00FF);
retValue[1] = (byte) ((parValue >> 8) & 0x000000FF);
retValue[2] = (byte) ((parValue >> 16) & 0x000000FF);
@@ -56,7 +56,7 @@ public class FontHelper {
*/
public static Map<String, Map<String, Font>> getInstalledFonts() {
Map<String, Map<String, Font>> ret = new HashMap<>();
Font fonts[] = null;
Font[] fonts = null;
try {
@@ -194,7 +194,7 @@ public class FontHelper {
withKerningAttrs.put(TextAttribute.KERNING, TextAttribute.KERNING_ON);
Font withKerningFont = Font.getFont(withKerningAttrs);
GlyphVector withKerningVector = withKerningFont.layoutGlyphVector(getFontRenderContext(withKerningFont), chars, 0, chars.length, Font.LAYOUT_LEFT_TO_RIGHT);
int withKerningX[] = new int[availableChars.size()];
int[] withKerningX = new int[availableChars.size()];
for (int i = 0; i < availableChars.size(); i++) {
withKerningX[i] = withKerningVector.getGlyphLogicalBounds(i * 2 + 1).getBounds().x;
}
@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.helpers;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -47,6 +48,10 @@ public class ImageHelper {
return in;
}
public static void write(BufferedImage image, String formatName, File output) throws IOException {
ImageIO.write(image, formatName, output);
}
public static void write(BufferedImage image, String formatName, OutputStream output) throws IOException {
ImageIO.write(image, formatName, output);
}