当前位置:网站首页>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`
运行
边栏推荐
- ALCCIKERS Shane 20191114
- Effects of Scraping and Aggregation
- Centos7 install postgresql and enable remote access
- AWR analysis report questions for help: How can SQL be optimized from what aspects?
- 2022年NPDP考完多久出成绩?怎么查询?
- 手写一个博客平台~第一天
- 【web】理解 Cookie 和 Session 机制
- LeetCode Review Diary: 153. Find the Minimum Value in a Rotated Sort Array
- 永磁同步电机36问(二)——机械量与电物理量如何转化?
- 个人博客系统项目测试
猜你喜欢

MySQL optimization strategy

Nanoprobes丨1-mercapto-(triethylene glycol) methyl ether functionalized gold nanoparticles

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

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

Analysis of volatile principle

个人博客系统项目测试

2022-07-30 mysql8 executes slow SQL-Q17 analysis

oracle query scan full table and walk index

ofstream,ifstream,fstream read and write files

软件测试 接口自动化测试 pytest框架封装 requests库 封装统一请求和多个基础路径处理 接口关联封装 测试用例写在yaml文件中 数据热加载(动态参数) 断言
随机推荐
【web】理解 Cookie 和 Session 机制
[Server data recovery] Data recovery case of server Raid5 array mdisk disk offline
BI-SQL丨WHILE
Software testing Interface automation testing Pytest framework encapsulates requests library Encapsulates unified request and multiple base path processing Interface association encapsulation Test cas
LeetCode brushing diary: 33. Search and rotate sorted array
60 Feature Engineering Operations: Using Custom Aggregate Functions【Favorites】
leetcode / anagram in string - some permutation of s1 string is a substring of s2
AWR分析报告问题求助:SQL如何可以从哪几个方面优化?
oracle查询扫描全表和走索引
Handwritten Blog Platform ~ Day Two
2022河南青训联赛第(三)场
软件测试 接口自动化测试 pytest框架封装 requests库 封装统一请求和多个基础路径处理 接口关联封装 测试用例写在yaml文件中 数据热加载(动态参数) 断言
AOF重写
The Paddle Open Source Community Quarterly Report is here, everything you want to know is here
nacos启动报错,已配置数据库,单机启动
[ORB_SLAM2] void Frame::ComputeImageBounds(const cv::Mat & imLeft)
Analysis of volatile principle
LeetCode刷题日记: 33、搜索旋转排序数组
LeetCode刷题日记:74. 搜索二维矩阵
Nanoprobes纳米探针丨Nanogold偶联物的特点和应用