draw line function

This is a discussion on draw line function within the C Programming forums, part of the General Programming Boards category; how can i let the user draw lines by clicking on the screen once and the line always be seen ...

  1. #1
    yakir
    Guest

    draw line function

    how can i let the user draw lines by clicking on the screen once and the line always be seen from that point to the mouse without erase the background - i tried to allocate the screen so i could return to the background everytime the mouse moves and print the line on it.. but the allocation is too big for the memory..

  2. #2
    yakir
    Guest

    so...

    (borland c)
    what should i do then??

  3. #3
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    (borland c)
    what should i do then??
    You sure like to keep us guessing. Borland C. which version? what operating system? are you writing a gdi windows program, a console program,a dos program,a bgi program. If you really want help from us then help us to help you by giving us the correct information.
    What code do you have so far? what exactly about your code isnt working. My c/c++ skills are ok but my telepathy and psychic skills leave much to be desired.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  4. #4
    yakir
    Guest

    very sorry: please help me....

    borland c 3.1
    os: windows xp
    a dos program

    sorry about not giving the information earlier...

    here is a simple code that i tried that fails at the allocation part because of low memory....

    the resulution is 640,480;

    void main()
    {
    graphics(); //calls initgraph
    openscr(); //draws an image on screen
    unsigned int picsize;
    void *pic;
    picsize=imagesize(0,0,400,400);
    pic=malloc (picsize);
    if (!pic) printf ("memory error");
    getimage (0,0,400,400);
    cleardevice();
    setbkcolor(0);
    getch();
    putimage (0,0,pic,XOR_PUT);
    getch();
    free (pic);
    }

    it succeed to allocate 300*300 but not a larger part of screen such as 400*400;

  5. #5
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    As Salem said, an newer compiler is the best solution.

    But you could try:
    Code:
    #include <alloc.h>
    int main()
    { 
    graphics(); //calls initgraph
    openscr(); //draws an image on screen
    unsigned int picsize;
    void far *pic;
    picsize=imagesize(0,0,400,400);
    pic=farmalloc ((unsigned long) picsize);
    if (!pic) printf ("memory error");
    getimage (0,0,400,400);
    cleardevice();
    setbkcolor(0);
    getch(); 
    putimage (0,0,pic,XOR_PUT);
    getch();
    farfree (pic);
    return 0;
    }

  6. #6
    yakir
    Guest

    thanks a lot!!!!!!

    thank you salem and you swoopy: thank you both for your time!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM
  2. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  3. c++ linking problem for x11
    By kron in forum Linux Programming
    Replies: 1
    Last Post: 11-19-2004, 10:18 AM
  4. Replies: 5
    Last Post: 02-08-2003, 07:42 PM
  5. Draw Line Between Two Points
    By Shadow12345 in forum C++ Programming
    Replies: 4
    Last Post: 05-18-2002, 09:23 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21