@archvisioninc/canvas 2.6.8 → 2.6.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -413,8 +413,9 @@ export const getImageFileFromBuffer = args => {
|
|
|
413
413
|
asDataUrl
|
|
414
414
|
} = args || {};
|
|
415
415
|
if (_.isEmpty(buffer)) return '';
|
|
416
|
+
if (!_.isObject(buffer) && !_.isArray(buffer)) return buffer;
|
|
416
417
|
if (asDataUrl) {
|
|
417
|
-
|
|
418
|
+
// Convert buffer to data:image/png;base64 string
|
|
418
419
|
const Uint8ToString = u8a => {
|
|
419
420
|
if (_.isEmpty(u8a)) return '';
|
|
420
421
|
const maxChunkSize = 8192;
|
|
@@ -425,23 +426,16 @@ export const getImageFileFromBuffer = args => {
|
|
|
425
426
|
}
|
|
426
427
|
return chunks.join('');
|
|
427
428
|
};
|
|
429
|
+
const ascii = new Uint8Array(buffer);
|
|
428
430
|
const dataString = btoa(Uint8ToString(ascii));
|
|
429
|
-
const
|
|
430
|
-
|
|
431
|
-
});
|
|
432
|
-
const blobUrl = URL.createObjectURL(blob);
|
|
433
|
-
console.log({
|
|
434
|
-
dataString,
|
|
435
|
-
blob,
|
|
436
|
-
blobUrl
|
|
437
|
-
});
|
|
438
|
-
return blobUrl;
|
|
431
|
+
const dataUrl = `data:image/png;base64,${dataString}`;
|
|
432
|
+
return dataUrl;
|
|
439
433
|
}
|
|
440
434
|
const blob = new Blob([buffer], {
|
|
441
435
|
type: 'image/png'
|
|
442
436
|
});
|
|
443
|
-
const
|
|
444
|
-
return
|
|
437
|
+
const blobUrl = URL.createObjectURL(blob);
|
|
438
|
+
return blobUrl;
|
|
445
439
|
};
|
|
446
440
|
export const getTextureUrl = args => {
|
|
447
441
|
const {
|
package/package.json
CHANGED
|
@@ -471,10 +471,10 @@ export const getImageFileFromBuffer = args => {
|
|
|
471
471
|
const { buffer, asDataUrl } = args || {};
|
|
472
472
|
|
|
473
473
|
if (_.isEmpty(buffer)) return '';
|
|
474
|
+
if (!_.isObject(buffer) && !_.isArray(buffer)) return buffer;
|
|
474
475
|
|
|
475
476
|
if (asDataUrl) {
|
|
476
|
-
|
|
477
|
-
|
|
477
|
+
// Convert buffer to data:image/png;base64 string
|
|
478
478
|
const Uint8ToString = u8a => {
|
|
479
479
|
if (_.isEmpty(u8a)) return '';
|
|
480
480
|
|
|
@@ -489,18 +489,17 @@ export const getImageFileFromBuffer = args => {
|
|
|
489
489
|
return chunks.join('');
|
|
490
490
|
};
|
|
491
491
|
|
|
492
|
+
const ascii = new Uint8Array(buffer);
|
|
492
493
|
const dataString = btoa(Uint8ToString(ascii));
|
|
493
|
-
const
|
|
494
|
-
const blobUrl = URL.createObjectURL(blob);
|
|
494
|
+
const dataUrl = `data:image/png;base64,${dataString}`;
|
|
495
495
|
|
|
496
|
-
|
|
497
|
-
return blobUrl;
|
|
496
|
+
return dataUrl;
|
|
498
497
|
}
|
|
499
498
|
|
|
500
499
|
const blob = new Blob([ buffer ], { type: 'image/png' });
|
|
501
|
-
const
|
|
500
|
+
const blobUrl = URL.createObjectURL(blob);
|
|
502
501
|
|
|
503
|
-
return
|
|
502
|
+
return blobUrl;
|
|
504
503
|
};
|
|
505
504
|
|
|
506
505
|
export const getTextureUrl = args => {
|