C语言pcx文件显示不出来
#include<io.h>
#include<stdio.h>
#include<dos.h>
#include<string.h>
#include<math.h>
#include<stdio.h>
#include<bios.h>
#include<mem.h>
#include<fcntl.h>
#include<stdlib.h>
#include<conio.h>
#define SCREEN_HEIGHT 200
#define SCREEN_WIDTH 320
#define PALETTE_MASK 0x3c6
#define PALETTE_REGISTER_RD 0x3c7
#define PALETTE_REGISTER_WR 0x3c8
#define PALETTE_DATA 0x3c9
#define VGA256 0x13
#define TEXT_MODE 0x03
unsigned char far *video_buffer=(char far *)0xA0000000L;
typedef struct pcx_header_typ
{
char manufacturer;
char version;
char encoding;
char bits_per_pixel;
int x,y;
int width,height;
int horz_res;
int vert_res;
char ega_palette[48];
char reserved;
char num_color_planes;
int bytes_per_line;
int palette_type;
char padding[58];
} pcx_header, *pcx_header_ptr;
typedef struct RGB_color_typ
{
unsigned char red;
unsigned char green;
unsigned char blue;
}RGB_color,*RGB_color_ptr;
typedef struct pcx_picture_typ
{
pcx_header header;
RGB_color palette[256];
char far *buffer;
} pcx_picture, *pcx_picture_ptr;
void Set_Palette_Register(int index,RGB_color_ptr color)
{
outp(PALETTE_MASK,0xff);
outp(PALETTE_REGISTER_WR,index);
outp(PALETTE_DATA,color->red);
outp(PALETTE_DATA,color->green);
outp(PALETTE_DATA,color->blue);
}
void PCX_Load_Screen(char *filename,int enable_palette)
{
// this function loads a pcx file into a picture structure, the actual image
// data for the pcx file is decompressed and expanded into a secondary buffer
// within the picture structure, the separate images can be grabbed from this
// buffer later. also the header and palette are loaded
FILE *fp;
int num_bytes,index;
unsigned int count;
unsigned char data;
RGB_color palette[256];
// open the file
fp = fopen("tu.pcx","rb");
fseek(fp,128L,SEEK_SET);
// load the data and decompress into buffer
count=0;
while(count<=(unsigned int)SCREEN_WIDTH * SCREEN_HEIGHT)
{
// get the first piece of data
data = getc(fp);
// is this a rle?
if (data>=192 && data<=255)
{
// how many bytes in run?
num_bytes = data-192;
// get the actual data for the run
data = getc(fp);
// replicate data in buffer num_bytes times
while(num_bytes-->0)
{
// image->buffer[count++] = data;
video_buffer[count++]=data;
} // end while
} // end if rle
else
{
// actual data, just copy it into buffer at next location
//image->buffer[count++] = data;
video_buffer[count++]=data;
} // end else not rle
} // end while
for (index=0; index<256; index++)
{
// get the red component
palette[index].red = (getc(fp) >> 2);
// get the green component
palette[index].green = (getc(fp) >> 2);
// get the blue component
palette[index].blue = (getc(fp) >> 2);
} // end for index
fclose(fp);
// change the palette to newly loaded palette if commanded to do so
if (enable_palette)
{
for (index=0; index<256; index++)
{
Set_Palette_Register(index,(RGB_color_ptr)&palette[index]);
} // end for index
} // end if change palette
} // end PCX_Load
void Set_Video_Mode(int mode)
{
union REGS inregs,outregs;
inregs.h.ah=0;
inregs.h.al=(unsigned char)mode;
int86(0x10,&inregs,&outregs);
}
void main(void)
{
char *pcx="poem.pcx";
Set_Video_Mode(VGA256);
PCX_Load_Screen(pcx,1);
getch();
Set_Video_Mode(TEXT_MODE);
}
代码应该没有问题的~可是却看不到想要的结果~
是白屏~
也试过bmp的代码,结果显示没有发现bmp文件。
...全文
相关推荐
PCX图片解码
在编程实现PCX解码时,常见的语言如C++、Python、Java等都有相关的库或函数可以调用。例如,开源库如libpng、FreeImage等都支持PCX格式。
dos真彩色模式下真彩色图像显示技术(1).doc
为了确保程序的兼容性和效率,开发者通常会编写C语言程序,利用VESA BIOS调用来处理各种高、真彩色模式的图像显示。
GBAconv-开源
它提供了音频和图像处理功能,使得开发者能够将WAV音频文件和PCX图像文件转换为C语言数组,以便直接嵌入到GBA游戏的源代码中。
可以读出.exe中的位图资源的控件
这种控件在编程领域,尤其是涉及到图形用户界面(GUI)开发时非常有用,因为它允许程序员在不依赖外部文件的情况下,直接在程序内部使用和显示这些嵌入的图像。
2015年特岗教师招聘初中信息技术考试题(样卷).pdf
计算机编程语言:文档中提到了C语言,这是广泛用于系统软件开发的语言之一,以其高效率和灵活性著称。三、互联网技术知识点1.


