Thread: graphics.h under Turbo C

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    4

    Question graphics in Turbo C

    Hi,

    Ok,sorry if this is too DOS-centered..

    This may sound stupid ..but is there any way i can save images drawn in graphics mode as a real image file..
    which can be accesed by other programs in graphics mode..

    ( being accessed by something like PAINT is too much to ask..)

    Also ,can I define my own custom colours..If yes,how?!

    Thanx!
    Last edited by newbie17; 10-23-2001 at 03:02 AM.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > but is there any way i can save images drawn in graphics mode as a real image file
    The getimage function would be a place to start.

    > Also ,can I define my own custom colours..If yes,how?
    Try the setpalette function
    There seem to be several to choose from.

    Open the graphics.h file in a text editor, and read the manual page for each function.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Unregistered
    Guest
    If u want to save it as BMP or something, u need to study header for the extension.
    And save the file according to that.

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    4

    Unhappy graphics.h

    hi..,

    Ok, i should have specified while asking..sorry!

    Actually,using getimage() saves the image in a block of memory ..
    Now,as this data is stored in the memory whose starting point is known to me,can i save this image in the same way in the file?

    Also,as the above user said,how do i do that?!

    And..setpalette() just changes the value of the colour you specify to one of the existing colours..I want to assign it a new colour,which is not part of the existing palette..!

    can i define such a colour?

    Please help!

  5. #5
    Registered User Zeeshan's Avatar
    Join Date
    Oct 2001
    Location
    London, United Kingdom
    Posts
    226
    Hey,
    The graphics.h in Turbo C/C++ uses BGI graphics. The drivers for color modes higher than 16 colors are very difficult to find and won't run on most computers.
    My suggestion is to write your own graphics library. First you'll have to learn the MCGA 300x200x256 mode. It supports 256 different colors.
    On the other hand, in TC/TC++ there ARE only 16 colors, you can't define a new color, hence, only use these 16 colors. You can only change the position of these 16 colors in the palette.

    To get the best tutorials on MCGA mode, see the Links Section of this site.

    You can also find information on you to read in a 256 colors .bmp file in DOS in the links section. Proceeding in the opposite direction will enable you to save your own graphics into PAINT's .bmp files.

  6. #6
    Registered User Zeeshan's Avatar
    Join Date
    Oct 2001
    Location
    London, United Kingdom
    Posts
    226
    Ok, sorry, incomplete answer

    If you just want to save your 16-color graphics obtained through getimage...

    You can do so, by sending all the data to a binary-mode file...through fwrite....

  7. #7
    Disagreeably Disagreeable
    Join Date
    Aug 2001
    Posts
    711
    Well, you could just spin up your own format. Like, use a hex value between 0 and F to stand for each of the 16 different colors.

    To make an image, just write a loop that goes to each pixel and reads what the color is. Dump it into a file.

    To display your images, just open the file, and make a loop that reads each hex value and writes the respective color of pixel to the screen.

    If you want it to be supported by other image viewers, you could check out an archive called bgi2bmp. I'm sure a simple search on google would locate it.

  8. #8
    Registered User Sunny's Avatar
    Join Date
    Nov 2001
    Posts
    101

    Smile

    ..hmm..

    I do a have a bgi driver that sets to 256 colors in dos and high res. Tell me if u need it. I also have the source code ( in assembly ) for displaying bmp files. You could use it for saving also.
    Tell me if you need it.
    Yes...YES!!! I did it! Ha ha ha...I'm king of the world...No..No..please-wait-no...!!!!-- This program has performed an illegal operation AND WILL be shut down....Ack-Choking..help...ack..

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Remember Turbo? It is comming back
    By Mario F. in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 08-14-2006, 01:26 PM
  2. Turbo Assembler
    By darkknight1984 in forum Tech Board
    Replies: 2
    Last Post: 03-10-2005, 01:05 PM
  3. Replies: 4
    Last Post: 11-22-2003, 09:06 AM
  4. STEP turbo C 3.0 >< Borland 5.02
    By Huh..... in forum C Programming
    Replies: 0
    Last Post: 03-12-2002, 07:54 AM
  5. graphics.h
    By Seti in forum C++ Programming
    Replies: 2
    Last Post: 02-28-2002, 04:11 PM