您的位置:程序门 -> 其他开发语言 -> 汇编语言



怎么用汇编语言读取bmp图像文件进内存或者数据段?


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


怎么用汇编语言读取bmp图像文件进内存或者数据段?
发表于:2007-02-20 17:04:43 楼主
怎么用汇编语言读取bmp图像文件进内存或者数据段?

有很多c语言的例子,没有汇编的呀。
发表于:2007-02-20 19:23:271楼 得分:0
既然有   c   的,就可以转换成   汇编   的撒!
发表于:2007-02-20 19:27:332楼 得分:0
lz   要给出   c   的   source   code   才可以撒!
发表于:2007-02-20 21:37:233楼 得分:0
#include   <stdio.h>
#include   <stdlib.h>
#include   <math.h>
#include   <sys/stat.h>

#define exit_err 1
#define exit_nor 0

#define com_err -1
#define com_nor 0

#define ret_err com_err
#define ret_nor com_nor

/*   #pragma   pack(1)   */

/*
typedef   unsigned   short uint;
typedef   int dword;
typedef   short word;
typedef   int long;
typedef   unsigned   char byte;
*/
typedef   unsigned   int uint;
typedef   long dword;
typedef   int word;
typedef   long long;
typedef   unsigned   char byte;

/*   bmp   file   head   */
typedef   struct   tagbitmapfileheader
{
uint bftype; /*   identifier   'bm '   */
dword bfsize; /*   file   size:   complete   file   size   in   bytes   */
uint bfreserved1; /*   reserved   for   later   use   */
uint bfreserved2; /*   reserved   for   later   use   */
dword bfoffbits; /*   bitmap   data   offset:   offset   from   beginning   of   file   to   the   beginning   of   the   bitmap   data   */
}bitmapfileheader;

/*     */
typedef   struct   tagbitmapinfoheader
{
dword bisize; /*   bitmap   header   size   */
long biwidth; /*   horizontal   width   of   bitmap   in   pixels   */
long biheight; /*   vertical   height   of   bitmap   in   pixels   */
word biplanes; /*   number   of   planes   in   this   bitmap   ,const   1   */
word bibitcount; /*   1   -   monochrome   bitmap,   4   -   16   color   bitmap,   8   -   256   color   bitmap,   16   -   16bit(high   color)   bitmap,   24   -   24bit(true   color)bitmap,   32   -   32bit(true   color)bitmap   */
dword bicompression; /*   compression   specifications.   the   following   values   are   possible:   1   -   rle   8bit/pixel,2   -   rle   4bit/pixel   */
dword bisizeimage; /*   size   of   the   bitmap   data   in   butes.this   number   must   be   rounded   to   the   next   4   byte   boundary   */
long bixpelspermeter; /*   horizontal   resolution   */
long biypelspermeter; /*   vertical   resolution   */
dword biclrused; /*   number   of   colors   used   by   this   bitmap.   */
dword biclrimportant; /*   important   colors:   number   of   important   colors.   this   number   will   be   equal   to   the   number   of   colors   when   every   color   is   important   */
}bitmapinfoheader;

/*   rgb   */
typedef   struct   tagrgbquad
{
byte rgbblue;
byte rgbgreen;
byte rgbred;
byte rgbreserved;
}rgbquad;

/*   bmp   info   head   */
typedef   struct   tagbitmapinfo
{
bitmapinfoheader bmiheader;
rgbquad bmicolors[1];
}bitmapinfo;

typedef   struct   tagbitmapdata
{
byte bicount;
byte biindexvalue;
}bitmapdata;

/*   output   infomation   of   per   pixel   */
int   outputpixelinfo(char*   );

void   printfileheader(bitmapfileheader   *,file   *);

void   printimageheader(bitmapinfoheader   *,file   *);

void   printimagedatainfo(rgbquad*,bitmapdata*,int,file   *);

void   writedatatofile(char   *,file   *);
发表于:2007-02-20 21:38:114楼 得分:0
bitmapfileheader *pbmfheader; /*   bmp   file   header   */
bitmapinfoheader *pbmiheader; /*   bmp   image   info   header   */
rgbquad *prgb;
bitmapdata *pbmdata;
file *fp_out;
char ch_filepath[256];

printf( "analysis   start.\n ");

memset(ch_filepath,0x00,sizeof(ch_filepath));
strcat(ch_filepath, "rleout ");
strcat(ch_filepath, ".txt ");
fp_out   =   fopen(ch_filepath, "w ");
if   (fp_out==null)
{
return   com_err;
}

printf( "analysis   step   1   ok.\n ");

/*   print   file   header   */
pbmfheader   =   (bitmapfileheader*)chp_data;
bmfh   =   (bitmapfileheader*)chp_data;
printfileheader(pbmfheader,fp_out);
printf( "analysis   step   2   ok.\n ");

pbmiheader   =   (bitmapinfoheader*)(chp_data   +   sizeof(bitmapfileheader));
bmih   =   (bitmapinfoheader*)(chp_data   +   sizeof(bitmapfileheader));
/*   print   image   header   */
printimageheader(pbmiheader,fp_out);
printf( "analysis   step   3   ok.\n ");

/*   get   palette   value   */
prgb   =   (rgbquad*)(chp_data   +   sizeof(bitmapfileheader)   + sizeof(bitmapinfoheader));
acolors   =   (rgbquad*)(chp_data   +   sizeof(bitmapfileheader)   + sizeof(bitmapinfoheader));
printf( "analysis   step   4   ok.\n ");

printf( "%d\n ",(int)pbmiheader-> bibitcount);
/*   print   image   data */
pbmdata =   (bitmapdata*)(chp_data   +   sizeof(bitmapfileheader) +   sizeof(bitmapinfoheader)   +   (int)pow(2,pbmiheader-> bibitcount)*4);
printf( "analysis   step   5   ok.\n ");

printimagedatainfo(prgb,pbmdata,(int)pbmiheader-> bibitcount,fp_out);
printf( "analysis   step   6   ok.\n ");
fclose(fp_out);

printf( "analysis   end.\n ");

return   com_nor;
发表于:2007-02-22 11:32:495楼 得分:0
放到资源里,然后读取资源就可以了.
发表于:2007-02-27 12:58:166楼 得分:0
如果用汇编的话。首先要了解bmp文件的格式。在查查手册。dos系统调用有打开本件读文件的功能。不是太复杂
发表于:2007-02-28 09:30:177楼 得分:0
zhichi


快速检索

最新资讯
热门点击