首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ Builder >

新有关问题:关于GDI+提示Ambiguity between 'Graphics' and 'Gdiplus:Graphics'的

2012-04-02 
新问题:关于GDI+提示Ambiguity between Graphics and Gdiplus::Graphics的,请教高手按照下边的做法却

新问题:关于GDI+提示Ambiguity between 'Graphics' and 'Gdiplus::Graphics'的,请教高手
按照下边的做法却出现后边描述的情况,请各位给个解决方案,谢谢
==================================================
#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-------找到这个方法,但不知添加在哪个地方合适。。。。。。

[解决办法]
下面这个例子和你的包含是一样的,还加了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;
}
//---------------------------------------

热点排行