program For Projection of 3D Images
program For Projection of 3D Images
#include<stdio.h>
#include<stdlib.h>
#include<graphics.h>
#include<conio.h>
void draw3d(int fs,int x[20],int y[20],int tx,int ty,int d);
void draw3d(int fs,int x[20],int y[20],int tx,int ty,int d)
{
int i,j,k=0;
for(j=0;j<2;j++)
{
for(i=0;i<fs;i++)
{
if(i!=fs-1)
line(x[i]+tx+k,y[i]+ty-k,x[i+1]+tx+k,y[i+1]+ty-k);
else
line(x[i]+tx+k,y[i]+ty-k,x[0]+tx+k,y[0]+ty-k);
}k=d;
}
for(i=0;i<fs;i++)
{
line(x[i]+tx,y[i]+ty,x[i]+tx+d,y[i]+ty-d);
}
}
void main()
{
int gd=DETECT,gm;
int x[20],y[20],tx=0,ty=0,i,fs,d;
initgraph(&gd,&gm,"");
printf("no of sides(front view only):");
scanf("%d",&fs);
printf("Co-ordinates:");
for(i=0;i<fs;i++)
{
printf("(x%d,y%d)",i,i);
scanf("%d%d",&x[i],&y[i]);
}
printf("Depth");
scanf("%d",&d);
draw3d(fs,x,y,tx,ty,d);
getch();//front view
setcolor(14);
for(i=0;i<fs;i++)
{
if(i!=fs-1)
line(x[i]+200,y[i],x[i+1]+200,y[i+1]);
else
line(x[i]+200,y[i],x[0]+200,y[0]);
}
getch();//top view
for(i=0;i<fs-1;i++)
{
line(x[i],300,x[i+1],300);
line(x[i],300+d*2,x[i+1],300+d*2);
line(x[i],300,x[i],300+d*2);
line(x[i+1],300,x[i+1],300+d*2);
}
getch(); //side view
for(i=0;i<fs-1;i++)
{
line(10,y[i],10,y[i+1]);
line(10+d*2,y[i],10+d*2,y[i+1]);
line(10,y[i],10+d*2,y[i]);
line(10,y[i+1],10+d*2,y[i+1]);
}
getch();
closegraph();
}
OUTPUT:
Top view
//Program for Image Compression
# include<stdio.h>
# include<conio.h>
# include<math.h>
# include<io.h>
# include<alloc.h>
# include<string.h>
# include<process.h>
void main()
{
unsigned int i,j,N,M,k,xt,yt;
unsigned char *L,*gray;
unsigned long int *code;
unsigned long int aux1,aux2,Lmask,act_len,flength;
unsigned char mask,Len;
int ch,ind;
unsigned char ctemp,Ltemp;
char file_name1[14],file_name2[14];
FILE *fptr,*fptro;
clrscr();
printf("enter input file name for compressed image->");
scanf("%s",file_name1);
fptr=fopen(file_name1,"rb");
if(fptr==NULL)
{
printf("\nNO such file exists");
exit(1);
}
printf("\n Enter file name for uncompressed image->");
scanf("%s",file_name2);
k=strcmp(file_name1,file_name2);
if(k==0)
{
printf("\nInput and Output file cannot share the same name");
exit(1);
}
ind=access(file_name2,0);
while(!ind)
{
k=stricmp(file_name1,file_name2);
if(k==0)
{
gotoxy(1,8);
printf("Input and Output files cannot share the same name");
exit(1);
}
gotoxy(1,4);
printf("file exists.Wish to continue?(y or n)-->");
while(((ch=getch())!='y')&&(ch!='n'));
putch(ch);
switch(ch)
{
case 'y':
ind=1;
break;
case 'n':
gotoxy(1,4);
printf(" ");
gotoxy(1,3);
printf(" ");
gotoxy(1,3);
printf("Enter the file name");
scanf("%s",file_name2);
ind=access(file_name2,0);
}
}
fptro=fopen(file_name2,"wb");
xt=wherex();
yt=wherey();
gotoxy(70,25);
textattr(RED+(LIGHTGRAY<<4)+BLINK);
cputs("WAIT");
act_len=0;
M=8*sizeof(long int)-8;
for(i=0;i<4;i++)
{
ch=getc(fptr);
aux1=(unsigned long int)ch;
aux1<<=M;
act_len=aux1;
aux1=(long int)0;
M=8;
}
N=getc(fptr);
gray=(unsigned char*)malloc(N*sizeof(char));
L=(unsigned char*)malloc(N*sizeof(char));
code=(unsigned long int*)malloc(N*sizeof(long int));
for(i=0;i<N;i++)
gray[i]=getc(fptr);
for(i=0;i<N;i++)
L[i]=getc(fptr);
mask=128;
Len=0;
aux2=0;
aux1=0;
ind=1;
i=0;
while(ind)
{
ch=getc(fptr);
for(k=0;k<8;k++)
{
aux1=ch&mask;
ch<<1;
aux2<<=1;
if(aux1!=0)
aux2=1;
Len++;
if(Len==L[i])
{
code[i]=aux2;
aux2=0;
Len=0;
i++;
if(i==N)
{
ind=0;
break;
}
}
}
}
Len=0;
aux2=aux2=0;
flength=0;
mask=128;
ind=1;
while(ind)
{
ch=getc(fptr);
for(k=0;k<8;k++)
{
if(flength>act_len)
{
ind=0;
break;
}
aux1=(ch&mask);
ch<<=1;
aux2<<=1;
if(aux1!=0)
aux2=1;
Len++;
for(j=0;j<N;j++)
{
if(L[j]>Len)
break;
printf("file exists.Wish to continue?(y or n)-->");
while(((ch=getch())!='y')&&(ch!='n'));
putch(ch);
switch(ch)
{
case 'y':
ind=1;
break;
case 'n':
gotoxy(1,4);
printf(" ");
gotoxy(1,3);
printf(" ");
gotoxy(1,3);
printf("Enter the file name");
scanf("%s",file_name2);
ind=access(file_name2,0);
}
}
fptro=fopen(file_name2,"wb");
xt=wherex();
yt=wherey();
gotoxy(70,25);
textattr(RED+(LIGHTGRAY<<4)+BLINK);
cputs("WAIT");
act_len=0;
M=8*sizeof(long int)-8;
for(i=0;i<4;i++)
{
ch=getc(fptr);
aux1=(unsigned long int)ch;
aux1<<=M;
act_len=aux1;
aux1=(long int)0;
M=8;
}
N=getc(fptr);
gray=(unsigned char*)malloc(N*sizeof(char));
L=(unsigned char*)malloc(N*sizeof(char));
code=(unsigned long int*)malloc(N*sizeof(long int));
for(i=0;i<N;i++)
gray[i]=getc(fptr);
for(i=0;i<N;i++)
L[i]=getc(fptr);
mask=128;
Len=0;
aux2=0;
aux1=0;
ind=1;
i=0;
while(ind)
{
ch=getc(fptr);
for(k=0;k<8;k++)
{
aux1=ch&mask;
ch<<1;
aux2<<=1;
if(aux1!=0)
aux2=1;
Len++;
if(Len==L[i])
{
code[i]=aux2;
aux2=0;
Len=0;
i++;
if(i==N)
{
ind=0;
break;
}
}
}
}
Len=0;
aux2=aux2=0;
flength=0;
mask=128;
ind=1;
while(ind)
{
ch=getc(fptr);
for(k=0;k<8;k++)
{
if(flength>act_len)
{
ind=0;
break;
}
aux1=(ch&mask);
ch<<=1;
aux2<<=1;
if(aux1!=0)
aux2=1;
Len++;
for(j=0;j<N;j++)
{
if(L[j]>Len)
break;
if(L[j]==Len)
{
if(code[j]==aux2)
{
aux2=0;
putc((int)gray[j],fptro);
Len=0;
break;
}
}
}
flength++;
}
}
gotoxy(70,25);
textattr(WHITE+(BLACK<<4));
cputs(" ");
gotoxy(xt,yt);
printf("\n Done decoding");
fcloseall();
getch();
}
OUTPUT:
Done decoding
SIMPLE SAMPLE FLASH PROGRAM
AIM:
TOOLS
FLASH WORKSPACE
TWEENING MOTION
AFTER TWEENING MOTION
RESULT:
SIMPLE PHOTOSHOP USING ADOBE
AIM:
TOOLS
PHOTOSHOP
AFTER MERGING
RESULT: