1. Hey! Guest! The 36th GMC Jam will take place between February 27th, 12:00 UTC - March 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

Question - Code How does gif_save_buffer actually work?

Discussion in 'GameMaker Studio 2 Community Tech Support' started by Andrew Armstrong, Jan 28, 2020.

  1. Andrew Armstrong

    Andrew Armstrong Member

    Joined:
    Sep 24, 2016
    Posts:
    14
    I've got a pretty decent gif record code setup so that I can press a button and it will record the next 5 seconds of gameplay and save a gif via the gif_save() function. That's all fine and dandy! :)

    What I'd like to learn more about now is the gif_save_buffer() function. Are there any examples out there of how this works? The documentation shows I can save a completed gif to a buffer by doing something like:

    Code:
    global.capture_buff = gif_save_buffer(gif_image);
    From there, I have no idea how to use that.

    My next goal is to create a sort of always-recording "instant replay" system with the intention of being able to hit a button and then it would save the past 5 seconds, rather than the next 5 seconds. Will this buffer function allow me to do that sort of thing?

    Thanks for reading, cheers!
     
  2. gnysek

    gnysek Member

    Joined:
    Jun 20, 2016
    Posts:
    1,381
    Have you tried the whole example from docs ? Below saves 30 frames of game only if application surface is enabled.

    Code:
    if save_gif == true
    {
    if count == 0
        {
        gif_image = gif_open(room_width, room_height);
        }
    else if count < 30
        {
        gif_add_surface(gif_image, application_surface, 6/100);
        }
    else
        {
        global.capture_buff = gif_save_buffer(gif_image);
        count = 0;
        save_gif = false;
        }
    count++;
    }
     
  3. Andrew Armstrong

    Andrew Armstrong Member

    Joined:
    Sep 24, 2016
    Posts:
    14
    Hi thanks! Yeah, I did read the full example, and was using it successfully with the regular gif_save() function variation. I just didn't (and still don't) understand how the gif_save_buffer() function worked specifically.

    Anyway, I ended up finding a solution to my issue through Nocturnes fantastic marketplace asset "GIFCam". I very much recommend using this if you're doing anything similar. Tah dah!
    https://marketplace.yoyogames.com/assets/7865/gifcam
     

Share This Page