Written on April 9th, 2009 at 12:15 am by

48 Comments

How to take Screenshot of c/c++ graphics program in turbo c without using Windows98

Many face problem of how to take Screenshot of C/C++ graphics program done using Turboc.Especially students.The reason is Print Screen nor any screen Capture software work in Graphics Mode of Turboc.End result not able to show output to their teachers or doing paint work in MS paint :)

Here is a simple solution to it..

1.compile your code.
2.Now select Build All.(compile->Build all)
This will create a Exe of your program in the current working directory.
3.Download DosBox
4.Install it and run the EXE.

dosbox
5.Now you should mount the current working directory of turboc .
For example: type

mount o e:/TCC

mounting dosbox
6.Now TCC folder will be mounted in to a Virtual Drive o.
7.Navigate to virtual drive o.
naviagate
8.Now type the name of the program.

For Example: grpahics.exe

output
9.you can see the output.Now press “print Screen” or use any software to capture the output.For full screen press ALT+ENTER.


Demo of C Graphics Program Running via Dosbox:

C Graphics Program Running via Dosbox

Hope this post helped..
Know any other easier method do let me know..

Want useful tips like this in future too?Dont miss out any updates ,Just Sign Up for Free Newsletter below

Get Free Newsletter
c++ take screenshot, Capturing Graphical Screen C & C++, how to take print out of graphics screen of c, how to take screen shot from c, how to take screenshots in C, screen capture c++ graphics, software for taking screenshots from c++, take screenshot c++, take screenshot in c, turboc graphics program screenshot

48 Responses to “How to take Screenshot of c/c++ graphics program in turbo c without using Windows98”


  1. thegands

    3 years ago

    that is awesome!

    Reply

  2. admin

    3 years ago

    Hope it was useful to you:)

    Reply

  3. Pallab

    3 years ago

    DOSBox can really be a life-saver. Unfortunately even dosbox doesnt work properly in Win7..and graphics program doesn’t work. Do you know any way to run TC 3.0 graphics programs in Win7?

    Reply

  4. admin

    3 years ago

    @pallab

    Sorry i dont know..:cry: I am still to try it on windows 7..But sure will let you know once i find a soluton…

    Reply

  5. Vinayak

    3 years ago

    DOSBOX works really nice, but there is a problem.
    I have an egg catching game, in the first screen the title”EGG GAME” is in calligraphy type of font and has font size of 7 in turbo c++.
    But when I do step 8 i.e., type the name egg.exe the font size is reduced to normal size and even the font type has changed to , i think times roman.Could U please tell me how to rectify it

    Reply

  6. admin

    3 years ago

    I am not sure with the pro..I feel its using the default font ..
    I tried out its working fine..

    Check this snap i took using DOSBOX only

    http://whereismycabin.googlepages.com/font_000.png

    Reply

  7. kuldhir

    3 years ago

    you can use this code
    //Here is a program to save a graphical o/p to bmp
    #include
    #include
    #include
    #include

    int SaveBMP16(char []);
    typedef unsigned char byte;
    typedef unsigned int word;
    typedef unsigned long dword;
    void main()
    {
    /* request auto detection */
    int gdriver;
    int gmode, errorcode;
    detectgraph(&gdriver,&gmode);
    /* initialize graphics and local variables */
    initgraph(&gdriver, &gmode, “c:\\tc\\bgi”);

    errorcode = graphresult();
    if (errorcode != grOk) /* an error occurred */
    exit(1);

    int midx, midy,radius = 100;

    midx = getmaxx() / 2;
    midy = getmaxy() / 2;

    setcolor(getmaxcolor());

    /* draw the circle */
    circle(midx, midy, radius);

    /* clean up */
    SaveBMP16(“Circle.Bmp”);
    }

    struct BMP
    {

    // BitMap File Header
    byte bfType[2]; /* 1 2 must always be set to ‘BM’ to declare that this is a .bmp file.*/
    dword bfSize; /* 3 4 specifies the size of the file in bytes.*/
    word bfReserved1;// 7 2 must always set to zero. */
    word bfReserved2;// 9 2 must always be set to zero.
    dword bfOffset; // 11 4 specifies the offset from the beginning of the file to bitmap data.

    // BitMap Image Header
    dword biSize; // 15 4 specifies the size of the BitMap Header structure, in bytes.
    dword biWidth; // 19 4 specifies the width of image, in pixels.
    dword biHeight; // 23 4 specifies the height of image, in pixels.
    word biPlanes; // 27 2 specifies the number of planes of the target device,must be set to 0
    word biBitCount; // 29 2 specifies the number of bits per pixel.
    dword biCompression; //31 4 Specifies the type of compression, usually set to 0 – No Compres
    dword biSizeImage; // 35 4 specifies the size of the image data, in bytes. If there is no compression, it is valid to set this member to zero.
    dword biXPelsPerMeter; //39 4 specifies the the horizontal pixels per meter on the designated targer device, usually set to zero.
    dword biYPelsPerMeter; // 43 4 specifies the the vertical pixels per meter on the designated targer device, usually set to zero
    dword biClrUsed; // 47 4 specifies the number of colors used in bitmap, if set to 0 number of colors is calculated using the biBitCount member.
    dword biClrImportant; // 51 4 specifies the number of color that are ‘important’ for the bitmap, if set to zero, all colors are important.
    };

    int SaveBMP16(char file[])
    {
    int i=0, j=0, r, g, b;

    FILE *fp;
    BMP *bmp;

    bmp=(BMP *)malloc(54);

    bmp->bfType[0]=’B';
    bmp->bfType[1]=’M';
    bmp->bfSize=153718;
    bmp->bfReserved1=0;
    bmp->bfReserved2=0;
    bmp->bfOffset=118;
    bmp->biSize=40;
    bmp->biWidth=640;
    bmp->biHeight=480;
    bmp->biPlanes=1;
    bmp->biBitCount=4;
    bmp->biCompression=0;
    bmp->biSizeImage=153600; //Fixed Size ?
    bmp->biXPelsPerMeter=0;
    bmp->biYPelsPerMeter=0;
    bmp->biClrUsed=0;
    bmp->biClrImportant=0;

    fp=fopen(file, “wb”);
    if(fp == NULL)
    {
    printf(“File can’t be open”);
    getch();
    return 1;
    }

    fwrite(bmp, 54, 1, fp);
    fseek(fp, 54L, SEEK_SET);

    // Upto Here its OK.

    // Question 1. What do next 16×4 Lines do ?

    fputc(0×0, fp);
    fputc(0×0, fp);
    fputc(0×0, fp);
    fputc(0×0, fp);

    fputc(127, fp);
    fputc(0×0, fp);
    fputc(0×0, fp);
    fputc(0×0, fp);

    fputc(0×0, fp);
    fputc(127, fp);
    fputc(0×0, fp);
    fputc(0×0, fp);

    fputc(127, fp);
    fputc(127, fp);
    fputc(0×0, fp);
    fputc(0×0, fp);

    fputc(0×0, fp);
    fputc(0×0, fp);
    fputc(127, fp);
    fputc(0×0, fp);

    fputc(127, fp);
    fputc(0×0, fp);
    fputc(127, fp);
    fputc(0×0, fp);

    fputc(0×0, fp);
    fputc(192, fp);
    fputc(192, fp);
    fputc(0×0, fp);

    fputc(192, fp);
    fputc(192, fp);
    fputc(192, fp);
    fputc(0×0, fp);

    fputc(128, fp);
    fputc(128, fp);
    fputc(128, fp);
    fputc(0×0, fp);

    fputc(255, fp);
    fputc(0×0, fp);
    fputc(0×0, fp);
    fputc(0×0, fp);

    fputc(0×0, fp);
    fputc(255, fp);
    fputc(0×0, fp);
    fputc(0×0, fp);

    fputc(255, fp);
    fputc(255, fp);
    fputc(0×0, fp);
    fputc(0×0, fp);

    fputc(0×0, fp);
    fputc(0×0, fp);
    fputc(255, fp);
    fputc(0×0, fp);

    fputc(255, fp);
    fputc(0×0, fp);
    fputc(255, fp);
    fputc(0×0, fp);

    fputc(0×0, fp);
    fputc(255, fp);
    fputc(255, fp);
    fputc(0×0, fp);

    fputc(255, fp);
    fputc(255, fp);
    fputc(255, fp);
    fputc(0×0, fp);

    i=0;
    j=479;

    fseek(fp, 118, SEEK_SET);

    while(j>=0)
    {
    i=0;
    while(i<640)
    {
    fputc((getpixel(i, j)<<4) | getpixel(i+1, j), fp); //Que 2. What does this do ? Why Left Shift 4 times and why Bit wise ORing of two pixles.
    i+=2;
    }
    j–;
    }
    free(bmp);
    fclose(fp);
    return 0;
    }

    Reply

  8. admin

    2 years ago

    @kuldhir

    Thanks for the code..I will try it..Will be useful for others too.Hope it works…

    Reply

  9. Sivasakthi

    2 years ago

    Thanks

    Reply

  10. Varun

    2 years ago

    Its giving me error saying BGI error graphics cannot be initailized.bgi error

    although the program works gr8 in the compiler i am doing the same thing as u are doing…

    Reply

  11. masoud

    2 years ago

    thank uuuuuuu so much it was realy nice

    Reply

  12. amrit pal

    2 years ago

    thanx,it really works
    thnx again

    Reply

  13. Student

    2 years ago

    thanks dear for help

    Reply

  14. neha

    2 years ago

    i am having an error

    bgi error graphics not initialized use ‘initgraph’

    plz help

    Reply

  15. Nadeem

    2 years ago

    hey i tried it but it is showing an error as BGI error….what do i do ????? plz give me a solution to it

    Reply

  16. Tushar

    2 years ago

    Hey i m getting problem in thi..
    BGI error is there in Dos BOx..

    Plzzz help me out…

    Reply

  17. Nishant

    2 years ago

    same bgi error dude… help out xD

    Reply

  18. siddharth

    2 years ago

    showing error
    bgi error : graphic are not installed
    what to do now?

    Reply

    • Shunmugha

      2 years ago

      First check out whether your graphics program is getting complied properly without error..Set all library link properly..Then try these steps..

      Reply

  19. siddharth

    2 years ago

    yes, i had given all links properly,and my code and exe also run properly. when trying run on dosbox displys bgi error with graphics are now initialised..
    Plz help me out…

    Reply

  20. pradeep

    2 years ago

    the same bgi error please help…..the pah is alright …the linker setting is also right

    Reply

  21. Kesav

    1 year ago

    BGI Error ….Method For Correcting It

    In your C Program Type
    initgraph(&gdriver, &gmode, “..\\bgi”);

    Mount z C:\TC

    In z: Type cd bin
    z:\bin is pointing C:\TC\BIN and also Ur ..\\bgi pointing c:\tc\bgi

    Then Run Ur Exe File

    Reply

  22. Purnima

    1 year ago

    Thanks alot for your help.. it really works

    Reply

  23. Jacob

    1 year ago

    for bgi error paste EGAVGA.BGI from bgi folder to bin folder in bgi file

    Reply

  24. nia

    1 year ago

    Thanks a ton !!! Now I can use C graphics commands in Vista !!!

    Reply

  25. nadeem ahmad

    1 year ago

    Thank you so much for students help

    Reply

  26. Rushi

    1 year ago

    really very much helpful…thnk u so mcuh..

    Reply

  27. Tanmoy

    1 year ago

    first of all copy the EGAVGA.BGI from bgi folder to bin folder
    Z:\>mount o c:\TC
    Z:\>:o
    o:\>
    o:\>cd bin
    o:\BIN>
    o:\BIN>programname.exe

    Reply

  28. Tushar

    1 year ago

    When I type the name of the graphics file, it says it is an ‘illegal command’
    What’s the problem ?
    The file is located in C:\TC\BIN which is the mounted folder

    ‘”
    o:\>Graphematics.exe
    Illegal Command: Graphematics.exe

    Reply

  29. Tushar

    1 year ago

    And this works with all other .exe files EXCEPT this graphics one? What could be the reason ?

    Reply

  30. Tushar

    1 year ago

    Hey. Everything worked out. I just made a new exe by compiling the cpp and it worked.

    So DOSBOX did help me. But I also need to take a screenshot of the IDE where my code is written (i.e. that blue screen). alt+prntscreen doesn’t help in this case. Nor does DOSBOX. Any help here ?

    Thanks a ton for you help. Much appreciated

    Reply

    • Shunmugha

      1 year ago

      Very Happy that it helped you! You mean the blue turbo C IDE screen right?You can put the IDE screen in windowed mode and take it.Here’s how you can take screenshot of Turbo C IDE blue screen

      1.Minimize the IDE to task bar(ALT + TAB)
      2.In task bar right click Turbo C and go to properties.
      3.In options tab ->Display Options select Window option click ok.In the next window click ok again.
      4.Now in windowed mode ,normal screenshot will work via (alt + PrintScreen)

      Here is an example…

      Screenshot of Turbo C IDE

      Hope it was useful! :)

      Reply

Leave a Reply



Previous Post:

Next Post: