当前位置:网站首页>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`
运行
边栏推荐
- Shell Beginners Final Chapter
- AI target segmentation capability for fast video cutout without green screen
- Redis Persistence - RDB and AOF
- [LeetCode Daily Question]——654. The largest binary tree
- 力扣、752-打开转盘锁
- 个人博客系统项目测试
- Install mysql using docker
- "NetEase Internship" Weekly Diary (3)
- 【LeetCode Daily Question】——704. Binary Search
- Ask God to answer, how should this kind of sql be written?
猜你喜欢

『网易实习』周记(三)

个人博客系统项目测试

Fundamentals of Cryptography: X.690 and Corresponding BER CER DER Encodings

『网易实习』周记(一)

Service discovery of kubernetes

AOF rewrite

MySQL优化策略

2022-07-30 mysql8执行慢SQL-Q17分析

Project Background Technology Express
![[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
随机推荐
Garbage Collector CMS and G1
"NetEase Internship" Weekly Diary (2)
swift project, sqlcipher3 -> 4, cannot open legacy database is there a way to fix it
Electronic Manufacturing Warehouse Barcode Management System Solution
C language inserted into the characters of simple exercises
LeetCode brushing diary: 53, the largest sub-array and
BI-SQL丨WHILE
oracle query scan full table and walk index
2022-08-01 mysql/stoonedb slow SQL-Q18 analysis
AOF重写
leetcode / anagram in string - some permutation of s1 string is a substring of s2
Nanoprobes多组氨酸 (His-) 标签标记:重组蛋白检测方案
密码学的基础:X.690和对应的BER CER DER编码
【LeetCode Daily Question】——704. Binary Search
Good News | AR opens a new model for the textile industry, and ALVA Systems wins another award!
The state status is displayed incorrectly after the openGauss switch
Remember a gorm transaction and debug to solve mysql deadlock
Outsourcing worked for three years, it was abolished...
MySQL - CRUD operations
[ORB_SLAM2] void Frame::ComputeImageBounds(const cv::Mat & imLeft)