Skip to content

Commit 4d84942

Browse files
authored
Merge pull request #2 from umjammer/v1.0.5
V1.0.5
2 parents 2eca7b3 + bd2c7ab commit 4d84942

22 files changed

+1849
-1532
lines changed

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
tmp/
2-
lib/
1+
/tmp/
2+
/etc/
3+
/lib/

jni_mac.pom

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,28 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
6+
67
<artifactId>libFfmpegResampleOpWrapper</artifactId>
78
<version>1.0.3</version>
89
<groupId>vavi</groupId>
910
<packaging>dylib</packaging>
11+
1012
<build>
1113
<plugins>
1214
<plugin>
1315
<groupId>org.codehaus.mojo</groupId>
1416
<artifactId>native-maven-plugin</artifactId>
1517
<extensions>true</extensions>
1618
<configuration>
17-
<!-- trigger javah execution -->
1819
<javahClassNames>
1920
<javahClassName>vavi.awt.image.resample.FfmpegResampleOp</javahClassName>
2021
</javahClassNames>
21-
<!-- enable additional javah interface in dependencies list -->
22-
<javahSearchJNIFromDependencies>true</javahSearchJNIFromDependencies>
23-
<!-- | Add jdk include directories to system include path | Override
24-
${jkdIncludePath} If your jdk does not conform to Sun JDK layout -->
25-
<javahOS>macosx</javahOS>
22+
<javahSearchJNIFromDependencies>false</javahSearchJNIFromDependencies>
23+
<javahOS>darwin</javahOS>
2624
<compilerProvider>generic-classic</compilerProvider>
2725
<compilerStartOptions>
28-
<compilerStartOption> -g -Wall -O2 -fomit-frame-pointer -fPIC</compilerStartOption>
26+
<compilerStartOption>-g -Wall -O2 -fomit-frame-pointer -fPIC</compilerStartOption>
27+
<!-- unless locating jdk includes, cause error why??? -->
2928
<compilerStartOption>-arch x86_64
3029
-I${java.home}/../include
3130
-I${java.home}/../include/darwin
@@ -37,17 +36,15 @@
3736
</compilerStartOptions>
3837
<sources>
3938
<source>
40-
<!-- relative to your project directory -->
4139
<directory>src/main/native</directory>
4240
<fileNames>
4341
<fileName>FfmpegResampleOpWrapper.c</fileName>
4442
</fileNames>
4543
</source>
4644
</sources>
47-
<!-- deploy the accompany .lib file as well -->
48-
<linkerSecondaryOutputExtensions>lib</linkerSecondaryOutputExtensions>
45+
<linkerSecondaryOutputExtensions>dylib</linkerSecondaryOutputExtensions>
4946
<linkerStartOptions>
50-
<linkerStartOption> -dynamiclib -arch x86_64
47+
<linkerStartOption>-dynamiclib -arch x86_64
5148
-L/usr/local/lib -lavformat -lavcodec -lswscale -lavutil</linkerStartOption>
5249
</linkerStartOptions>
5350
</configuration>

pom.xml

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,25 @@
33
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
55
<modelVersion>4.0.0</modelVersion>
6+
67
<groupId>vavi</groupId>
78
<artifactId>vavi-image</artifactId>
89
<name>Vavi Imaging API</name>
910
<organization>
1011
<name></name>
1112
</organization>
12-
<version>1.0.3</version>
13+
<version>1.0.5</version>
1314
<url>https://github.com/umjammer/vavi-image</url>
14-
<description>1.0.3
15+
<description>1.0.5
16+
17+
fix gif spi
18+
fix gif transparent
19+
20+
1.0.4
21+
22+
refactoring bmp, gif
23+
24+
1.0.3
1525

1626
fix non lzw gif
1727

@@ -29,6 +39,13 @@ TODO
2939
imageio ppm doesn't work
3040
pom
3141
jni bcel 5 on java8 ???</description>
42+
<scm>
43+
<url>https://github.com/umjammer/vavi-image</url>
44+
</scm>
45+
<issueManagement>
46+
<url>https://github.com/umjammer/vavi-image/issues</url>
47+
</issueManagement>
48+
3249
<build>
3350
<plugins>
3451
<plugin>
@@ -41,28 +58,26 @@ TODO
4158
</plugin>
4259
</plugins>
4360
</build>
61+
4462
<repositories>
4563
<repository>
4664
<id>jitpack.io</id>
4765
<url>https://jitpack.io</url>
4866
</repository>
4967
</repositories>
68+
5069
<dependencies>
5170
<dependency>
5271
<groupId>com.github.umjammer</groupId>
5372
<artifactId>vavi-commons</artifactId>
54-
<version>1.0.6</version>
55-
</dependency>
56-
<dependency>
57-
<groupId>com.github.umjammer</groupId>
58-
<artifactId>vavi-awt</artifactId>
59-
<version>1.0.1</version>
73+
<version>1.0.7</version>
6074
</dependency>
6175
<dependency>
6276
<groupId>com.github.umjammer</groupId>
6377
<artifactId>jiu</artifactId>
6478
<version>0.14.3</version>
6579
</dependency>
80+
6681
<dependency>
6782
<groupId>org.junit.jupiter</groupId>
6883
<artifactId>junit-jupiter-api</artifactId>
@@ -75,6 +90,12 @@ TODO
7590
<version>5.3.0</version>
7691
<scope>test</scope>
7792
</dependency>
93+
<dependency>
94+
<groupId>com.github.umjammer</groupId>
95+
<artifactId>vavi-awt</artifactId>
96+
<version>1.0.5</version>
97+
<scope>test</scope>
98+
</dependency>
7899
<dependency>
79100
<groupId>com.github.umjammer</groupId>
80101
<artifactId>javapng-spi</artifactId>
@@ -88,4 +109,5 @@ TODO
88109
<scope>test</scope>
89110
</dependency>
90111
</dependencies>
112+
91113
</project>

src/main/java/vavi/awt/image/bmp/WindowsBitmap.java

Lines changed: 48 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -231,26 +231,26 @@ private static final class Header {
231231

232232
int bitmapSize;
233233

234-
/** ビットマップファイルのヘッダを読み込みます. */
235-
static final Header readFrom(InputStream in) throws IOException {
234+
/**
235+
* ビットマップファイルのヘッダを読み込みます.
236+
* @throws IllegalArgumentException not a windows bitmap
237+
*/
238+
static final Header readFrom(LittleEndianDataInputStream lin) throws IOException {
236239

237240
Header header = new Header();
238241

239-
@SuppressWarnings("resource")
240-
LittleEndianDataInputStream iin = new LittleEndianDataInputStream(in);
241-
242-
@SuppressWarnings("unused")
243-
int dummy;
242+
byte[] signature = new byte[2];
244243

245244
// 14 bytes
246-
dummy = iin.read();
247-
// Debug.println((byte) dummy);
248-
dummy = iin.read();
249-
// Debug.println((char) dummy);
250-
header.bitmapSize = iin.readInt();
251-
dummy = iin.readShort();
252-
dummy = iin.readShort();
253-
header.bitmapOffset = iin.readInt();
245+
246+
lin.readFully(signature);
247+
if (signature[0] != 'B' || signature[1] != 'M') {
248+
throw new IllegalArgumentException("not a windows bitmap");
249+
}
250+
header.bitmapSize = lin.readInt();
251+
lin.readShort();
252+
lin.readShort();
253+
header.bitmapOffset = lin.readInt();
254254

255255
return header;
256256
}
@@ -336,28 +336,25 @@ public String toString() {
336336
/**
337337
* ストリームからビットマップヘッダのインスタンスを作成します.
338338
*/
339-
static final WindowsBitmapHeader readFrom(InputStream in) throws IOException {
339+
static final WindowsBitmapHeader readFrom(LittleEndianDataInputStream lin) throws IOException {
340340

341341
WindowsBitmapHeader bh = new WindowsBitmapHeader();
342342

343-
@SuppressWarnings("resource")
344-
LittleEndianDataInputStream iin = new LittleEndianDataInputStream(in);
345-
346343
// read 40 bytes
347-
bh.headerSize = iin.readInt();
348-
bh.width = iin.readInt();
349-
bh.height = iin.readInt();
350-
bh.planes = iin.readShort();
351-
bh.bits = iin.readShort();
352-
bh.compression = iin.readInt();
353-
bh.imageSize = iin.readInt();
354-
bh.ppmX = iin.readInt();
355-
bh.ppmY = iin.readInt();
356-
bh.usedColor = iin.readInt();
357-
bh.importantColor = iin.readInt();
344+
bh.headerSize = lin.readInt();
345+
bh.width = lin.readInt();
346+
bh.height = lin.readInt();
347+
bh.planes = lin.readShort();
348+
bh.bits = lin.readShort();
349+
bh.compression = lin.readInt();
350+
bh.imageSize = lin.readInt();
351+
bh.ppmX = lin.readInt();
352+
bh.ppmY = lin.readInt();
353+
bh.usedColor = lin.readInt();
354+
bh.importantColor = lin.readInt();
358355

359356
//Debug.println("bitmap");
360-
Debug.print(bh);
357+
//Debug.print(bh);
361358

362359
if (bh.usedColor == 0) {
363360
switch (bh.bits) {
@@ -387,12 +384,13 @@ static final WindowsBitmapHeader readFrom(InputStream in) throws IOException {
387384
byte[] reds = new byte[bh.usedColor];
388385
byte[] greens = new byte[bh.usedColor];
389386
byte[] blues = new byte[bh.usedColor];
387+
byte[] alphas = new byte[bh.usedColor];
390388

391389
for (int i = 0; i < bh.usedColor; i++) {
392-
blues[i] = (byte) in.read();
393-
greens[i] = (byte) in.read();
394-
reds[i] = (byte) in.read();
395-
/* alpha */ in.read();
390+
blues[i] = lin.readByte();
391+
greens[i] = lin.readByte();
392+
reds[i] = lin.readByte();
393+
alphas[i] = lin.readByte();
396394
//System.err.print("(" + i + ")");
397395
//bh.palette[i].print();
398396
}
@@ -424,8 +422,10 @@ static final WindowsBitmapHeader readFrom(InputStream in) throws IOException {
424422
}
425423
}
426424

427-
in.skip(bh.headerSize - 40);
428-
Debug.println("skip: " + (bh.headerSize - 40));
425+
lin.skipBytes(bh.headerSize - 40);
426+
if (bh.headerSize - 40 > 0) {
427+
Debug.println("skip: " + (bh.headerSize - 40));
428+
}
429429

430430
return bh;
431431
}
@@ -684,15 +684,9 @@ public byte[] get256ColorRleData() {
684684
// -------------------------------------------------------------------------
685685

686686
/** ビットマップイメージを読み込みます. */
687-
private static byte[] readBitmap(InputStream in, int num) throws IOException {
688-
689-
byte buf[] = new byte[num];
690-
691-
int l = 0;
692-
while (l < num) {
693-
l += in.read(buf, l, num - l);
694-
}
695-
687+
private static byte[] readBitmap(LittleEndianDataInputStream in, int num) throws IOException {
688+
byte[] buf = new byte[num];
689+
in.readFully(buf, 0, num);
696690
return buf;
697691
}
698692

@@ -704,17 +698,19 @@ private static byte[] readBitmap(InputStream in, int num) throws IOException {
704698
*/
705699
public static WindowsBitmap readFrom(InputStream in) throws IOException {
706700

701+
LittleEndianDataInputStream lin = new LittleEndianDataInputStream(in);
702+
707703
WindowsBitmap bitmap = new WindowsBitmap();
708704

709-
bitmap.header = Header.readFrom(in);
710-
bitmap.bitmapHeader = WindowsBitmapHeader.readFrom(in);
705+
bitmap.header = Header.readFrom(lin);
706+
bitmap.bitmapHeader = WindowsBitmapHeader.readFrom(lin);
711707

712708
if (bitmap.bitmapHeader.imageSize == 0) {
713709
bitmap.bitmapHeader.imageSize = bitmap.header.bitmapSize - bitmap.header.bitmapOffset;
714710
//Debug.println(b.bitmapHeader.imageSize);
715711
}
716712

717-
bitmap.bitmap = readBitmap(in, bitmap.bitmapHeader.imageSize);
713+
bitmap.bitmap = readBitmap(lin, bitmap.bitmapHeader.imageSize);
718714

719715
return bitmap;
720716
}
@@ -736,15 +732,15 @@ public static WindowsBitmap readFrom(InputStream in) throws IOException {
736732
*
737733
* </code></pre>
738734
*/
739-
protected static WindowsBitmap readFrom(InputStream in, int off, int size) throws IOException {
735+
public static WindowsBitmap readFrom(LittleEndianDataInputStream lin, int off, int size) throws IOException {
740736

741737
WindowsBitmap bitmap = new WindowsBitmap();
742738

743739
bitmap.header = new Header();
744740

745741
bitmap.header.bitmapSize = size;
746742

747-
bitmap.bitmapHeader = WindowsBitmapHeader.readFrom(in);
743+
bitmap.bitmapHeader = WindowsBitmapHeader.readFrom(lin);
748744

749745
bitmap.bitmapHeader.height /= 2;
750746
bitmap.header.bitmapOffset = bitmap.bitmapHeader.headerSize + 4 * bitmap.bitmapHeader.usedColor;
@@ -753,7 +749,7 @@ protected static WindowsBitmap readFrom(InputStream in, int off, int size) throw
753749
//b.bitmapHeader.print();
754750
//included mask
755751
//Debug.println("read: " + (b.header.bitmapSize - b.header.bitmapOffset));
756-
bitmap.bitmap = readBitmap(in, bitmap.header.bitmapSize - bitmap.header.bitmapOffset);
752+
bitmap.bitmap = readBitmap(lin, bitmap.header.bitmapSize - bitmap.header.bitmapOffset);
757753

758754
return bitmap;
759755
}

src/main/java/vavi/awt/image/bmp/WindowsBitmapImageSource.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616

1717
/**
18-
* ウインドウズビットマップを作成します
19-
*
18+
* Windows ビットマップを作成します
19+
*
2020
* @author <a href="mailto:umjammer@gmail.com">Naohide Sano</a> (nsano)
2121
* @version 0.00 970713 nsano initial version <br>
2222
* 1.00 010731 nsano refine <br>
@@ -62,7 +62,7 @@ public void requestTopDownLeftRightResend(ImageConsumer ic) {
6262
}
6363

6464
/** WindowsIconSource 用 */
65-
WindowsBitmapImageSource(WindowsBitmap bitmap) {
65+
public WindowsBitmapImageSource(WindowsBitmap bitmap) {
6666
this.bitmap = bitmap;
6767
}
6868

0 commit comments

Comments
 (0)