Click to See Complete Forum and Search --> : export graph to ANY image format


melzeiny
April 16th, 2008, 09:19 AM
Hi All,
I am new in C++ programming, and I got this sample code from the internet to draw a bar chart , however . I need instead of drawing this chart on the screen I need to export it to ANY image format what so ever on my hard disk. Any one?? :D
here is the sample code



//Author: Karanth Srihari
//Email ID: hari_karanth@indiatimes.com

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<graphics.h>

int values[10],n;

void ingraph()
{
int i;
setbkcolor(9);
settextstyle(4,0,5);
outtextxy(160,5,"BAR GRAPH");
settextstyle(3,0,2);
outtextxy(300,450,"X-AXIS");
settextstyle(3,1,2); 
outtextxy(30,200,"Y-AXIS");
line(100,60,100,400);
line(100,400,500,400);
for(i=120;i<500;i+=20)
line(i,400,i,405);
for(i=300;i>60;i-=20)
line(100,i,95,i);
line(500,398,500,402);
line(504,400,500,398);
line(500,402,504,400);
line(98,60,102,60);
line(100,56,98,60);
line(100,56,102,60);
}

drawgraph()
{
int i,j;
for(i=0,j=115;i<n;j+=20,i++)
rectangle(j,(400-values[i]),(j+12),400);
}


void main()
{
int d=0,m=0,i;
clrscr();
initgraph(&d,&m,"c:\\tc");
printf("ENTER NUMBER OF OBJECTS::\n");
scanf("%d",&n);
printf("ENTER THE VALUES::\n");
for(i=0;i<n;i++)
scanf("%d",&values[i]);
cleardevice();
ingraph();
drawgraph();
getch();
closegraph();
}

Lindley
April 16th, 2008, 11:33 AM
The easiest image format to export to is ppm (google it), but that takes up large amounts of space. I suggest looking into libpng if you want some actual compression.

melzeiny
April 17th, 2008, 03:57 AM
yeah but my problem is the code to export to whatever format , could you help me with that???

Syslock
April 17th, 2008, 09:42 PM
Your request is a bit unrealistic to export to any format.

Try the FreeImage library.

melzeiny
April 20th, 2008, 05:06 AM
sorry, i might have not been very clear, what i meant is that i will be satisfiesd with exporting to one format , but i have no reservations on what format it would be.. the only requirement is -as much as possible- to use the only included libraries in the mentioned code.
thanks very much