The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX => Topic started by: IXFURU on January 07, 2017, 11:23:42 AM

Title: Screenshot Request
Post by: IXFURU on January 07, 2017, 11:23:42 AM
Over the years of RPGMaking, I've become aware of several screenshot scripts.  There is one that even takes shots of the entire map (though that one is for ACE).  I'm able to code a bit, but I've never really understood the way screenshots are taken, even after studying the afore-mentioned scripts.  I've come to the point in one of my projects, where I need a screenshot script of a specific type, and I've been unable to find one that will work, or that I can edit myself to do as I require it to.  Here's the gist of what I'm searching for:

-VX script (RGSS2)
-must take a screenshot, regardless of what scene the game's state is in (Like ModernAlgebra's does)
-must only take a shot of an 'area' of the screen, instead of the entire screen
-when activated, the system will take into account the arguments passed (x, y, width, height, directory), and set the screenshot area to those coordinates and dimensions
-once taken, the script must send the image of the area screenshot to a directory that is passed as the fifth argument

Basically, I could use a script call:

Code: [Select]
area_screenshot(20, 60, 200, 200, "Picture")

That example would take a screenshot of the screen area at x20, y60, be 200 pixels wide and 200 pixels tall.  It would then export the image taken to the 'Graphics/Picture' directory.

I have no preference if this is a new script or if it is an edited version of an existing script.  For instance, if you can take ModernAlgebra's script, and tweak it to allow for such a script call, then that would be fine.  In this case, credit would be given to both the original author and to the one who edited the script. 

I appreciate any assistance that I get on this request.
Title: Re: Screenshot Request
Post by: XaXaV on July 28, 2017, 01:36:35 PM
$2 and I code it.
Title: Re: Screenshot Request
Post by: IXFURU on July 31, 2017, 10:20:35 PM
$2? 

Well.  I guess I'll just stick with layering sprites for now.  Thanks though.
Title: Re: Screenshot Request
Post by: XaXaV on July 31, 2017, 11:58:03 PM
Just kidding. :D

Here it is. :)

https://pastebin.com/UrbmSznS (https://pastebin.com/UrbmSznS)
Title: Re: Screenshot Request
Post by: IXFURU on August 01, 2017, 01:42:38 PM
Wth is that?  Didn't bother.  As a scripter, I could tell this was another joke.  Doesn't matter.  Hijacked my thread is all.  I can make do with what my current methods.  Er..  Thanks.
Title: Re: Screenshot Request
Post by: XaXaV on August 01, 2017, 02:35:13 PM
For a scripter you're not very good, I may say. Sorry. ;)
The blob in the beginning of the script is a Base64-encoded data, which contains the DLL needed for the script to work.

Sure, I coded it in like 10 minutes, but it's harsh to tell me you didn't bother...
Just try it. You'll be surprised. If you don't trust my code, ask Modern Algebra about it. :)
Title: Re: Screenshot Request
Post by: IXFURU on August 01, 2017, 04:10:14 PM
Ouch!  I'm not very good? 

Full of hurtful comments and pranks.  I'm not the best.  I've seen your other work.  You're pretty good man.  It just didn't look legit to about the 1200th line.   MA coded the screenshot script with no such lines, let alone 1200. 

I will look at it again...*sighs*
Title: Re: Screenshot Request
Post by: XaXaV on August 01, 2017, 04:59:23 PM
I said that you're not good, cuz' I got angry when you said it's just "another joke". Sorry. :)

The main reason for the script to be that big is because of the Base64-encoded DLL data.
For me it's easier to embed the DLL in the script itself and have it extract it on run-time. (Doesn't slow down anything.)
If I haven't embedded the DLL in it the script would be just a non-working script without it.
For me it's better to do so than give the script and a link to a DLL file which will eventually be removed at some point in time.
I call this a stand-alone script. No other downloads needed. :)

Just try it, man. Trust me, it works. :)
Title: Re: Screenshot Request
Post by: IXFURU on August 02, 2017, 09:58:46 AM
Ahh.  Very cool.  It's all good man.  I'm rather skeptical of folks on RM sites these days.  I apologize for previous comments.

The script works well.  2 Questions.

What is the 'mode' argument for?

Would it be possible to set a 'color' as transparent.  Say the first pixel in the upper left hand corner of the image?  If not, it's cool just the same.

Great work man!  And thank you.
Title: Re: Screenshot Request
Post by: XaXaV on August 02, 2017, 10:21:30 AM
It's all cool, man. I apologize too. I was rude, sorry. :)

The "mode" argument can be 0, 1 and 2 and it affects the quality of the screenshot.
0 is what I call the "full mode". It's "what you see it's what you get". Applies no compression on the output image.
1 is the "good mode". Compresses the output and lowers the quality.
2 is the "best mode". Slight compression and good quality.
Basically, in a normal game you would use mode 0. I have different modes because I use this for lots of different
stuff like my Streaming script which would use mode 1 for a lower image size therefore faster network traffic.

For the other question, I'm not really sure what you mean, but yes. I can do everything, basically.
Just explain it a bit more. :)
Title: Re: Screenshot Request
Post by: IXFURU on August 02, 2017, 04:08:30 PM
Well.  Typically PNG's can have transparent parts, so that when they are layered, The parts can be changed without covering up parts behind it.   This script will be part of a system which allows players to design images of characters, faces, weapons, etc., with layered PNGs.  When they've completed it, they click finish or whatever and the system captures the area on the screen where their parts have been layered.  The issue therefore is that the screenshot will capture the background as well.  My idea is to set the background to a color, then, when the screenshot occurs, set that background color to transparent.  That's why I suggested the first 0,0 coordinate, because it will just be part of the background anyway.
Title: Re: Screenshot Request
Post by: XaXaV on August 02, 2017, 04:17:35 PM
I see. Well, I can make it so. But for a system like this you won't even need such a screenshot script, since you can do it all with just bitmaps. You can make a clear bitmap, layer the parts, draw them on the bitmap and then export the bitmap to a .PNG file.
It'd be easier. :)
Title: Re: Screenshot Request
Post by: IXFURU on August 03, 2017, 01:44:53 AM
So, as long as the bitmap is blank it will preserve the transparency?
Title: Re: Screenshot Request
Post by: XaXaV on August 03, 2017, 10:42:48 AM
Exactly. It renders to a file as it is.
Title: Re: Screenshot Request
Post by: Zeriab on August 03, 2017, 08:04:41 PM
I like how you've included the DLL in the script itself. Good job :D
Title: Re: Screenshot Request
Post by: IXFURU on August 03, 2017, 08:35:12 PM
You know I hear and see a lot about DLLs.  Guess I don't really understand what they are and what they do exactly.  Also, why was it necrssary to implement them in the script?  Would it not have worked without it?  And lastly, Do you have to type all those letters and such out by hand?  That seems really confusing.

And Xaxav: 

Explaina bit about how to code this using Bitmap.  I've created and exported text files before.  They are relatively easy.  This is what I'm imagining the code would look like:

Code: [Select]
bmp = Bitmap.new (width, height)
<do the layering here, possibly using the blt method>
file = File.open (filename, w+)
<somehow attach the bmp to the file here>
file.close

It's the attaching to bitmap that I don't quite get....
Title: Re: Screenshot Request
Post by: XaXaV on August 03, 2017, 09:24:48 PM
DLLs are simply application extensions. They extend the functionality of a program or an application.
They are written in C or C++ and act faster than the RGSS in most cases. People use them in RGSS for lots of stuff,
because RGSS isn't as the standard Ruby where you could just "require" a library and use it.
A lot to say, but basically DLLs extend the functionality of the RGSS where it could not do it on it's own.

The script I wrote uses a DLL which makes screenshots of the game faster than most of the other scripts.
And plus, it handles desired area capturing and image quality. It won't work without it. Of course, I can code a script
that can make screenshots without the help of a DLL too. :)
No, I didn't type that blob manually. I use the Ruby Array #pack method to pack it into a Base64 string.

To code the thing you want using Bitmaps is really easy actually.
You just do what you do on the Bitmap (using the #blt method to do the layering) and then
you convert the Bitmap data to a PNG or a BMP format by a method, which I can give you a script for if you
want to. And then save it to a file.
Title: Re: Screenshot Request
Post by: IXFURU on August 03, 2017, 10:27:33 PM
I can only code in Ruby.  For years I've wanted to code without using the RGSS, but I've downloaded a bunch of stuff that just seems foreign if I want to make a game.  Is there a program that essentially acts like the script editor and compiles the code?  I remember being devastated when MV switched feom Ruby, because it left me back at square one.  And that sucked after self-teaching myself Ruby.  I was even upset by the alterations of the way Ace handled windows and Scenes, but I learned a bit to code with it nonetheless. 

Anyway, yeah, if you have time and don't mind making the PNG scriptlet method or whatever that would be cool.  But understand you've done enough and I appreciate it.
Title: Re: Screenshot Request
Post by: yuyu! on August 04, 2017, 12:06:57 AM
Seems like the two biggest coding learning curves are the initial programmer-logic curve and the jumping-to-a-new-language curve. :P I'm still having trouble connecting the dots and relating the languages I've learned (to various degrees).

I think someone made a new language that is similar to Ruby (?) but converts the code to javascript. If you ever get MV, it might be worth checking out!

https://forums.rpgmakerweb.com/index.php?threads/sapphirescript-a-new-language-to-make-rmmv-plugins.78530/
Title: Re: Screenshot Request
Post by: IXFURU on August 04, 2017, 09:16:56 AM
That's really cool yuyu!  I had no idea this existed!   I probably still need to learn JavaScript at some point, but this definitely resembles Ruby and looks like the script editor I'm used to.  Thanks for the info and the link.