VC2005 编译MSDN中的例子 出来一大堆错误~不明白啊

狂放之歌 2006-03-29 09:13:42
/*
错误都定位在 GdiplusHeaders.h
GdiplusFlat.h
GdiplusPath.h
GdiplusMetafile.h
这些 都是安装文件啊~~哪里出了毛病啊?
121个..error!!
有三个是 VC2005 取消了默认类型 而且将这个作为错误发出
*/
#include <windows.h>
#include <stdio.h>
#include <gdiplus.h>
using namespace Gdiplus;

INT GetEncoderClsid(const WCHAR* format, CLSID* pClsid); // helper function


int _tmain(int argc, _TCHAR* argv[])
{
// Initialize GDI+.
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

CLSID encoderClsid;
EncoderParameters encoderParameters;
ULONG quality;
Status stat;

// Get an image from the disk.
Image* image = new Image( _T("SmartCUT.bmp") );

// Get the CLSID of the JPEG encoder.
GetEncoderClsid(L"image/jpeg", &encoderClsid);

// Before we call Image::Save, we must initialize an
// EncoderParameters object. The EncoderParameters object
// has an array of EncoderParameter objects. In this
// case, there is only one EncoderParameter object in the array.
// The one EncoderParameter object has an array of values.
// In this case, there is only one value (of type ULONG)
// in the array. We will let this value vary from 0 to 100.

encoderParameters.Count = 1;
encoderParameters.Parameter[0].Guid = EncoderQuality;
encoderParameters.Parameter[0].Type = EncoderParameterValueTypeLong;
encoderParameters.Parameter[0].NumberOfValues = 1;

// Save the image as a JPEG with quality level 0.
quality = 0;
encoderParameters.Parameter[0].Value = &quality;
stat = image->Save(L"Shapes001.jpg", &encoderClsid, &encoderParameters);

if(stat == Ok)
wprintf(L"%s saved successfully.\n", L"Shapes001.jpg");
else
wprintf(L"%d Attempt to save %s failed.\n", stat, L"Shapes001.jpg");

// Save the image as a JPEG with quality level 50.
quality = 50;
encoderParameters.Parameter[0].Value = &quality;
stat = image->Save(L"Shapes050.jpg", &encoderClsid, &encoderParameters);

if(stat == Ok)
wprintf(L"%s saved successfully.\n", L"Shapes050.jpg");
else
wprintf(L"%d Attempt to save %s failed.\n", stat, L"Shapes050.jpg");

// Save the image as a JPEG with quality level 100.
quality = 100;
encoderParameters.Parameter[0].Value = &quality;
stat = image->Save(L"Shapes100.jpg", &encoderClsid, &encoderParameters);

if(stat == Ok)
wprintf(L"%s saved successfully.\n", L"Shapes100.jpg");
else
wprintf(L"%d Attempt to save %s failed.\n", stat, L"Shapes100.jpg");

delete image;
GdiplusShutdown(gdiplusToken);

return 0;
}

...全文
169 11 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
DrSmart 2006-03-30
  • 打赏
  • 举报
回复
呵呵
狂放之歌 2006-03-30
  • 打赏
  • 举报
回复
将这个注释掉 头文件包含没有错误了

//#define WIN32_LEAN_AND_MEAN // 从 Windows 头中排除极少使用的资料

另外xing_xing_xing(ζ未名ζ) 的方法也有效..针对MFC/SDK通杀

from msdn:

Visual C++ Concepts: Building a C/C++ Program
Faster Builds and Smaller Header Files

To speed the build process, Visual C++ provides the following definitions that reduce the size of the Win32 header files by excluding some of the less common APIs:

* VC_EXTRALEAN
* WIN32_LEAN_AND_MEAN

VC_EXTRALEAN defines WIN32_LEAN_AND_MEAN and a number of NOservice definitions, such as NOCOMM and NOSOUND. (For a list of NOservice definitions, see the header file Windows.h and the MFC header file afxv_w32.h.)

Applications created with the Visual C++ application wizards use VC_EXTRALEAN automatically. You can manually define VC_EXTRALEAN in legacy MFC applications to speed their build process.

Non-MFC applications can define WIN32_LEAN_AND_MEAN and applicable NOservice definitions to reduce build times.

Trying to use an API excluded by these definitions causes compiler errors. If a program that defines NOCOMM or VC_EXTRALEAN tries to use PurgeComm, for example, the following errors result:

error C2065: 'PurgeComm' : undeclared identifier
error C2064: term does not evaluate to a function

十分感谢大家~
yuanss71 2006-03-29
  • 打赏
  • 举报
回复
头文件包含了两个相同的

低版本的 在前面
先检测到的版本的就出现这样的问题

调整 include 中的路径次序 可以解决
rageliu 2006-03-29
  • 打赏
  • 举报
回复
应该是头文件的包含问题
DentistryDoctor 2006-03-29
  • 打赏
  • 举报
回复
不应该吧,头文件有问题?
xing_xing_xing 2006-03-29
  • 打赏
  • 举报
回复
After putting the following two lines before #include'ing <gdiplus.h>

#define _AFXDLL
#include <afxwin.h>

参考
http://groups.google.com/group/microsoft.public.dotnet.framework.drawing/browse_thread/thread/f0febf272a128235/9051da5d9b17210d%239051da5d9b17210d

狂放之歌 2006-03-29
  • 打赏
  • 举报
回复
...刚才又了一下~

main中 什么代码也不加,,只要 #include <gdiplus.h>
就是 121error 14 warning
DrSmart 2006-03-29
  • 打赏
  • 举报
回复
sdk版本问题?????????????
狂放之歌 2006-03-29
  • 打赏
  • 举报
回复
还有很多~~
狂放之歌 2006-03-29
  • 打赏
  • 举报
回复
------ 已启动生成: 项目: BMPtoJPEG, 配置: Release Win32 ------
正在编译...
stdafx.cpp
正在编译...
BMPtoJPEG.cpp
f:\program files\microsoft visual studio 8\vc\platformsdk\include\GdiplusImaging.h(67) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
f:\program files\microsoft visual studio 8\vc\platformsdk\include\GdiplusImaging.h(67) : error C2440: 'initializing' : cannot convert from 'const char [37]' to 'int'
There is no context in which this conversion is possible
f:\program files\microsoft visual studio 8\vc\platformsdk\include\GdiplusImaging.h(67) : error C2146: syntax error : missing ';' before identifier 'IImageBytes'
f:\program files\microsoft visual studio 8\vc\platformsdk\include\GdiplusImaging.h(67) : error C2470: 'IImageBytes' : looks like a function definition, but there is no parameter list; skipping apparent body
f:\program files\microsoft visual studio 8\vc\platformsdk\include\GdiplusImaging.h(67) : error C2059: syntax error : 'public'
f:\program files\microsoft visual studio 8\vc\platformsdk\include\GdiplusImaging.h(246) : error C2146: syntax error : missing ';' before identifier 'id'
f:\program files\microsoft visual studio 8\vc\platformsdk\include\GdiplusImaging.h(246) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
f:\program files\microsoft visual studio 8\vc\platformsdk\include\GdiplusImaging.h(246) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
f:\program files\microsoft visual studio 8\vc\platformsdk\include\GdiplusHeaders.h(384) : error C2143: syntax error : missing ')' before '*'
f:\program files\microsoft visual studio 8\vc\platformsdk\include\GdiplusHeaders.h(384) : error C2143: syntax error : missing ';' before '*'
f:\program files\microsoft visual studio 8\vc\platformsdk\include\GdiplusHeaders.h(384) : error C2460: 'Gdiplus::Image::IStream' : uses 'Gdiplus::Image', which is being defined
f:\program files\microsoft visual studio 8\vc\platformsdk\include\GdiplusHeaders.h(372) : see declaration of 'Gdiplus::Image'
菜牛 2006-03-29
  • 打赏
  • 举报
回复
把错误信息贴出来。
vc源代码合集0951.rarvc源代码合集0951.rar 2012-06-12 11:54 80,235 (MSDN oct 2001)VC6 适用的最后一个版本[ISO].rar 2012-06-13 09:53 0 1.txt 2012-06-12 11:56 17,755 2011年北航计算机考研复试上机题.rar 2012-06-12 07:14 11,172,336 91算命软件.zip 2012-06-12 11:53 334,303 advanced+windows+debugging+resources.zip 2012-06-12 12:45 1,647,769 ATM - 副本.zip 2012-06-12 11:41 3,468,299 C++how to program源代码.rar 2012-06-12 12:32 405,625 C++国象棋游戏源代码.rar 2012-06-12 12:56 10,743,192 C++数据图像获取.rar 2012-06-12 11:43 3,861 C++矩阵加法和乘法运算(可运行但未排除BUG).txt 2012-06-12 11:52 2,753 C++词法分析器.txt 2012-06-12 12:44 2,035,571 Clock.rar 2012-06-12 12:44 1,915,984 CZG.rar 2012-06-12 12:22 10,537 C和C++字符串处理函数.txt 2012-06-12 12:21 8,825 c扫描器源码.txt 2012-06-12 12:39 505,110 c语言也能干大事全部板书(带书签)-感谢rupeng.com鹏友的整理.rar 2012-06-12 12:10 183,001 C语言函数大全语法着色版.chm 2012-06-12 12:07 25,088 C语言加密程序.doc 2012-06-12 12:27 13,961 C语言图像函数库详解.txt 2012-06-12 11:54 38,018 C语言图形编程.rar 2012-06-12 12:26 521,167 C语言实现可视化人机界面的有效方法.pdf 2012-06-12 12:23 3,250,257 C语言精髓例子.rar 2012-06-12 11:41 334,336 C语言编程规范-1.0.doc 2012-06-12 12:52 1,960 ddos源代码_c语言实现 VC6.rar 2012-06-12 12:11 366,777 DeviceTree.rar 2012-06-12 12:53 2,127,246 Ethernet帧封装_解析_模拟发送.rar 2012-06-12 12:57 2,722 FFT_C语言.txt 2012-06-12 12:52 572,659 gbk+unicode+汉字编码对照表.rar 2012-06-12 12:31 16,598 GDI简化程序.rar 2012-06-12 12:50 25,088 H.264编码算法的完整源代码二.doc 2012-06-12 12:51 3,074,435 H264帧内预测算法的研究与优化.pdf 2012-06-12 12:49 1,629,393 H264流媒体RTP打包源代码和相关资料.rar 2012-06-12 12:26 397 HEXtoTXT.TXT 2012-06-12 12:23 11,439,766 iccvar C编译器.rar 2012-06-12 13:04 56,110 InfInstall.rar 2012-06-12 11:56 17,999 IPHelper.rar 2012-06-12 11:58 942,551 JEPG图像数字的识.rar 2012-06-12 11:59 19,418 Lucas定理--组合数求摸.docx 2012-06-12 12:51 1,826,942 md5加密算法源代码.rar 2012-06-12 11:48 79,221 MFC音乐播放器(滑块控制音量).zip 2012-06-12 13:01 74,769 MyQQ-VC开发的局域网通信程序.rar 2012-06-12 12:18 1,154 N个数1的个数.txt 2012-06-12 12:03 176,988 ODBCApiDataManager.rar 2012-06-12 11:50 54,935 PlayWithDataStructureSourceCode.zip 2012-06-12 13:00 23,174 random.rar 2012-06-12 12:27 138,307 RGB各种颜色对照表.pdf 2012-06-12 11:43 86,759 Socket编程例子_MFC_SDK.rar 2012-06-12 12:01 45,155 SpyXX.rar 2012-06-12 11:47 5,121,939 Unix源代码.rar 2012-06-12 07:10 2,678,026 VC++6.0.rar 2012-06-12 11:58 2,458,686 vc++avi媒体播放器 保存所需窗口bmp.zip 2012-06-12 11:55 3,721,136 VC++动态链接库(dll)编程深入浅出.rar 2012-06-12 13:02 23,185 VC++图像平滑处理+程序.rar 2012-06-12 12:12 45,056 VC++操作INI配置文件的实现.doc 2012-06-12 11:48 11,728,284 VC++数字图像模式识别技术及工程实践.pdf 2012-06-12 12:58 1,863,715 VC++设置和获得一组单选按钮的选状态.rar 2012-06-12 12:52 565,945 VCHOME图形图像编程技术篇.chm 2012-06-12 11:59 34,816 VC__T的用途.doc 2012-06-12 11:45 4,438,581 VC坦克大战带地图编辑器.rar 2012-06-12 13:09 7,108,412 VC数据库编程技术与实例.ISO.part 2012-06-13 09:46 199,929,772 vc源代码合集0951.rar 2012-06-12 11:47 46,602 vector使用方法.doc 2012-06-12 13:04 959,370 VirtualNES.rar 2012-06-12 12:49 8,323,796 Visual C++实现图像获取、处理与分析.rar 2012-06-12 12:49 6,275,839 Visual C++实现数字图像处理源代码.rar 2012-06-12 11:57 182 Visual C++技术内幕摘要笔记.rar 2012-06-12 11:50 3,620,678 visual c++网络通信编程实用案例精选(源代码).rar 2012-06-12 12:23 3,982,016 Visual_C++网络编程经典案例详解PPT.rar 2012-06-12 12:26 428,875 Visual_Studio_2008_入门教程.pdf 2012-06-12 11:47 56,320 VOIP语音数据实际码率 .doc 2012-06-12 12:10 71,680 vs2010安装msdn.doc 2012-06-12 12:00 970,347 WebServer源代码.rar 2012-06-12 12:31 157,391 windiff_src.zip 2012-06-12 12:44 12,282,377 Windows2000设备驱动程序设计指南.pdf 2012-06-12 12:43 1,155,676 Windows2000驱动程序设计指南.rar 2012-06-12 12:51 540,654 winsock.zip 2012-06-12 12:45 7,417,271 YY.rar 2012-06-12 12:21 1,267 [自毁程序]源代码.txt 2012-06-12 12:25 1,826,678 《Keil Software –Cx51 编译器用户手册 文完整版》(403页).pdf 2012-06-12 12:58 24,097 《黑客攻击手段之偷梁换柱》配套源代码.zip 2012-06-12 11:53 237 【Visual C++】18.简单的愤怒小鸟弹球demo无删减版.rar 2012-06-12 12:22 2,615 【乱码加密】源代码.txt 2012-06-12 12:06 228,818 一个简单的学生成绩管理系统.rar 2012-06-12 12:47 2,916 缀表达式转后缀表达式代码(数据结构C++).rar 2012-06-12 11:57 6,246,172 串口助手源码.7z 2012-06-12 11:55 9,382 免疫算法源代码.txt 2012-06-12 13:02 318,455 再再论指针.pdf 2012-06-12 12:54 183,362 写一个图形界面的操作系统.rar 2012-06-12 11:51 49,152 列主元消去法.doc 2012-06-12 12:20 524 判断质数.dsw 2012-06-12 12:12 1,987,273 单词拼写检查器.rar 2012-06-12 11:40 2,477,013 双人配合俄罗斯方块beta版(源码).rar 2012-06-12 11:57 5,633,867 双向循环链表.rar 2012-06-12 12:44 140,600 双缓冲技术.rar 2012-06-12 12:07 86,668 基于CStatic波形显示控件.rar 2012-06-12 12:22 33,669 太极.zip 2012-06-12 12:06 346,073 安装文件注册表提取工具.zip 2012-06-12 11:48 159,232 对象作为函数参数.doc 2012-06-12 12:20 564 将三个数按从大到小的顺序排序.dsw 2012-06-12 11:48 118,272 建立一个学生信息链表.doc 2012-06-12 11:47 106,496 按照类层次编写程序.doc 2012-06-12 12:21 513 明码序列号保护的实现.txt 2012-06-12 11:51 103,936 最大堆实现排序(从大到小输出).doc 2012-06-12 11:51 240,128 最小生成树(prim算法)贪心算法.doc 2012-06-12 12:26 772,419 最简单的c++静态链接.zip 2012-06-12 11:45 202,240 最长公共子序列算法.doc 2012-06-12 12:24 956 步进电机C程序.c 2012-06-12 12:20 377 求三个数的最大者和最小者.c 2012-06-12 12:03 411,683 注册表编程应用实例.pdf 2012-06-12 13:03 260,549 用C和汇编写的Dos操作系统的源码.rar 2012-06-12 11:43 34,816 用sql实现查询重复记录的代码.doc 2012-06-12 13:05 41,472 用VC++实现USB接口读写数据的程序.doc 2012-06-12 12:22 3,939 用邻接矩阵表示的图的深度优先搜索和广度优先搜索.txt 2012-06-12 11:43 1,845,250 界面美化Prof-UIS.rar 2012-06-12 11:45 440,342 着名的CDX游戏开发工具.zip 2012-06-12 12:19 91,035 离散余弦正逆变换+CODE.pdf 2012-06-12 11:58 3,261 笔记识别.rar 2012-06-12 11:46 1,579,321 简单远程备份(V1.0).rar 2012-06-12 12:21 23,476 编程求主范式.rar 2012-06-12 12:17 65,536 编译原理词法分析.doc 2012-06-12 11:50 220 能提高你的效率的十个Visual Studio使用技巧.rar 2012-06-12 06:34 11,131,920 自动加群软件.zip 2012-06-12 11:47 240,640 虚基类的使用实例.doc 2012-06-12 12:15 1,660,959 虚拟桌面.rar 2012-06-12 07:09 7,654,095 计算机等级考试C语言上机软件_VC++6.0文版.zip 2012-06-12 12:17 2,126 语法分析器(C语言).cpp 2012-06-12 11:41 6,934,136 边缘检测.zip 2012-06-12 11:55 12,915 运算符重载实例.docx 2012-06-12 11:46 4,995,615 运行程序.rar 2012-06-12 12:24 36,864 选择排序和冒泡排序的C++和C的实现(总结).doc 2012-06-12 11:56 6,100 遗传算法源代码.txt 2012-06-12 06:41 1,720,354 飞秋FeiQ.rar 2012-06-12 06:48 6,015,720 黄金屋-文件排重软件V2.00.rar

19,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 图形处理/算法
社区管理员
  • 图形处理/算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧