![]() |
GS2 BMP Image Saver
It was very difficult for me to decide on what kind of method I wanted to use to do this. I wasn't sure if the colors should be a multi-dimensional array for the sake of easy functionality & testing, or an array, each color having it's own specific number that has to be calculated before the image is generated the sake of clarity. I thought I was going to do a GPaint program in GS2, but the screenshot functions won't work properly for me, and only save 256x256px or so on the top left corner of my screen, so I decided to call it a dead project, however, I don't want to let it go to waste, so I will provide you with my latest function.
PHP Code:
I tried to make the comments as clear as possible, but without researching on how images work and how they're generated, it may still be hard to understand what's going on in the script. PHP Code:
PHP Code:
PHP Code:
You can also change the bpp (24) to other modes, like 8 or 16 to get less color quality. You will notice that the channels are reversed (more specifically the blue & red switched places), this is due to the fact that raster scans are performed backwards (scans used by programs to read the image's data). I was going to use the LZW algorithm to try to do GIFs and PNGs but it fell apart and I never finished working on it. I may provide an update later on supporting PNGs and GIFs. |
BRAVO! Good work :)
|
Hmmm can eventually document makescreenshot2() better, next Graal version will also allow loading saved images (drawingpanel.saveimage()).
Generating images on-the-fly by script is quite interesting though, might need some optimization for big images. The function convertrgbtoascii() is missing though ? |
Quote:
Edited the top post. And these are the functions I was thinking of using instead of the multidimensional arrays: NPC Code: NPC Code: ColorToInt(r, g, b) converts 3 numbers in to it's own unique number (thanks to PFA for that function/idea) IntToColor(i) outputs the r, g, b generated by ColorToInt. |
Looks very nice! Should be *255 though not 256 since color ranges go from 0 - 255 (I know there are 256 posibilities). Example:
PHP Code:
|
| All times are GMT +2. The time now is 11:53 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.