新问题:关于GDI+提示Ambiguity between 'Graphics' and 'Gdiplus::Graphics'的,请教高手

wys512 2007-02-09 09:47:41
按照下边的做法却出现后边描述的情况,请各位给个解决方案,谢谢
==================================================
#include <algorithm>
using std::min;
using std::max;
#include <Gdiplus.h>

#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ExtCtrls.hpp>
using namespace Gdiplus;

象这样排列包含文件就行了
======================================================


#include <algorithm>
using std::min;
using std::max;
#include <Gdiplus.h>
的前边又会自动添加
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ExtCtrls.hpp>
#include <Graphics.hpp>------主要是这个,因为我用了speedbutton
或者使用了image装载jpeg的话就会报这个错:Ambiguity between 'Graphics' and 'Gdiplus::Graphics'

然后编译仍然通不过,请问该如何解决呢
/////////////////////////////////////////////////////////////////
可以重新定义一下,比方说
typedef Gdiplus::Graphics GpGraphics-------找到这个方法,但不知添加在哪个地方合适。。。。。。
...全文
258 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
wys512 2007-02-10
  • 打赏
  • 举报
回复
好的,谢谢maozefa(阿发伯) ,问题解决,结了,呵呵
阿发伯 2007-02-09
  • 打赏
  • 举报
回复
下面这个例子和你的包含是一样的,还加了TDpeedButton和TImage,都没有错误
//---------------------------------------------------------------------------

#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Buttons.hpp>
#include <ExtCtrls.hpp>
#include <Graphics.hpp>
#include <algorithm>
using std::min;
using std::max;
#include <gdiplus.h>
using namespace Gdiplus;
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TSpeedButton *SpeedButton1;
TImage *Image1;
TButton *Button1;
TButton *Button2;
void __fastcall Button1Click(TObject *Sender);
void __fastcall Button2Click(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif


//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void Rotate(AnsiString FileName, HDC hdc, int x, int y, double angle)
{
Gdiplus::Image image((WideString)FileName);
Matrix matrix;
matrix.RotateAt(angle, PointF(image.GetWidth() / 2 + x, image.GetHeight() / 2 + y));
Gdiplus::Graphics g(hdc);
g.SetTransform(&matrix);
g.DrawImage(&image, x, y);
}

void __fastcall TForm1::Button1Click(TObject *Sender)
{
Gdiplus::GdiplusStartupInput gdiplusStartupInput;
ULONG gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
Rotate("d:\\msn.jpg", Canvas->Handle, 50, 50, 45);
GdiplusShutdown(gdiplusToken);
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button2Click(TObject *Sender)
{
::Graphics::TBitmap *bmp = new ::Graphics::TBitmap();

delete bmp;
}
//---------------------------------------------------------------------------
wys512 2007-02-09
  • 打赏
  • 举报
回复
好的,我回去试下先,可以的话明天结贴,呵呵,如果不行,明天可能还要麻烦下你哦
阿发伯 2007-02-09
  • 打赏
  • 举报
回复
你说的问题使用域操作符::可以解决的,我刚才试了,引用speedbutton这样的内含了<Graphics.hpp>没有出错
wys512 2007-02-09
  • 打赏
  • 举报
回复
我的情况不是说引用TBitmap时出错,而是引用了象speedbutton这样的内含了<Graphics.hpp>时出现的问题
wys512 2007-02-09
  • 打赏
  • 举报
回复
这样可行吗
阿发伯 2007-02-09
  • 打赏
  • 举报
回复
在引用Graphics.hpp的类时加上::Graphics,如:

::Graphics::TBitmap *bmp = new ::Graphics::TBitmap();

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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