« Color masking and sprite tiles | Main | Memory leak on Vista »

Using Quicktime to display CMYK images

Darkstar 2D's CompositeQuickTime.createImageFromQT should work on OS X and you end up with a apple.awt.OSXImage. Fun fact: searching for apple.awt.OSXImage on Google gives me 10 hits.
CMYK test image - 592 kb (in RGB below)

cmyk_test.jpg


importPackage(Packages.java.io)
importPackage(Packages.java.awt)
importPackage(Packages.java.awt.image)
importPackage(Packages.java.awt.geom)
importPackage(Packages.javax.imageio)
importPackage(Packages.com.teppefall.ds.render2d.compositing)
importPackage(Packages.quicktime)
importPackage(Packages.quicktime.io)

function loadImage(ref, cmyk) {
	var bimg;
	try {
		var file = new File(System.getProperty("user.home") +File.separator+"Desktop"+File.separator+ ref)
		if(!cmyk)
		bimg = ImageIO.read(file);
		else
		bimg = CompositeQuickTime.createImageFromQT(new QTFile(file))
		context.info(bimg)
	}
	catch(e) {
		e.printStackTrace();
	}
	return bimg;
}

var sprite
var r = {
	destroy: function() {
		try {
			QTSession.close()
		}
		catch(e) {}
	},
	initialize: function(ds, fg, bg) {
		try {
			QTSession.open()
		}
		catch(e) {}
		sprite = loadImage("cmyk_test2.jpg", true)
	},
	render : function(g, size) {
		g.drawImage(
			sprite,
			0,
			0,
			sprite.getWidth(null),
			sprite.getHeight(null),
			null
		)
	}
}

context.getDarkstar().setRenderer(new D2DAdapter(r))


TrackBack

TrackBack URL for this entry:
http://www.installer.teppefall.com/movabletype/mt-tb.cgi/155

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

This website is all about alpha and beta software

Download non-beta software here