wee, fix a bug in the unzip code and decode pngs

This commit is contained in:
Andreas Gal 2014-08-01 00:30:19 -07:00
Родитель 5a78fed2ce
Коммит f7f715e94a
2 изменённых файлов: 15 добавлений и 3 удалений

16
midp.js
Просмотреть файл

@ -501,8 +501,20 @@ Native["javax/microedition/lcdui/Font.init.(III)V"] = function(ctx, stack) {
}
Native["javax/microedition/lcdui/ImageDataFactory.createImmutableImageDecodeImage.(Ljavax/microedition/lcdui/ImageData;[BII)V"] = function(ctx, stack) {
var length = stack.pop(), offset = stack.pop(), bytes = stack.pop(), image = stack.pop();
image.data = bytes.buffer.slice(offset, offset + length);
var length = stack.pop(), offset = stack.pop(), bytes = stack.pop(), imageData = stack.pop();
var blob = new Blob([bytes.buffer.slice(offset, offset + length)], { type: "image/png" });
var img = new Image();
img.src = URL.createObjectURL(blob);
img.onload = function() {
imageData["javax/microedition/lcdui/ImageData$width"] = img.naturalWidth;
imageData["javax/microedition/lcdui/ImageData$height"] = img.naturalHeight;
imageData["javax/microedition/lcdui/ImageData$nativeImageData"] = img;
ctx.resume();
}
img.onerror = function(e) {
ctx.resume();
}
throw VM.Pause;
}
Native["com/sun/midp/chameleon/layers/SoftButtonLayer.isNativeSoftButtonLayerSupported0.()Z"] = function(ctx, stack) {

Просмотреть файл

@ -224,7 +224,6 @@ function inflate(bytes) {
ensureBuffer(bufferLength + blockLen);
var end = bufferLength + blockLen;
bufferLength = end;
for (var n = bufferLength; n < end; ++n) {
if (typeof (b = bytes[bytesPos++]) == 'undefined') {
eof = true;
@ -232,6 +231,7 @@ function inflate(bytes) {
}
buffer[n] = b;
}
bufferLength = end;
return eof;
}