-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9a45c60
commit 9195d45
Showing
18 changed files
with
3,823 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/target/ | ||
/.settings/ | ||
/.classpath | ||
/.project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# JSixel | ||
|
||
JNA based Java bindings for libsixel. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,233 @@ | ||
<!-- | ||
Copyright © 2023 JAdaptive Limited (support@jadaptive.com) | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.sshtools</groupId> | ||
<artifactId>jsixel</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<name>jsixel - JNA based Java bindings for libsixel</name> | ||
<properties> | ||
<maven.compiler.target>17</maven.compiler.target> | ||
<maven.compiler.source>17</maven.compiler.source> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
</properties> | ||
<developers> | ||
<developer> | ||
<id>brett</id> | ||
<email>brett@logonbox.com</email> | ||
</developer> | ||
</developers> | ||
<url>https://github.com/sshtools/jsixel</url> | ||
<organization> | ||
<name>JAdaptive</name> | ||
<url>https://jadaptive.com</url> | ||
</organization> | ||
<inceptionYear>2023</inceptionYear> | ||
<description> | ||
JNA based Java bindings for libsixel. | ||
</description> | ||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.13.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>net.java.dev.jna</groupId> | ||
<artifactId>jna</artifactId> | ||
<version>5.13.0</version> | ||
</dependency> | ||
</dependencies> | ||
<distributionManagement> | ||
<snapshotRepository> | ||
<id>ossrh-sshtools</id> | ||
<url>https://oss.sonatype.org/content/repositories/snapshots</url> | ||
</snapshotRepository> | ||
<repository> | ||
<id>ossrh-sshtools</id> | ||
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url> | ||
</repository> | ||
</distributionManagement> | ||
<licenses> | ||
<license> | ||
<name>Apache License Version 2.0</name> | ||
<url>http://www.apache.org/licenses/LICENSE-2.0</url> | ||
<distribution>repo</distribution> | ||
</license> | ||
</licenses> | ||
<scm> | ||
<url>https://github.com/sshtools/jsixel</url> | ||
<connection>https://github.com/sshtools/jsixel.git</connection> | ||
</scm> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>com.nativelibs4java</groupId> | ||
<artifactId>maven-jnaerator-plugin</artifactId> | ||
<version>0.12</version> | ||
</plugin> | ||
</plugins> | ||
<pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>3.2.0</version> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.8.1</version> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-source-plugin</artifactId> | ||
<version>3.1.0</version> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-site-plugin</artifactId> | ||
<version>3.8.2</version> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-release-plugin</artifactId> | ||
<version>3.0.0</version> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-ant-plugin</artifactId> | ||
<version>2.3</version> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-javadoc-plugin</artifactId> | ||
<version>3.5.0</version> | ||
<executions> | ||
<execution> | ||
<id>javadoc-jar</id> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>jar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<encoding>UTF-8</encoding> | ||
<detectJavaApiLink>false</detectJavaApiLink> | ||
<source>17</source> | ||
<doclint>none</doclint> | ||
<sourcepath>src/main/java</sourcepath> | ||
<includeDependencySources>false</includeDependencySources> | ||
<dependencySourceIncludes> | ||
<dependencySourceInclude>com.sshtools:*</dependencySourceInclude> | ||
</dependencySourceIncludes> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-gpg-plugin</artifactId> | ||
<version>3.1.0</version> | ||
<executions> | ||
<execution> | ||
<id>sign-artifacts</id> | ||
<phase>verify</phase> | ||
<goals> | ||
<goal>sign</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>com.mycila</groupId> | ||
<artifactId>license-maven-plugin</artifactId> | ||
<version>2.3</version> | ||
<configuration> | ||
<header>src/templates/APACHE-2.txt</header> | ||
<properties> | ||
<owner>JAdaptive Limited</owner> | ||
<email>support@jadaptive.com</email> | ||
</properties> | ||
<excludes> | ||
<exclude>**/README</exclude> | ||
<exclude>src/test/resources/**</exclude> | ||
<exclude>src/main/resources/**</exclude> | ||
</excludes> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>check</goal> | ||
<goal>format</goal> | ||
<goal>remove</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.sonatype.plugins</groupId> | ||
<artifactId>nexus-staging-maven-plugin</artifactId> | ||
<version>1.6.13</version> | ||
<extensions>true</extensions> | ||
<configuration> | ||
<serverId>ossrh-sshtools</serverId> | ||
<nexusUrl>https://oss.sonatype.org/</nexusUrl> | ||
<autoReleaseAfterClose>true</autoReleaseAfterClose> | ||
<stagingProgressTimeoutMinutes>10</stagingProgressTimeoutMinutes> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
</build> | ||
<profiles> | ||
<profile> | ||
<id>release-sign-artifacts</id> | ||
<activation> | ||
<property> | ||
<name>performRelease</name> | ||
<value>true</value> | ||
</property> | ||
</activation> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-gpg-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>sign-artifacts</id> | ||
<phase>verify</phase> | ||
<goals> | ||
<goal>sign</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.sonatype.plugins</groupId> | ||
<artifactId>nexus-staging-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
</profiles> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/Test.java |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package com.sshtools.jsixel; | ||
|
||
import java.io.Closeable; | ||
import java.io.File; | ||
import java.nio.ByteBuffer; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import com.sshtools.jsixel.lib.SixelLibrary; | ||
import com.sun.jna.Memory; | ||
import com.sun.jna.Pointer; | ||
import com.sun.jna.ptr.PointerByReference; | ||
|
||
public class Decoder implements Closeable { | ||
|
||
private final PointerByReference enc; | ||
private final Set<Memory> allocated = new HashSet<>(); | ||
|
||
public Decoder() { | ||
enc = new PointerByReference(); | ||
SixelLibrary.INSTANCE.sixel_encoder_new(enc, (PointerByReference)null); | ||
} | ||
|
||
public void opt(char flag) { | ||
SixelLibrary.INSTANCE.sixel_encoder_setopt(enc, flag, (Pointer)null); | ||
} | ||
|
||
public void opt(char flag, String arg) { | ||
SixelLibrary.INSTANCE.sixel_encoder_setopt(enc, flag, arg); | ||
} | ||
|
||
public void opt(char flag, int arg) { | ||
var memo = new Memory(4); | ||
allocated.add(memo); | ||
memo.setInt(0, arg); | ||
SixelLibrary.INSTANCE.sixel_encoder_setopt(enc, flag, memo); | ||
} | ||
|
||
public void opt(char flag, boolean arg) { | ||
var memo = new Memory(1); | ||
allocated.add(memo); | ||
memo.setInt(0, arg ? 1 : 0); | ||
SixelLibrary.INSTANCE.sixel_encoder_setopt(enc, flag, memo); | ||
} | ||
|
||
public void opt(char flag, long arg) { | ||
var memo = new Memory(8); | ||
allocated.add(memo); | ||
memo.setLong(0, arg); | ||
SixelLibrary.INSTANCE.sixel_encoder_setopt(enc, flag, memo); | ||
} | ||
|
||
public void encode(File file) { | ||
encode(file.getAbsolutePath()); | ||
} | ||
|
||
public void encode(String file) { | ||
SixelLibrary.INSTANCE.sixel_encoder_encode(enc, file); | ||
} | ||
|
||
public void encodeBytes(ByteBuffer buf, int width, int height, int pixelFormat, byte[] palette, int ncolors) { | ||
SixelLibrary.INSTANCE.sixel_encoder_encode_bytes(enc, buf, width, height, pixelFormat, palette == null ? null : ByteBuffer.wrap(palette), ncolors); | ||
} | ||
|
||
@Override | ||
public void close() { | ||
allocated.forEach(Memory::close); | ||
SixelLibrary.INSTANCE.sixel_encoder_unref(enc); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package com.sshtools.jsixel; | ||
|
||
import java.io.Closeable; | ||
import java.io.File; | ||
import java.nio.ByteBuffer; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import com.sshtools.jsixel.lib.SixelLibrary; | ||
import com.sun.jna.Memory; | ||
import com.sun.jna.Pointer; | ||
import com.sun.jna.ptr.PointerByReference; | ||
|
||
public class Encoder implements Closeable { | ||
|
||
private final PointerByReference enc; | ||
private final Set<Memory> allocated = new HashSet<>(); | ||
|
||
public Encoder() { | ||
enc = new PointerByReference(); | ||
SixelLibrary.INSTANCE.sixel_encoder_new(enc, (PointerByReference)null); | ||
} | ||
|
||
public void opt(char flag) { | ||
SixelLibrary.INSTANCE.sixel_encoder_setopt(enc, flag, (Pointer)null); | ||
} | ||
|
||
public void opt(char flag, String arg) { | ||
SixelLibrary.INSTANCE.sixel_encoder_setopt(enc, flag, arg); | ||
} | ||
|
||
public void opt(char flag, int arg) { | ||
var memo = new Memory(4); | ||
allocated.add(memo); | ||
memo.setInt(0, arg); | ||
SixelLibrary.INSTANCE.sixel_encoder_setopt(enc, flag, memo); | ||
} | ||
|
||
public void opt(char flag, boolean arg) { | ||
var memo = new Memory(1); | ||
allocated.add(memo); | ||
memo.setInt(0, arg ? 1 : 0); | ||
SixelLibrary.INSTANCE.sixel_encoder_setopt(enc, flag, memo); | ||
} | ||
|
||
public void opt(char flag, long arg) { | ||
var memo = new Memory(8); | ||
allocated.add(memo); | ||
memo.setLong(0, arg); | ||
SixelLibrary.INSTANCE.sixel_encoder_setopt(enc, flag, memo); | ||
} | ||
|
||
public void encode(File file) { | ||
encode(file.getAbsolutePath()); | ||
} | ||
|
||
public void encode(String file) { | ||
SixelLibrary.INSTANCE.sixel_encoder_encode(enc, file); | ||
} | ||
|
||
public void encodeBytes(ByteBuffer buf, int width, int height, int pixelFormat, byte[] palette, int ncolors) { | ||
SixelLibrary.INSTANCE.sixel_encoder_encode_bytes(enc, buf, width, height, pixelFormat, palette == null ? null : ByteBuffer.wrap(palette), ncolors); | ||
} | ||
|
||
@Override | ||
public void close() { | ||
allocated.forEach(Memory::close); | ||
SixelLibrary.INSTANCE.sixel_encoder_unref(enc); | ||
} | ||
|
||
} |
Oops, something went wrong.