File tree Expand file tree Collapse file tree 4 files changed +30
-7
lines changed
Expand file tree Collapse file tree 4 files changed +30
-7
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ Load images from:
2323* Local file.
2424* Data URI.
2525* Http(s) URL.
26+ * Node.js Blob URL.
2627* Raw RGBA pixel data
2728
2829
@@ -40,7 +41,18 @@ Additional features:
4041const Image = require (' image-raub' );
4142```
4243
43- See [ TypeSctipt defenitions] ( /index.d.ts ) for more details.
44+ See [ TypeScript defenitions] ( /index.d.ts ) for more details.
45+
46+
47+ ### Set window icon
48+
49+ Compatible with [ glfw-raub] ( https://github.com/node-3d/glfw-raub ) ` window.icon ` property.
50+
51+ ``` js
52+ const icon = new Image ();
53+ icon .src = __dirname + ' /icons/logo.png' ;
54+ icon .on (' load' , () => { window .icon = icon; });
55+ ```
4456
4557
4658### Load an OpenGL texture
Original file line number Diff line number Diff line change 11'use strict' ;
22
3- const { inspect , inherits } = require ( 'util ' ) ;
4- const Emitter = require ( 'events ' ) ;
5-
3+ const { resolveObjectURL } = require ( 'node:buffer ' ) ;
4+ const { inspect , inherits } = require ( 'node:util ' ) ;
5+ const Emitter = require ( 'node:events' ) ;
66const { download } = require ( 'addon-tools-raub' ) ;
77
88const { Image } = require ( '../core' ) ;
@@ -99,6 +99,17 @@ class JsImage extends Image {
9999 return ;
100100 }
101101
102+ // Object URL
103+ if ( / ^ b l o b : n o d e d a t a : / . test ( this . _src ) ) {
104+ const blob = resolveObjectURL ( this . _src ) ;
105+ ( async ( ) => {
106+ const arrayBuffer = await blob . arrayBuffer ( ) ;
107+ const buffer = Buffer . from ( arrayBuffer ) ;
108+ this . _load ( buffer ) ;
109+ } ) ( ) ;
110+ return ;
111+ }
112+
102113 // Data URI
103114 if ( / ^ d a t a : / . test ( this . _src ) ) {
104115 this . _isDataUri = true ;
Original file line number Diff line number Diff line change 11{
22 "author" : " Luis Blanco <luisblanco1337@gmail.com>" ,
33 "name" : " image-raub" ,
4- "version" : " 4.1.3 " ,
4+ "version" : " 4.2.0 " ,
55 "description" : " Native Image loader for Node.js" ,
66 "license" : " MIT" ,
77 "main" : " index.js" ,
You can’t perform that action at this time.
0 commit comments