save the content of polygon to 2d char array buffer for storing pixels - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

save the content of polygon to 2d char array buffer for storing pixels

Hi All,
I have written code for draw a regular polygon for drawing rectangle, pentagon , hexagon etc.
Now i want to save the content of polygon to 2d char array buffer for storing pixels and save it into a bitmap image file.

But i am not able to do this.
please anyone can help me.


Thanks & Regards
Anuj Awasthi.


Comments

  • Malcolm_McLeanMalcolm_McLean Posts: 254Member ✭✭
    : Hi All,
    : I have written code for draw a regular polygon for drawing
    : rectangle, pentagon , hexagon etc.
    : Now i want to save the content of polygon to 2d char array buffer
    : for storing pixels and save it into a bitmap image file.
    :
    : But i am not able to do this.
    : please anyone can help me.
    :
    Don't try.
    Allocate a buffer of width * height

    by
    char *buff = malloc(width * height);

    now you can access the pixels like this

    buff[y*width+x] = val;

    You will need to call a getpixel or similar routine to read the pixel values off the screen, then place them in your buffer. You might need to look up the colour in the palette to convert from rgb values to palette indices.

    There is a routine on my website that save .bmp files. Look under the "Basic Algorithms" source code link.
Sign In or Register to comment.