Author: maroon
Added: 6y
Updated: Never
mIRC: used 6.35 & 7.51+
Hits: 1,534
Downloads: 11
Review: entropy
Size: 12.03KB
1 0
Login to vote.
PNG Tiny 1-color Wallpaper or Background
v1
/PNG [[/#6hex | /colorR,G,B | [/rand]] [[/wh] | [/width16-4096] [/height16-4096]] [/overwrite] [/+N] <[path\]filename.png>
Creates a very small 1-color .png image, using $compress to create the compressed data expected by the PNG format. If filename doesn't include path, image is written to your mirc.ini's folder. Quotes not needed, won't write to disk unless filename is *.png
If you want to make a wallpaper for a mobile device that mIRC can't run on, just create the .png on mIRC elsewhere and use the dimensions of the other screen.
Tested on mIRC6.35 and 7.51+, not sure how earlier it works
The syntax message always dispays every time you use the script, showing several examples. If you don't see 2 red lines at the top, then it didn't write your wallpaper to disk.
By default, creates dimensions 1366x768, but /wh overrides as whatever your current monitor resolution is. Or you can override with /widthN and/or /heightN
Color can be specified as either /# followed by 6 hex digits or /color followed by 3 comma-separated numbers 0-255. Or /rand randomly chooses 0-255 for each RGB value. Default color is of course, maroon.
/overwrite switch prevents accidental overwriting existing files, won't overwrite without it.
/+N defaults to /+3000 and is the number of extra bytes of uncompressed data. If +N isn't large enough, Explorer won't show the icon next to the filename, and some viewers won't show the image. The required number increases as width*height increases, and sometimes increasing N results in compressed data shrinking slightly.
Screenshot created with:
/png /#800000 /+972 /width1366 /height768 /overwrite maroon.png
Project icon created by converting screenshot to 64x64 .ico, results in filesize nearly 5x larger.
; syntax: -> /PNG [[/#6hex $(|) /colorR,G,B $(|) [/rand]] [[/wh] $(|) [/width16-4096] [/height16-4096]] [/overwrite] [/+N] <[path\]filename.png> ; Creates a very small 1-color .png image, using $compress to create the compressed ; data expected by the PNG format. If filename doesn't include path, image is written ; to your mirc.ini's folder. Quotes not needed, won't write to disk unless filename is *.png ; ; If you want to make a wallpaper for a mobile device that mIRC can't run on, just create ; the .png on mIRC elsewhere and use the dimensions of the other screen. ; ; Tested on mIRC6.35 and 7.51+, not sure how earlier it works ; ; The syntax message always dispays every time you use the script, showing several examples. ; If you don't see 2 red lines at the top, then it didn't write your wallpaper to disk. ; ; By default, creates dimensions 1366x768, but /wh overrides as whatever your current monitor ; resolution is. Or you can override with /widthN and/or /heightN ; ; Color can be specified as either /# followed by 6 hex digits or /color followed by 3 ; comma-separated numbers 0-255. Or /rand randomly chooses 0-255 for each RGB value. ; Default color is of course, maroon. ; ; /overwrite switch prevents accidental overwriting existing files, won't overwrite without it. ; ; /+N defaults to /+3000 and is the number of extra bytes of uncompressed data. If +N isn't ; large enough, Explorer won't show the icon next to the filename, and some viewers won't ; show the image. The required number increases as width*height increases, and sometimes ; increasing N results in compressed data shrinking slightly. ; For example, 800x600 needs /+500 1024x768 needs /+640 1366x768 needs /+789 ; i only know trial+error to find minimum /+N needed for a particular width/height. Sometimes increasing /+N shrinks filesize by 1 alias PNG { var %width = 1366 , %height 768 , %rgb 128 0 0 , %extra 3000 , %filename , %OverwriteFlag 0 , %uncompressed echo -ag $str(=/,20) :parse_cmdline if (/#* iswm $1) { var %h $mid($1,3) | if (($len(%h) != 6) || (0 $+ $remove(%h,a,b,c,d,e,f) !isnum)) { goto syntax } var %rgb $regsubex(%h,/(.)(.)/g, $base(\1\2,16,10,2) $chr(32)) | goto set_rgb } elseif ($1 == /rand) { var %rgb $rand(0,255) $rand(0,255) $rand(0,255) | goto set_rgb } elseif (/color*,*,* iswm $1) { var %h $mid($1,7) | if (($remove(%h,$chr(44)) !isnum) || ($numtok(%h,44) !isnum 3)) { goto syntax } var %rgb $replace(%h,$chr(44),$chr(32)) :set_rgb var %i 1 | while (%i isnum 1-3) { if ($gettok(%rgb,%i,32) !isnum 0-255) { goto syntax } | inc %i } goto nextparse } elseif ((/+* iswm $1) && ($mid($1,3) isnum 0-)) var %extra $v1 elseif (/over* iswm $1) inc %OverwriteFlag elseif ($1 == /wh) var %width = $window(-1).w , %height $window(-1).h elseif (/width* iswm $1) { var %h $mid($1,7) | if (%h !isnum 16-4096) { goto syntax } | var %width %h } elseif (/height* iswm $1) { var %h $mid($1,8) | if (%h !isnum 16-4096) { goto syntax } | var %height %h } elseif ((/* iswm $1) || (*.png !iswm $1-)) goto syntax else { var %filename $noqt($1-) | goto top } ; 4096 max width/height can be changed, but uncompressed RAM image at 4096x4096 is 2048kb (2meg) :nextparse tokenize 32 $2- | if ($1 != $null) goto parse_cmdline ; finished processing the 'command line' :top if ($isdir( %filename)) { PNG_Msg 4 Unable to Overwrite a Folder Name! %filename | goto syntax } if (($isfile(%filename)) && (!%OverwriteFlag)) { PNG_Msg 4 Unable to Overwrite without /overwrite switch: %filename | goto syntax } ; this is extra size of extra 0x00 bytes in uncompressed image, causes minor change in .png filesize ; adding 7 then $int() causes value to round up, or could've used $ceil var %mem_needed $int($calc(%extra +(7+%width *%height)/8)) ; creating 256 byte string of 0x00's then double the length until the desired length. /bcopy doesn't allow N=S+1 to allow near unlimited copy ; if filled with values other than 0 the image will have different levels of vertical striations. ;bset &image 1 $str(0 $+ $chr(32),256) | var %image 256 ;while (%mem_needed > %image) { bcopy &image $calc(1+%image) &image 1 $iif($calc(%mem_needed -%image) > %image,$v2,$v1) | var %image $bvar(&image,0) } ;bset -c &image 260280 0 bset -c &image %mem_needed 0 ; See PNG structure at top. Filling byte positions for items A thru U bset -c &pngfile 1 0 png_replace 00 89 50 4E 47 0D 0A 1A 0A 00 00 00 0D 49 48 44 52 png_replace 10 00 00 07 80 00 00 04 38 01 03 00 00 00 D2 1D 53 png_replace 20 00 00 00 00 03 50 4C 54 45 35 BF 5C 84 5A B5 09 png_replace 30 00 00 01 13 49 44 41 54 18 19 ;width = bigendian 4 hex bytes file offset 10h /png_replace 10 $png_bigendian_dword($base(%width,10,16,8)) ;height = bigendian 4 hex bytes file offset 14h png_replace 14 $png_bigendian_dword($base(%height,10,16,8)) ;RGB colors = 3 bytes at offset 29h RR,GG,BB bset &pngfile $calc(1+$base(29,16,10)) %rgb ;update IHDR string's CRC-32 to reflect new width/height within 17 bytes at offset 0x0C ;i have yet to encounter a pic viewer which refuses to display image because CRC32 was incorrect bcopy -c &png_temp 1 &pngfile 13 17 | var %crc $crc(&png_temp,1) | png_replace 1D $png_bigendian_dword($base(%crc,16,16,8)) ;update PLTE string's CRC-32 to reflect new colors within 7 bytes at offset 0x25 bcopy -c &png_temp 1 &pngfile 38 7 | var %crc $crc(&png_temp,1) | png_replace 2C $png_bigendian_dword($base(%crc,16,16,8)) ;This uses mIRC to create the deflate compressed data which is the same as used by PNG except the first 2 bytes are different. noop $compress(&image,bn1m2) ;Updates compressed data's length stored bigendian at offset 0x30 - convert length to hex then split into 4 byte values for storage png_replace 30 $png_bigendian_dword($base($bvar(&image,0),10,16,8)) ;$calc(1+$bvar(&pngfile,0)) is position for append. Newer mIRC allows -1 to append to destination bcopy &pngfile $calc(1+$bvar(&pngfile,0)) &image 3 $calc($bvar(&image,0) -2) ;update PLTE string's CRC-32 to reflect new compressed data including the 4 IDAT bytes at offset 0x34 bcopy -c &png_temp 1 &pngfile 53 $calc(4+$bvar(&image,0)) var %crc $crc(&png_temp,1) ;append crc32 of IDAT + unchanging IEND chunk png_replace $base($calc($bvar(&pngfile,0) -0),10,16) $png_bigendian_dword($base(%crc,16,16,8)) 00 00 00 00 49 45 4E 44 AE 42 60 82 if (%OverwriteFlag) btrunc $qt(%filename) 0 bwrite $qt(%filename) 0 -1 &pngfile PNG_Msg 4 Success! Written $bvar(&pngfile,0) bytes to $qt(%filename) Uncompressed Mem Size: $+ %mem_needed Filesize: $file(%filename).size PNG_Msg 4 Width: $+ %width Height: $+ %Height Color:# $+ $base($rgb($gettok(%rgb,3,32),$gettok(%rgb,2,32),$gettok(%rgb,1,32)),10,16,6) Padding: $+ /+ $+ %extra :syntax PNG_Msg PNG $+ $chr(174) by maroon: Create tiny single color .png wallpaper PNG_Msg Syntax: /png [[/#6hex $(|) /colorR,G,B $(|) [/rand]] [[/wh] $(|) [/width16-4096] [/height16-4096]] [/overwrite] [/+N] <[path\]filename.png> PNG_Msg Switches in any order except filename last. List color as either hex /#d00d1e or decimal /color195,33,72 /rand = random rgb colors PNG_Msg /wh uses monitor's width/height $+($window(-1).w,x,$window(-1).h) /overwrite = allows overwriting existing file. (default 1366x768) PNG_Msg /+N increases uncompressed memory image by N bytes above 1/8*Width*Height (Default=/+3000) (some viewers need increased at larger w/h) PNG_Msg if /+N is too small, image may not be viewable PNG_Msg filesize increases along with width * height. PNG_Msg 13 Examples: /PNG /rand /overwrite random color.png PNG_Msg 5 /PNG /#C41E3A /overwrite cardinal.png PNG_Msg 12 /PNG /width1024 /height768 /color0,123,167 cerulean blue.png PNG_Msg 3 /PNG /wh /#84DE02 /overwrite alien armpit.png PNG_Msg 14 /PNG /color130,142,132 /overwrite /width4096 /height4096 /+3584 dolphin.png PNG_Msg 2 To find RGB colors, can use Alt-K, then RIGHT_CLICK on a colored square at bottom, then click 'define custom colors' PNG_Msg 13 Be sure to click CANCEL when exiting colors dialog to avoid changing mirc's own colors too PNG_Msg 2 You can also find 6-digit Hex Color Codes for many colors at https://en.wikipedia.org/wiki/Lists_of_colors } alias PNG_Msg { var %c 12 | if ($1 isnum 0-15) { var %c $1 | tokenize 32 $2- } | echo -ag $+($chr(3),0,$chr(44),%c) $1- $chr(3) } ; $1 is a 32-bit hex value, returns 4 hex bytes in bigendian order alias png_bigendian_dword { var %h $right(00000000 $+ $1,8) | return $mid(%h,1,2) $mid(%h,3,2) $mid(%h,5,2) $mid(%h,7,2) } ; input = tokenized list of hex values, output = values converted from hex to decimal alias png_hex_to_dec { return $regsubex($1-,/(\w+)/g,$base(\t,16,10) $chr(32)) } ; input = tokenized list of dec values, output = values converted from dec to hex alias png_dec_to_hex { return $regsubex($1-,/(\d+)/g,$base(\t,10,16,2) $chr(32)) } ; $1 is 0-based hex offset. $2- are variable length series of hex 0-FF values ; replaces bytes of &pngfile beginning at that offset, converting 0-based hex to 1-based decimal. ; "/png_replace 29 11 22 33" replaces 3 bytes at 1-based position 1+$base(29,16,10) with $chr($base(11,16,10)) $chr($base(22,16,10)) $chr($base(33,16,10)) alias png_replace { bset -c &png_temp 1 $png_hex_to_dec($2-) | bcopy &pngfile $calc(1+$base($1,16,10)) &png_temp 1 $numtok($2-,32) } ; assumes PNG file format is: ; <hex file offset> <hex length> <description> ; all dword values stored bytes bigendian, where 0x12345678 is stored as "0x12 0x34 0x56 0x78", 0x0D stored as "0 0 0 0x0D" ;(A) 00 8 Signature 0x89 "PNG" 0D 0A 1A 0A ;(B) 08 4 0x0D Dword length of IHDR data length excluding the "IHDR" string ;(C) 0c 4 "IHDR" ;(D) 10 4 Dword image pixel width ;(E) 14 4 Dword image pixel height ;(F) 18 1 Bit depth, bits per palette index (This image uses 0x01) ;(G) 19 1 Color type (This image uses 0x01, 'Palette used') ;(H) 1A 1 Compression method (This image uses 0x00 Deflate) ;(I) 1B 1 Filter method (This image uses 0x00) ;(J) 1C 1 Interlace method (This image uses 0x00, No Interlace) ;(K) 1D 4 Dword CRC32 of items D thru J above, the 4 bytes "IHDR" and 0x0D bytes of D thru J ;(L) 21 4 Dword Length of PLTE data excluding the "PLTE" string, 0x03 ;(M) 25 4 "PLTE" ;(N) 29 1 Red Index 0x00 thru 0xFF ;(O) 2A 1 Green Index 0x00 thru 0xFF ;(P) 2B 1 Blue Index 0x00 thru 0xFF ;(Q) 2C 1 Dword CRC32 of the 7 byte string of items M thru P ;(R) 30 4 Dword length of IDAT data segment excluding the "IDAT" string, Items T-V ;(S) 34 4 "IDAT" ;(T) 38 1 Compression Method / Flags (This Image uses 0x18, Bit 0-3 CM 0x08 = Deflate, Bit 4-7 CINFO 0x01 = LZ Window size 2^(8+0x01) = 512 bytes ) ;(U) 39 1 Flags (This Image uses 0x19), Bits 0-4 FCHECK = 0x19, Bit 5 FDICT=0, Bit 6-7 FLEVEL=0 - Byte "T" * 256 + FCHECK must be multiple of 31 ;(V) 4A N Variable length compressed Data. Created by filling &image with 0x00's then using $compress(&image,bm1n2) substituting bytes T+U in place of 1st 2 bytes of $compress output ;(W) 4A+N 4 CRC32 of items S thru V, should be length of 4 + value in item R ;(X) 4E+N 4 Length of IEND Structure exluding "IEND" string, This Image uses 0x00 ;(Y) 52+N 4 "IEND" ;(Z) 56+N 4 CRC32 of "IEND" + $null bytes following, i.e. $crc(IEND,0) ; length of uncompressed data changes according to width/height used, which also affects size of compressed data at less than a dozen bytes per extra uncompressed 10k length. ; //var %i 32 | bset &a 1 $str(0 $+ $chr(32),32) | while (%i < 1000000) { bcopy &a %i &a 1 %i | inc %i %i } | var %j 10000 | while (%j < %i) { bcopy -c &b 1 &a 1 %j | noop $compress(&b,bn1m2) | echo -ag $bvar(&a,0) %j -> $bvar(&b,0) | inc %j 10000 }
0
Ok so i loaded this Snippet into remotes and there was a colorful echos to the status window. I copy and pasted the basic syntax with a sample...
/png /#800000 /+972 /width1366 /height768 /overwrite maroon.png
then: /run maroon.png
Success! Well done maroon!