我想创建窗口的独立地操纵像素颜色,就像位图图片一样。我更喜欢针对Ubuntu的本地库-> Linux。也许可以使用类似的功能:
SetPixel(int x,int y,int Color) {
//Some code that set the color of one pixel by his coordinates x and y
return 0;//May return an error
}
它将通过其位置设置窗口中像素的颜色
我已经尝试了许多教程(正在使用Graphics.h或Windows.h),但是它们都没有在工作在我的计算机上,我可能做错了但< [我发现的内容不明确。无论如何,我不知道如何下载库无需指示。我相信它在Linux上不起作用。
SDL2不是Linux的本机。顺便说一句如果需要任何澄清,请添加评论或建议修改
http://lazyfoo.net/tutorials/SDL/index.php
您需要的特殊功能在此版本中可用:http://lazyfoo.net/tutorials/SDL/08_geometry_rendering/index.php
仅向您显示功能:
SDL_RenderSetDrawColor( myRenderer, 0xFF, 0xFF, 0xFF, 0xFF);
SDL_RenderDrawPoint( myRenderer, cordX, cordY);
因此您可以选择颜色并独立更改像素PS:它在ubuntu上有效,文章将教您如何配置所需的一切。PS2:如果您需要帮助,请与我联系,我的操作系统也是ubuntu。
#include <X11/Xlib>
bool SetPixel(uint16_t X,uint16_t Y,uint32_t Color){
XSetForeground(_Display,_GraphicCTX,Color);
XDrawPoint(_Display,_Window,_GraphicCTX,X,Y);
return true;
}
bool Setup(){ //Use it first to make every graphical manipulations working :)
Display=XOpenDisplay(0);//Create a display
Window=XCreateSimpleWindow(Display,DefaultRootWindow(Display),0,0,480,360,0,0,0); //Create a Window
XMapWindow(Display,Window);//Make the Window visible
GraphicCTX=XCreateGC(Display,Window,0,NIL);//Create a Graphics Context
//v Wait for a MapNotify XEvent for next commands
XSelectInput(Display,Window,StructureNotifyMask);
while(1){
XEvent E;
XNextEvent(Display,&E);
if(E.type==MapNotify)break;
}
return true;
}
我使用X11是因为它是Linux的本地图形协议。事实上,我制作了一个库,使使用类使一切变得更简单。
需要先执行设置功能,然后才能执行任何图形操作,否则它将无法执行任何操作!
这可以工作,但是要进行高级开发,您将需要玩更多的图像! manual for Xlib非常好!