mIRC Home    About    Download    Register    News    Help

Print Thread
#217701 20/01/10 02:44 PM
Joined: Dec 2002
Posts: 252
T
Talon Offline OP
Fjord artisan
OP Offline
Fjord artisan
T
Joined: Dec 2002
Posts: 252
I was working in C++ with the SDL Library for access to the framebuffer, and i needed to implement a text drawing routine, so I was making a series of bitmaps to make fixed width fonts. I came up with this nice little alias that should have worked great.

Code:
alias textchart {
  if (!$window(@Chart)) { window -dfp @Chart -1 -1 320 240 } 
  var %font = $window(@Chart).font , %size = $window(@Chart).fontsize
  var %fw = $width(A,%font,%size,0,0) , %fh = $height(A,%font,%size)
  var %x = 0
  while (%x < 255) {
    inc %x
    var %fw = $iif($width($chr(%x),%font,%size,0,0) > %fw,$v1,$v2)
    var %fh = $iif($height($chr(%x),%font,%size) > %fh,$v1,$v2) 
  }
  window -dfp @Chart -1 -1 $calc(%fw * 16) $calc(%fh * 16)
  drawrect -f @Chart 0 0 0 0 640 480
  var %x = 0
  while (%x < 16) {
    var %y = 0
    while (%y < 16) { 
      var %chr = $chr($calc((%x * 16) + %y))
      drawtext @Chart 15 $calc(%fw * %y) $calc(%fh * %x) $iif(%chr != $chr(32) && %chr != $null,$v1,$chr(160))
      inc %y
    }
    inc %x
  }
}


it finds the widest and tallest character, and resizes the @window according to that to fit all 256 characters into the window, so each letter has the exact same size box which i needed for fonts, while this alias works flawlessly, when I used the titlebar of the @window and changed the font, and did another /textchart to build a new font map, when I did a /drawsave I noticed the bitmap from the drawsave was NOT the same size as the windows .dw and .dh, only the very first time I issued the command was this correct.. To reproduce this error with drawsave here is what i did...

my default font is Fixedsys, i did /textchart, then did a /drawsave @chart Fixedsys.bmp, then I clicked the icon in the titlebar, went to fonts, changed it to Terminal (font size 9, default) and did another /textchart, so far so good looks right... did a /drawsave @chart Terminal.bmp and BAM, Terminal.bmp was way too big on JUST The height. I had to crop the picture for my bmp chart of the font which was no big deal, but it was an annoying step and figured it deserved a bug report smile

Talon #217719 20/01/10 09:13 PM
Joined: Dec 2002
Posts: 5,421
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,421
This is actually by design - the size of the bitmap is automatically increased when needed but it is never decreased since mIRC does not know which parts of the bitmap you want to discard. The only solution currently is to close and re-open the window. I will add a /drawcrop command to allow you to crop the bitmap size in the next version.

Khaled #217725 21/01/10 12:25 AM
Joined: Jul 2006
Posts: 4,150
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,150
What is the real difference between this two proprieties (.dw/.dh and .bw /.bh) because I always used window -f to set the size of the bitmap, now i'm confused confused


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Wims #217726 21/01/10 12:39 AM
Joined: Dec 2002
Posts: 252
T
Talon Offline OP
Fjord artisan
OP Offline
Fjord artisan
T
Joined: Dec 2002
Posts: 252
hmm not sure, i havent used .bw or .bh

Last edited by Talon; 21/01/10 12:39 AM.
Wims #217742 21/01/10 03:05 PM
Joined: Dec 2002
Posts: 5,421
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,421
The .dw/.dh properties return the size of the window display. The .bw/.bh properties return the size of the bitmap. When you first create a picture window, those sizes will be the same. If you resize the window smaller or larger, the bitmap will be resized with it. However, if you update part of the visible bitmap by drawing to it, that part of the bitmap is always retained. In other words, mIRC tracks where you've drawn on the bitmap and makes sure that it is not lost if you make the window smaller than that.

Khaled #217747 21/01/10 03:31 PM
Joined: Jul 2006
Posts: 4,150
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,150
thank you smile


#mircscripting @ irc.swiftirc.net == the best mIRC help channel

Link Copied to Clipboard