Thread: incremental save

  1. #1
    Registered User
    Join Date
    May 2005
    Posts
    3

    incremental save

    Hi, I`m a beginner in c/c++. I wrote a program with MSVC with allegro library which draws some graphics and then saves it from a buffer to a bitmap file. I want to save incremental filename bmp like 0000.bmp , 0001.bmp 0002.bmp etc. with an animation but I dont seem to find any references to how to do it. So could you please help me?

    I thought that something like this might do the job but it faild:

    Code:
    string my_string1 = a_int_variable
    string my_string2 = ".bmp";
    string my_string3 = my_string1 + my_string2;
    
    save_bitmap(my_string3, theBuffer, desktop_palette);
    I use to code with proce55ing in which, to do this kind of job i just have to write saveFrame("name-####.tga"); to get name-0001.tga , name-0002.tga etc.

    is there any simple way to do this? (sorry if my english is bad)

    Thx!

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    wsprintf would do this
    Code:
    int FrameNumber=0;
    char FileName[MAX_PATH];
    ...
    wsprintf(FileName, "%03d.bmp", FrameNumber);

  3. #3
    Registered User
    Join Date
    May 2005
    Posts
    3
    thx for the respnse.

    wsprintf declared in Winuser.h and included in Windows.h,

    after trying to compile the code i get " : error C2371: 'BITMAP' : redefinition; different basic types" because BITMAP seems to appear in windows.h and in allegro.h

    how can I use wsprintf and allegro library without this conflict?

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Why bother? Just use sprintf or the string class.

    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    Registered User
    Join Date
    May 2005
    Posts
    3
    Thank you very much!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Save vs Save As.... OPENFILENAME flags
    By csonx_p in forum Windows Programming
    Replies: 16
    Last Post: 06-01-2008, 02:42 PM
  2. save and save as functions
    By willc0de4food in forum Windows Programming
    Replies: 2
    Last Post: 06-29-2005, 02:49 AM
  3. save webpage? some save some not
    By kryptkat in forum Tech Board
    Replies: 3
    Last Post: 06-07-2005, 09:21 AM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  5. Major glitch losing source files with MSVC++ and WinXP
    By JasonD in forum C++ Programming
    Replies: 10
    Last Post: 08-14-2003, 12:15 PM