当前位置:三九宝宝网 → 宝宝教育 → 教学论文 → 正文

高手指点:用C语言编写一个读写

更新:02-16 整理:39baobao.com
字体:

[用C语言编写一个将若干单词按字母排序的程序请各位高手帮忙]//--------------------------------------------------------------------------- #include <stdio.h> #include <stdlib.h> #include <ctype.h> #define FILENAME "c:\\a.t...+阅读

#ifndef BMPRW_H #define BMPRW_H typedef struct { // 长度12字节 // short bftype; // 固定为"BM",VC不能读取一个short,故省略 int bfSize; // 位图文件的大小,以字节为单位 short bfReserved1; // 位图文件保留字,必须为0 short bfReserved2; // 位图文件保留字,必须为0 int bfOffBits; // 位图数据的起始位置,以相对于位图文件头的偏移量表示,以字节为单位 } BITMAPFILEHEADER; typedef struct { // 长度40字节 int biSize; // 本结构所占用字节数,长度40字节 int biWidth; // 位图的宽度,以像素为单位 int biHeight; // 位图的高度,以像素为单位 short biPlanes; // 目标设备的级别,必须为1 short biBitCount; // 每个像素所需的位数,必须是1(双色),4(16色),8(256色)或24(真彩色)之一 int biCompression; // 位图压缩类型,必须是0(不压缩),1(BI_RLE8压缩类型)或2(BI_RLE4压缩类型)之一 int biSizeImage; // 位图的大小,以字节为单位 int biXPelsPerMeter; // 位图水平分辨率,每米像素数 int biYPelsPerMeter; // 位图垂直分辨率,每米像素数 int biClrUsed; // 位图实际使用的颜色表中的颜色数 int biClrImportant; // 位图显示过程中重要的颜色数 } BITMAPINFOHEADER; typedef struct { // 24位真彩色无此结构,256级灰度图长度256*4字节 char rgbBlue; // 蓝色的亮度(值范围为0-255) char rgbGreen; // 绿色的亮度(值范围为0-255) char rgbRed; // 红色的亮度(值范围为0-255) char rgbReserved; // 保留,必须为0 } RGBQUAD; void ColorBmpR(char*, unsigned char*); // 彩色bmp图像读 void ColorBmpW(char*, char*, unsigned char*); // 彩色bmp图像写 void GrayBmpR (char*, unsigned char*); // 灰度bmp图像读 void GrayBmpW (char*, char*, unsigned char*); // 灰度bmp图像写 #endif /////////////////////////////////////////////////////////// #include "stdio.h" #include "stdlib.h" #include "Common.h" #include "BmpRW.h" /* Copyright: Li Weiwei VER: 2.00 Function: 读取一幅256灰度的bmp图片入内存 Input: bmp文件名指针,内存中图片数据指针 Output: 无 */ void GrayBmpR(char *fn, unsigned char *pImage) { BITMAPFILEHEADER *pbmpfh; // bmp文件头指针 BITMAPINFOHEADER *pbmpi; // bmp文件信息头指针 unsigned char *pbitstr; // bmp文件数据指针 int i = 0; // 将bmp文件头文件读入*pbmpfh FILE *rfile = fopen(fn,"rb+"); pbmpfh = (BITMAPFILEHEADER*) malloc(sizeof(BITMAPFILEHEADER)); if (!pbmpfh) { printf("pbmpfh not enough memory"); } fseek(rfile,sizeof(short),SEEK_SET); fread(pbmpfh,sizeof(BITMAPFILEHEADER),1,rfile); // 将bmp文件信息头文件读入*pbmpi pbmpi = (BITMAPINFOHEADER*) malloc(sizeof(BITMAPINFOHEADER)); if (!pbmpi) { printf("pbmpi not enough memory"); } fseek(rfile,sizeof(BITMAPFILEHEADER)+sizeof(short),SEEK_SET); fread(pbmpi,sizeof(BITMAPINFOHEADER),1,rfile); // 将bmp文件数据读入*pbitstr pbitstr = (unsigned char*) malloc(IMAGE_SIZE); if (!pbitstr) { printf("pbitstr not enough memory"); } fseek(rfile,pbmpfh->bfOffBits,SEEK_SET); fread(pbitstr,IMAGE_SIZE,1,rfile); fclose(rfile); // 将*pbitstr中数据存入*pImage for (i = 0; ibfOffBits,SEEK_SET); fread(pbitstr,IMAGE_SIZE*3,1,rfile); fclose(rfile); // 将*pbitstr中数据存入*pImage for( i=0 ; i

本文地址:https://www.39baobao.com/show/29_41916.html

以上内容来自互联网,请自行判断内容的正确性。若本站收录的信息无意侵犯了贵司版权,请联系我们,我们会及时处理和回复,谢谢.

以下为关联文档:

用C语言编写一个计算薪水的程序/*工资计算程序*/ #include main() { float originWage; /*应发工资*/ float realWage; /*实发工资*/ float tax; /*所缴税款*/ int i,hour,amount,money; printf("请选择工资种...

一个C语言编程题目请高手指点可以参考以下:1.程序分析: 2.程序源代码: #definenmax50 main() { inti,k,m,n,num[nmax],*p; printf("pleaseinputthetotalofnumbers:"); scanf("%d",&n); p=num; for(i=0;i *(p+i)...

用C语言编写一个简单的图书管理小程序源代码如下: #include<iostream> #include<iomanip> #include<string> #include<fstream> #include<stdio.h> using namespace std; const int maxb=10000; //最多的图书 clas...

用C语言编写一个图书管理系统#include#includestruct sale/*商品名的定义*/{int number; char name[20]; float price; long count; long time; long date;}; /*各个函数*/ void input(struct sale s[7]);/...

用c语言编写一个计算机病毒的例子简单啊 void main() { while(1) {} }//死循环,电脑用不了 或者这样 void main() { while(1) { char *a=new char(1024); } }//吃光你的内存 还能这样 #include #include void...

用c语言编写一个简单的程序main() { int a,b,i; bool flag = true; for (i = 0; i < 6; i++) { scanf("%d", &a); if (flag) { b = a; flag = false; } else { if (b > a) b = a; } } prinf("%d", b); }...

用c语言编写一个定义回文数的程序谢谢void main() { char a[50]; scanf("%s",&amp;a); int n=strlen(a),i=0; for(;i<=n/2;i++) { if (a[i]!=a[n-1-i]) { printf("%s不是回文数",a); break; } } if (i>n/2) {printf("%...

用c语言编写一个猜数游戏#include <stdio.h> #include <stdlib.h> #include <time.h> #define Range 100 int guess(int k){ int input; printf("请输入数字:\t"); scanf("%d",&input); if(input==k)return...

用c语言编写一个程序实现以下功能1 2 3 4 5 6 7 8 9 10 #include "stdio.h" intmain(intargc,char*argv[]){ 5261int a,b; doublex,y; charch1,ch2; printf("Please enter the data...\n"); scanf("%d%d%lf%lf %c...