mIRC Home    About    Download    Register    News    Help

Print Thread
#270989 06/11/22 09:37 AM
Joined: Dec 2002
Posts: 240
T
Talon Offline OP
Fjord artisan
OP Offline
Fjord artisan
T
Joined: Dec 2002
Posts: 240
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:
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://developer.mozilla.org/en-US/docs/Web/API/Blob

Joined: Jan 2004
Posts: 1,944
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,944
If the intent of this alias is to make a square icon, I'm not getting that. Instead, this gives me a rectangle window and imagefile with a lot of white space to the side. And when I check the dimensions there's nothing that matches the 32 with specified:

//echo -a $window(@pic).dw $window(@pic).dh $window(@pic).w $window(@pic).h

result: 101 32 109 60

Joined: Dec 2002
Posts: 240
T
Talon Offline OP
Fjord artisan
OP Offline
Fjord artisan
T
Joined: Dec 2002
Posts: 240
Ah nice catch, this is due to mIRC adjusting window sizes to make them fit in the MDI area when a window is created. To get around this, you need to use /window twice....

Updated:

Code
alias test {
  window -hpf @Test -1 -1 32 32
  echo -s * Debug: first window call- DW: $window(@Test).dw DH: $window(@Test).dh
  window -hpf @Test -1 -1 32 32
  echo -s * Debug: second window call- DW: $window(@Test).dw DH: $window(@Test).dh
  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 copied to clipboard!
}

Output:
* Debug: first window call- DW: 120 DH: 32
* Debug: second window call- DW: 32 DH: 32
Data URL copied to clipboard!

You should be able to paste your clipboard into your browsers url bar, hit enter, and now see the icon as 32x32

Last edited by Khaled; 13/11/22 08:26 PM.
Joined: Jan 2004
Posts: 1,944
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,944
Strange about the window -f, as the 2nd call only seems to work if the @window is -hidden or -minimized. As soon as the window becomes visible, it widens - possibly to make more of the titlebar visible, and it won't shrink the @window unless you minimize or hide it again.


Link Copied to Clipboard