Hi all,
I am currently working on a project with a lot of images.
To start prototyping the app I wanted to create dummy-data (json and images).
But because the use of a lot of images, these images should but unique.
I used the neko target, and created the json file with ease.
But its impossible to generate images from scratch with text using neko.
(I have the size and color of the images under controle!)
So for the I thought it would be useful to use
http://dummyimage.com/600x400/000/fff.png&text=testso I can generate different sizes, color and text
This is part of the code I use.
(I need to put some delays in there, because I want to play nice with
dummyimage.com)
// load image
var req = new haxe.Http('http://dummyimage.com/600x400/000/fff.png&text=test');
req.onData = function (pdata){
trace('first 100 bytes: '+pdata.substr(0, 100));
writeStringToPng(pdata);
}
req.onError = function (error){
trace('error: $error');
}
req.request(true);
function writeStringToPng (str:String):Void
{
var bytes:Bytes = Bytes.ofString(str);
var data = format.png.Tools.buildRGB (660,400,bytes);
var out = sys.io.File.write('bin/boo.png',true);
new format.png.Writer(out).write(data);
}
This code fails when I try to convert the
bytes to
data.
Perhaps my code is related to this issue:
https://github.com/HaxeFoundation/haxe/issues/2586Any idea how to fix this?
Thx