The problem I am having with this code is that i cannot see the full images i am using in the program (in other words, i would like the user to know what image he/she is viewing on the screen). Can someone help me please.
#include<graphics.h>
#include <stdlib.h>
#include<string.h>
#include <process.h>
#include <stdio.h>
#include <conio.h>
#include<dos.h>
#include<alloc.h>
#define C 10
#define F 2
#define T 15
FILE *f;
class Vwindow
{
void far *p;
int x;
int y;
int xf;
int yf;
public:
void LFree();
void init(int xx, int yy, int xxf, int yyf);
void capture();
void show();
void Imagen();
void Put_image();
};
void Vwindow::init(int xx, int yy, int xxf, int yyf)
{
x=xx;
y=yy;
yf=yyf;
xf=xxf;
}
void Vwindow::Imagen() {// function for my bmp image
int gd=DETECT,gm;
int y=0,x=0;
unsigned char bit1,bit2,bit;
//initgraph(&gd,&gm,"C:\\tc\\bgi");
f=fopen("pic.bmp","r");
fseek(f,0x76,0);
while(!feof(f))
{
bit=fgetc(f);
bit1=bit>>4;
bit2=(bit<<4)>>4;
putpixel(x++,y,bit1);
putpixel(x++,y,bit2);
if (x>=xf)
{
x=0;y++;
}
}
}
void Vwindow::capture()
{
unsigned tsize;
tsize=imagesize(x-3,y-3,xf+3,yf+3);
if ((p = farmalloc(tsize)) == NULL)
{
outtextxy(10,10,"No memory..!");
}
else
{
getimage(x,y,xf,yf,p);
}
}
void Vwindow::Put_image()
{
putimage(x,y,p,1);
}
void Vwindow::LFree()//free
{
farfree(p);
}
void Start_GMode();//START GRAPHIC MODE
void main()
{
int x=1;
int y=1;
int xf=42;
int yf=73;
Vwindow vn;
Start_GMode();
vn.init(x,y,xf,yf);
vn.Imagen();
vn.capture();
cleardevice();
outtextxy(10,1,"Hello World");
outtextxy(10,60,"Hello world");
outtextxy(10,110,"Hello World");
while(x<=251)
{
vn.init(x,y,xf,yf);
vn.Put_image();
delay(100);
vn.Put_image();
if(x==251)
{
if(y<=101)
{
x=1;
y+=50;
}
}
x+=10;
}
getch();
vn.LFree();
closegraph();
}
void Start_GMode()
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
/* initialize graphics mode */
initgraph(&gdriver, &gmode, "t:\\tc\\bgi");
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* return with error code */
}
}
Attached File(s)
-
project.zip (11.87K)
Number of downloads: 400

New Topic/Question
Reply




MultiQuote




|