[EGE]为什么会运行时错误?
  • 板块学术版
  • 楼主66xyyd
  • 当前回复1
  • 已保存回复1
  • 发布时间2023/10/28 16:36
  • 上次更新2023/11/2 11:03:25
查看原帖
[EGE]为什么会运行时错误?
946515
66xyyd楼主2023/10/28 16:36

用的是EGE图形库。我的一个类 Image 出了问题。经过排查是构造函数在调用 getimage 函数的时候出现了运行时错误。是哪里出现了问题?这个类定义如下(当类用的结构体):

struct Image{
public:
	PIMAGE pImg;
public:
	Image(size_t _w=0,size_t _h=0){
//		cout << "Image init.(w,h)\n";
//		cout << "w=" << _w << ", h=" << _h;
		if(_w || _h)	pImg=newimage(_w,_h);
		else{
//			cout << "null newimage.\n";
			pImg=newimage();
		}	
//		cout << "return successfully.\n";
	}
	Image(const Image &rhs){
		Image(rhs.width(),rhs.height());
		getimage(pImg,rhs.pImg,0,0,width(),height());
	}
	Image(const string &name){
//		cout << "Image init.(string)\n";
		pImg=newimage(Screen_data::screenWidth,Screen_data::screenHeight);
//		cout << "get new image success.\n";
		getimage(pImg,Screen_data::res_name,name.c_str());
	}
	~Image(){
		delimage(pImg);
		pImg=nullptr;
	}
	inline size_t width() const{
		return getwidth(pImg);
	}
	inline size_t height() const{
		return getheight(pImg);
	}
	const Image operator=(const Image &rhs){
		getimage(pImg,rhs.pImg,0,0,width(),height());
		return (*this);
	}
	void show(int sx=0,int sy=0){
		putimage(sx,sy,pImg);
	}
};
2023/10/28 16:36
加载中...