gpt4 book ai didi

c++ - FLTK 绘制像素图给出段错误

转载 作者:太空宇宙 更新时间:2023-11-04 09:06:08 25 4
gpt4 key购买 nike

我正在尝试使用 FLTK 在 C++ 程序中绘制 xpm 文件。

这是代码

#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include "image.xpm"
#include <FL/Fl_Pixmap.H>
#include <FL/fl_draw.H>
#include <FL/Fl_Image.H>
int main(int argc, char ** argv)
{
Fl_Window *window = new Fl_Window(800,650);
Fl_Pixmap pix(XFACE);
pix.draw(200,200);
window->end();
window->show(argc,argv);
return Fl::run();
}

XFACE 是“image.xpm”中的有效 xpm 对象

但是我在 pix.draw() 行遇到了段错误。
是什么原因造成的?

最佳答案

/* Try this - this works for me, and I guess is what you meant! */

#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Pixmap.H>

#include "image.xpm"

int main(int argc, char ** argv)
{
Fl_Window *window = new Fl_Window(800,650);
Fl_Box *image_box = new Fl_Box(5, 5, 790, 640);
Fl_Pixmap pix(XFACE);
window->end();
image_box->image(pix);
window->show(argc,argv);
return Fl::run();
}

/* end of file */

关于c++ - FLTK 绘制像素图给出段错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11044029/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com