Browse Source

Fixed libwebpjs memmove problem

master
Igor Zhukov 10 years ago
parent
commit
4b0bd16aab
  1. 3
      app/index.html
  2. 13
      app/js/lib/ng_utils.js
  3. 22
      app/js/lib/utils.js
  4. 17
      app/js/services.js
  5. 4079
      app/vendor/libwebpjs/libwebp-0.2.0.js
  6. 2
      app/webogram.appcache

3
app/index.html

@ -64,8 +64,7 @@
<script type="text/javascript" src="vendor/zlib/gunzip.min.js"></script> <script type="text/javascript" src="vendor/zlib/gunzip.min.js"></script>
<script type="text/javascript" src="vendor/closure/long.js"></script> <script type="text/javascript" src="vendor/closure/long.js"></script>
<script type="text/javascript" src="vendor/leemon_bigint/bigint.js"></script> <script type="text/javascript" src="vendor/leemon_bigint/bigint.js"></script>
<!--script type="text/javascript" src="vendor/libwebpjs/libwebp-0.2.0.min.js"></script--> <script type="text/javascript" src="vendor/libwebpjs/libwebp-0.2.0.js"></script>
<script type="text/javascript" src="vendor/libwebpjs/libwebp-0.1.13.js"></script>
<script type="text/javascript" src="js/lib/utils.js"></script> <script type="text/javascript" src="js/lib/utils.js"></script>

13
app/js/lib/ng_utils.js

@ -205,6 +205,19 @@ angular.module('izhukov.utils', [])
return $q.reject(e); return $q.reject(e);
} }
} }
else if (fileData.file) {
var deferred = $q.defer();
fileData.file(function (blob) {
getByteArray(blob).then(function (result) {
deferred.resolve(result);
}, function (error) {
deferred.reject(error);
})
}, function (error) {
deferred.reject(error);
});
return deferred.promise;
}
return $q.when(fileData); return $q.when(fileData);
} }

22
app/js/lib/utils.js

@ -463,30 +463,17 @@ function versionCompare (ver1, ver2) {
image.onerror = function () { image.onerror = function () {
nativeWebpSupport = false; nativeWebpSupport = false;
}; };
// image.src = 'data:image/webp;base64,UklGRjIAAABXRUJQVlA4ICYAAACyAgCdASoCAAEALmk0mk0iIiIiIgBoSygABc6zbAAA/v56QAAAAA=='; image.src = 'data:image/webp;base64,UklGRjIAAABXRUJQVlA4ICYAAACyAgCdASoCAAEALmk0mk0iIiIiIgBoSygABc6zbAAA/v56QAAAAA==';
var canvas, context; var canvas, context;
function convertBinaryToArray (a) {
var b = new Array();
var c = a.length;
for (i = 0; i < c; ++i) b.push(a.charCodeAt(i));
return b
}
function getPngUrlFromData(data) { function getPngUrlFromData(data) {
console.log(data);
data = convertBinaryToArray(data);
var start = tsNow(); var start = tsNow();
var decoder = new WebPDecoder(); var decoder = new WebPDecoder();
var config = decoder.WebPDecoderConfig; var config = decoder.WebPDecoderConfig;
var buffer = config.output; var buffer = config.j || config.output;
// var buffer = config.j;
var bitstream = config.input; var bitstream = config.input;
if (!decoder.WebPInitDecoderConfig(config)) { if (!decoder.WebPInitDecoderConfig(config)) {
@ -495,10 +482,11 @@ function versionCompare (ver1, ver2) {
} }
// console.log('[webpjs] status code', decoder.VP8StatusCode); // console.log('[webpjs] status code', decoder.VP8StatusCode);
var StatusCode = decoder.VP8StatusCode;
status = decoder.WebPGetFeatures(data, data.length, bitstream); status = decoder.WebPGetFeatures(data, data.length, bitstream);
if (status != 0) { if (status != (StatusCode.VP8_STATUS_OK || 0)) {
console.error('[webpjs] status error', status); console.error('[webpjs] status error', status, StatusCode);
} }
var mode = decoder.WEBP_CSP_MODE; var mode = decoder.WEBP_CSP_MODE;

17
app/js/services.js

@ -3792,25 +3792,10 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
} }
return FileManager.getByteArray(blob).then(function (bytes) { return FileManager.getByteArray(blob).then(function (bytes) {
var deferred = $q.defer();
var freader = new FileReader();
freader.onload = function (evt) {
return { return {
id: doc.id, id: doc.id,
src: WebpManager.getPngUrlFromData(evt.target.result) src: WebpManager.getPngUrlFromData(bytes)
}; };
// WebPDecodeAndDraw(evt.target.result)
};
freader.readAsBinaryString(bytes);
return deferred.promise;
// return {
// id: doc.id,
// src: WebpManager.getPngUrlFromData(bytes)
// };
}); });
}); });
} }

4079
app/vendor/libwebpjs/libwebp-0.2.0.js vendored

File diff suppressed because it is too large Load Diff

2
app/webogram.appcache

@ -1,6 +1,6 @@
CACHE MANIFEST CACHE MANIFEST
# 63 # 61
NETWORK: NETWORK:
* *

Loading…
Cancel
Save