All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jtransc.imaging.async.JTranscAsyncBitmapDataDecoder Maven / Gradle / Ivy

Go to download

JVM AOT compiler currently generating JavaScript, C++, Haxe, with initial focus on Kotlin and games.

There is a newer version: 0.6.8
Show newest version
package com.jtransc.imaging.async;

import com.jtransc.async.JTranscAsyncHandler;
import com.jtransc.imaging.JTranscNativeBitmap;
import com.jtransc.io.async.JTranscAsyncFile;
import com.jtransc.service.JTranscService;

public abstract class JTranscAsyncBitmapDataDecoder {
	static private JTranscAsyncBitmapDataDecoder _instance;

	static public JTranscAsyncBitmapDataDecoder getInstance() {
		if (_instance == null) _instance = JTranscService.getFirst(JTranscAsyncBitmapDataDecoder.class);
		return _instance;
	}

	static public void readFromURLAsync(String url, JTranscAsyncHandler handler) {
		getInstance().readFromURLAsync(url, handler);
	}

	static public void readFromFileAsync(String url, JTranscAsyncHandler handler) {
		getInstance().readFromFileAsync(url, handler);
	}

	static public void readFromBytesAsync(byte[] data, JTranscAsyncHandler handler) {
		getInstance().readFromBytesAsyncImpl(data, handler);
	}


	public void readFromURLAsyncImpl(String url, JTranscAsyncHandler handler) {
		throw new RuntimeException("Not implemented");
	}

	public void readFromFileAsyncImpl(final String file, final JTranscAsyncHandler handler) {
		new JTranscAsyncFile(file).readAllAsync(new JTranscAsyncHandler() {
			@Override
			public void complete(byte[] data, Throwable error) {
				if (error != null) {
					handler.complete(null, error);
				} else {
					readFromBytesAsyncImpl(data, handler);
				}
			}
		});
	}

	abstract public void readFromBytesAsyncImpl(final byte[] data, final JTranscAsyncHandler handler);
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy