当前位置:网站首页>GTK RGB图像绘制
GTK RGB图像绘制
2022-08-02 02:17:00 【百口可乐__】
源代码
#include <gtk/gtk.h>
#define WIDTH 300
#define HEIGHT 300
GtkWidget *window;
GdkPixbuf *pixbuf;
GtkWidget *image;
int main() {
gtk_init(NULL, NULL);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size(GTK_WINDOW(window), WIDTH, HEIGHT);
gtk_window_set_title(GTK_WINDOW(window), "RgbaShow");
guchar rgbbuf[WIDTH *HEIGHT * 3];
guchar *pos;
pos = rgbbuf;
for (int y = 0; y < HEIGHT; y++)
{
for (int x = 0; x < WIDTH; x++)
{
*pos++ = x<WIDTH/2?100:200; /* Red. */
*pos++ = y<HEIGHT/2?200:150; /* Green. */
*pos++ = 207; /* Blue. */
}
}
pixbuf = gdk_pixbuf_new_from_data(rgbbuf, GDK_COLORSPACE_RGB, FALSE, 8, WIDTH, HEIGHT, WIDTH*3, NULL, NULL);
image = gtk_image_new_from_pixbuf(pixbuf);
gtk_container_add(GTK_CONTAINER(window),image);
gtk_widget_show_all(window);
g_signal_connect(G_OBJECT(window),"destroy",G_CALLBACK(gtk_main_quit),NULL);
gtk_main();
}
编译
g++ t.c `pkg-config --cflags --libs gtk+-2.0`
运行
边栏推荐
- Multi-Party Threshold Private Set Intersection with Sublinear Communication-2021:解读
- NIO's Sword
- Speed up your programs with bitwise operations
- 记一个gorm初始化的坑
- 手写一个博客平台~第一天
- Shell Beginners Final Chapter
- Reflex WMS Intermediate Series 7: What should I do if I want to cancel the picking of an HD that has finished picking but has not yet been loaded?
- Constructor instance method inheritance of typescript37-class (extends)
- 数据链路层的数据传输
- AOF重写
猜你喜欢

Garbage Collector CMS and G1

Speed up your programs with bitwise operations

Good News | AR opens a new model for the textile industry, and ALVA Systems wins another award!

FOFAHUB使用测试
![[LeetCode Daily Question] - 103. Zigzag Level Order Traversal of Binary Tree](/img/b9/35813ae2972375fa728e3c11fab5d3.png)
[LeetCode Daily Question] - 103. Zigzag Level Order Traversal of Binary Tree

【LeetCode每日一题】——704.二分查找

永磁同步电机36问(三)——SVPWM代码实现

工程师如何对待开源

记一次gorm事务及调试解决mysql死锁

Golang分布式应用之定时任务
随机推荐
LeetCode刷题日记:LCP 03.机器人大冒险
oracle query scan full table and walk index
Talking about the "horizontal, vertical and vertical" development trend of domestic ERP
Hiring a WordPress Developer: 4 Practical Ways
Pinduoduo leverages the consumer expo to promote the upgrading of domestic agricultural products brands and keep pace with international high-quality agricultural products
Chengdu openGauss user group recruit!
Multi-Party Threshold Private Set Intersection with Sublinear Communication-2021: Interpretation
【web】理解 Cookie 和 Session 机制
LeetCode brush diary: LCP 03. Machine's adventure
Use baidu EasyDL implement factory workers smoking behavior recognition
2022-07-30 mysql8执行慢SQL-Q17分析
【LeetCode每日一题】——654.最大二叉树
MySQL优化策略
MySQL - CRUD operations
Install mysql using docker
Redis for distributed applications in Golang
A good book for newcomers to the workplace
Nanoprobes丨1-巯基-(三甘醇)甲醚功能化金纳米颗粒
volatile原理解析
记一次gorm事务及调试解决mysql死锁