I need C code or program to save the output of the following program into a jpg file(any picture file)?
i need to save the output of this program in to a picture file..i need to take printouts of those output..help me with the code that does the above thing...
this program is just a program to draw straight line using DDA algorithm

#include<graphics.h>
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<dos.h>
#define ROUND(a)((int)(a+0.5))
void dda(int,int,int,int);
void main()
{
int gdriver=DETECT,gmode;
int x1,y1,x2,y2;
initgraph(&gdriver,&gmode,"c:\\tc\\bgi...
printf("Enter the starting and ending coordinates of line:");
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
dda(x1,y1,x2,y2);
getch();
}
void dda(int xa,int ya,int xb,int yb)
{
int dx,dy,steps,k;
float xinc,yinc,x,y;
dx=xb-xa;
dy=yb-ya;
if(abs(dx)>abs(dy))
steps=abs(dx);
else
steps=abs(dy);
xinc=dx/(float)steps;
yinc=dy/(float)steps;
x=xa;
y=ya;
putpixel(ROUND(x),ROUND(y),1);
for(k=1;k<=steps;k++)
{
x=x+xinc;
y=y+yinc;
delay(10);
putpixel(ROUND(x),ROUND(y),1);
}
}

You have to use TurboC or TurboC++ compilers to use either of those links. graphics.h is obsolete and not supported by all other compilers.

I don't really know the answer to the question but I think it will be pretty complicated. Here is the jpg file format and here are other possible google links that may be useful.

I think you must choose .bmp file instead of jpg, as jpg files are difficiult to read and hence write. On the other hand .bmp files are easy to read and write. But they take much more strorage as compared to jpg files (no compression in .bmp files). you should go for 4-bits .bmp file. I can tell you its all about the header of bmp file, onces you understand the header its easy to read and write the file.

Best of luck

It gets stored in a memory block of your choice.
You then need to write that out to a BMP file, along with the correct BMP header.

This question has already been answered. Start a new discussion instead.