数学建模社区-数学中国
标题:
ntd.dll难住机器人发烧友
[打印本页]
作者:
wangzheng3056
时间:
2013-7-25 17:54
标题:
ntd.dll难住机器人发烧友
我为做机器人自学C++编程,在网上找了个程序改了一下。调试该程序总报错,因为ntd.dll的原因,无匹配的字符信息。我想把我C:\windows\system32\ntd.dll删除后,再下载一个新的ntd.dll替换,老的ntd.dll删不掉。请教专家们啦,看看我这程序错哪。
3 A! b' {4 W c$ T8 z
#include <iostream.h>
" m8 }% Z! |9 {- F$ d1 `
#include <stdio.h>
) H$ X( ^8 B4 ?, F
#include <math.h>
% \7 i% s4 t; B1 U) j) Z
typedef unsigned char BYTE;
$ {/ W8 N& b+ Z' r
long Ary2DW (unsigned char p[4]){
, a0 G" ?+ J# I! K# l7 q
int a0,a1,a2,a3;unsigned long A;
, y! x4 o9 }0 b" S9 Q% P
a0=int (p[0]); a1=int (p[1]);
3 w" |1 M2 u6 d1 E: o# h+ {
a2=int (p[2]); a3=int (p[3]);
% A8 l2 B5 {) n* Q+ C
A=a3*256*256*256+a2*256*256*256+a0;
X ~2 e8 @3 P r* D) h! H0 Q3 T
return A;};//实现数的大小正确转换,转换为WORD所代表的实际值
7 Q# z9 ]" D; f3 Z! f E
typedef struct tagBITMAPFILEHEADER {
9 Z* |- a5 X1 o3 x, M' R
BYTE bfType[2];BYTE bfSize[4];
6 b* S( Z' f) u* u9 m- _1 D& m' e
BYTE bfRcserved1[2];
8 a/ a+ I6 b6 ^% N7 N4 [
BYTE bfRcserved2[2];
2 K+ h$ Z- s8 i1 G8 ?: Q1 d% B
BYTE bfoffBits[4];
6 C2 c: A _8 ]$ A
}BITMAPFILEHEADER;//定义文件头格式,用相似的数据类型代替系统定义的数据类型
+ o' W# T8 d& o3 P
typedef struct tagBITMAPINFOHEADER {
4 [: p( ?4 G5 B0 }5 \/ ^% U% ]
BYTE biSize[4];
: s1 ~3 x% b( \5 ]
BYTE biWidth[4];
3 j5 g$ S7 ?2 Y/ `
BYTE biHeight[4];
]7 Z8 d6 E5 g( `& ^0 p
BYTE biCompression[4];
8 x/ w% u" `; J
BYTE biXPelsPerMeter[4];
& r" E! Y9 V' C4 X! _8 u, ?. ]
BYTE biYPelsPerMeter[4];
9 R7 l8 P4 h- n
BYTE biClrUsed[4];
3 x, |5 L0 `! m+ I, y
BYTE biClrImportant[4];
' R% V+ g5 |' p3 o$ J# n6 u
}BITMAPINFOHEADER;//定义信息头格式,用相似的数据类型代替系统定义的数据类型
5 N; L% I6 [4 @' Y
typedef struct BitmapFile{
) _( a2 g+ B1 v( }! x
BITMAPFILEHEADER bmfheader;
2 }$ B) |( N+ }$ Y" `5 d3 k
BITMAPINFOHEADER bminfoheader;
6 _0 g7 C) M. B% l) F2 |( S
BYTE bitmapdata[3275520];
4 V7 O0 t. V e2 L( ^1 U
}bitmap;//定义所处理图像文件对应BMP的文件格式
) ^8 n+ R7 k, l* s$ f* p, n" T
//主函数,将图像区数据读入B、G、R三个数组
$ a' G/ A# q! h& C
int main()
$ e0 X) _# s( E' p' A' P' _
{
: Q0 K& m: O9 r& E
bitmap *ample1;
4 S, Y/ ?+ i# T6 }2 _4 H
FILE *fp, *fp1;
! D, l4 m/ l5 I" S2 Y# `/ P
BYTE R[1280][853],G[1280][853],B[1280][853];
1 Y$ A3 D$ }/ x7 \& w8 R
long k=0;
& X9 k" {6 b n* x# O" c* \; U
int i,j;
V1 C0 `" ~. q
char name[20]="try.bmp";//读到新文件的文件名
3 m- c u1 f) z
fp=fopen("D:\\ample1.bmp","rb");//以二进制打开读文件
* P0 h6 J0 i( y! t2 N- n3 t
fp1=fopen(name,"wb");//为写建立一个新文件名
, L( A: W& y; P
if(! (ample1=new bitmap)){
. _9 Z; D) E! M4 @5 e
cout<<"error"<<endl;return 0;
! U9 [3 }' Y _% F# X/ a
}
# O: |3 W6 m; r6 T
else
2 {' B2 ?5 Q' x
{
$ a4 u% H+ C3 [" X
fread(ample1,sizeof(bitmap),1,fp);
+ m- R g- {- R5 a" S$ I' g
fwrite(ample1,sizeof(bitmap),1,fp1);
5 {5 e; r# h. Q: |
cout<<"********位图文件头格式:********"<<endl;
# ] x' S, u: U G4 m5 }
cout<<"位图文件的类型"<<ample1 -> bmfheader.bfType[0]<<ample1 -> bmfheader.bfType[1]<<endl;
! d: x+ W( T3 R3 }
cout<<"位图文件的大小"<<Ary2DW(ample1 -> bmfheader.bfSize)<<"字节"<<endl;
- v$ x: K: r8 e+ T H8 e3 |) ~7 D
cout<<"********以下是图像数据区********"<<endl;
$ p9 h( F1 L; @/ i: f, y# q3 p
//指定像素点,以16进制输出BGR值
) L8 A: V; }4 S
cout<<"像素点B通道的值"<<hex<<int (ample1 -> bitmapdata[0])<<endl;
4 q; o. E- u9 h; e; G
cout<<"像素点G通道的值"<<hex<<int (ample1 -> bitmapdata[1])<<endl;
$ C1 Y \9 }# f; e8 g- Y3 t6 w
cout<<"像素点R通道的值"<<hex<<int (ample1 -> bitmapdata[2])<<endl;
9 r* A f, R# C2 c! P
//将图像区数据读入 R、G、B三个数组
9 S7 H/ `. ` G+ i7 R0 G5 Y
for(i=1280; i>=0; i--)
. l# U6 _' y0 F
for(j=0; j<853; j++)
8 o- S7 K) W# V1 s; P" w: I
{
# a% P+ s& }# ~6 _
B[i][j]=ample1 -> bitmapdata[k++];
. j( P5 M, g. i5 ~1 D
G[i][j]=ample1 -> bitmapdata[k++];
4 J- h3 [" P2 z) K0 H- }0 C% C
R[i][j]=ample1 -> bitmapdata[k++];
8 j9 _* i+ f$ ?) q0 [
}
1 ~* ^- Z$ I1 X& u3 f( w6 {; q' N
//检查是否将图像数据读入数组
' K8 J8 H/ \" R, y
cout<<"********以下是内存数组数据********"<<endl;
) w0 F; j* z( Y+ P. ^+ N
cout<<"第一排第一个像素点B通道的值"<<int (B[0][0])<<endl;
: G8 }( C8 V* _/ P) W4 @: N! t
cout<<"最后一排第一个像素点R通道的值"<<int (R[1280][0])<<endl;
- H) m1 X8 ^) i
return 1;
; I H+ D# P' s3 O% u
}
6 H0 J& ?# B; v T! L j
delete ample1;
* f% |; J- S+ k
fclose(fp);
' Q' e' T- }. e' S7 R
fclose(fp1);
Q, h1 N; w6 H; }9 Z( C2 G
}
欢迎光临 数学建模社区-数学中国 (http://www.madio.net/)
Powered by Discuz! X2.5