drawsave to binary - 06/11/22 09:37 AM
It would be nice if there were a switch to instead of writing a file, to fill a &binvar with what the contents of the file would be. This is VERY handy when constructing image Blobs to be transmitted via $urlget() or sockets, or any other similar situation and also avoid a HDD write/remove.
Take this example code here, run it and post the contents of your clipboard into your browsers URL Bar:
And you should see a proper loaded image Blob of the mIRC icon!
It's not documented in the help file of what all types mIRC can /drawsave as, but there's enough info to deduce bmp and jpg based on the flags. Tests show saving to PNG also work.
With the proposed flag of -BN where N would represent image type (0 = bmp, 1 = jpg, 2 = png, etc...) We'd get a result like this without having to save/delete a file (this one's pseudo-code and won't work!):
A typical Blob consists of a string format, data: <mime-type>;<encoding>,<rawdata> and can be more than just images. For more information check out MDN
https://developer.mozilla.org/en-US/docs/Web/API/Blob
Take this example code here, run it and post the contents of your clipboard into your browsers URL Bar:
Code
alias test { window -hpf @Test -1 -1 32 32 drawpic -g0 @Test 0 0 $qt($mircexe) drawsave @Test tmp.png close -@ @Test bread tmp.png 0 $file(tmp.png).size &bimgfile .remove tmp.png noop $encode(&bimgfile,bm) clipboard data:image/png;base64, $+ $bvar(&bimgfile,1-).text echo -s Data URL Blob copied to clipboard! }
And you should see a proper loaded image Blob of the mIRC icon!
It's not documented in the help file of what all types mIRC can /drawsave as, but there's enough info to deduce bmp and jpg based on the flags. Tests show saving to PNG also work.
With the proposed flag of -BN where N would represent image type (0 = bmp, 1 = jpg, 2 = png, etc...) We'd get a result like this without having to save/delete a file (this one's pseudo-code and won't work!):
Code
alias test { window -hpf @Test -1 -1 32 32 drawpic -g0 @Test 0 0 $qt($mircexe) drawsave -B2 @Test &bimgfile close -@ @Test noop $encode(&bimgfile,bm) clipboard data:image/png;base64, $+ $bvar(&bimgfile,1-).text echo -s Data URL Blob copied to clipboard! }
A typical Blob consists of a string format, data: <mime-type>;<encoding>,<rawdata> and can be more than just images. For more information check out MDN
https:/