【如何拷贝页面源码】【火鸟同城网站源码】【excel源码库】c语言显示图片函数源码_c语言显示图片函数源码是什么
1.cè¯è¨å¦ä½è°ç¨å¾çï¼
2.Cè¯è¨è¾åºå¾ç
cè¯è¨å¦ä½è°ç¨å¾çï¼
ç´æ¥è°ç¨å¹¶æ¾ç¤ºJPG BMPçæ ¼å¼å¾ççå½æ°å¥½å没æï¼è¦èªå·±ç¼åã
é¦å è¦å¼æ¸ æ¥å¾çæ ¼å¼çç¼ç æ¹å¼ï¼ç¶å设置å辨çï¼å¯ä»¥æ¾ç¤ºåºæ¥ã
void far getimage(int leftï¼int topï¼int rightï¼int bottomï¼void far *buf)
说æï¼æå±å¹å¾å½¢é¨åæ·è´å°ç±BUFææåçå å¨åºåï¼å·¦ä¸è§åå³ä¸è§å¾æ ãç¨å½æ°IMAGESIZE()æ¥ç¡®å®åå¨å¾åæéåèæ°ãç¨GETIMAGE()åå¨çå¾åå¯ä»¥ç¨PUTIMAGTE()å½æ°åå°å±å¹ä¸ã
Cè¯è¨è¾åºå¾ç
è¾åºBMPå¾ççï¼
#include "stdlib.h"
#include "graphics.h"
#include "stdio.h"
#define WIDTH
#define HEIGHT
//ç¨ä¸ä¸ªäºç»´æ°ç»ä¿åçå¾çï¼è¿éå¾çé¿é«å¿ é¡»æ¯4çåæ°ï¼ä¸æ¯4çåæ°å¿ é¡»è¿è¡è¡¥é½ï¼
//ä½æ¯è¿éé¢æ¯æ²¡æè¿è¡è¡¥ä½æä½çï¼ä½ ä¹å¯ä»¥èªå·±å»ççä½bmpå¾ççç¼ç æ ¼å¼ï¼
//ç¶åå°±ç¥é该æä¹ç¨äº
void mian()
{
FILE *fp;
unsigned char bmp[][];
unsigned char bmp2[WIDTH][HEIGHT*3];
int i = 1,size1 = 0,size2 = 0,size0 = 0;
int j = 0;
if((fp = fopen("G:\\new\\Boy5.bmp","rb")) == NULL)//æå¼å¾ç
exit(0);
i = 0;
fseek(fp,L,0);//BMPå¾çéµåæ¯ä»ç¬¬ä½å¼å§
//#########è¯»å ¥å¾çéµåå°æ°ç»ä¸##########
while(i < WIDTH*HEIGHT*3)
{
*(bmp2[0]+i) = fgetc(fp);
i++;
}
fclose(fp);
initgraph(, ); // æå¼å¾å½¢çªå£ï¼è¿éè¿ä¸ªå½æ°æä¹åæ¯å¨VCä¸ç¼è¯çï¼ç¨äºä¸ä¸ªç½ä¸çç»å¾åºï¼ä¸TCçæå¼å¾å½¢çé¢å½æ°ææå·®å«,æ¹æå°±å¯ä»¥äº
//####################################è¾åºå¾çï¼è¿éæ¯æç¹çæ¹å¼å¨å¾å½¢çé¢è¾åºï¼
for(i = 0;i < (WIDTH-1);)
{
for(j =0;j < (HEIGHT-1)*3 ;)
{
putpixel(+(j/3),-(i/1),RGB((int)bmp2[i][j+2],(int)bmp2[i][j+3],(int)bmp2[i][j+4]));//è¾åºåç´ ç¹
j+=3;
}
i++;
}
getchar();
closegraph(); // å ³éå¾å½¢çªå£
}