当前位置:网站首页>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`
运行
边栏推荐
- Fundamentals of Cryptography: X.690 and Corresponding BER CER DER Encodings
- Project Background Technology Express
- Fly propeller power space future PIE - Engine Engine build earth science
- Unable to log in to the Westward Journey
- 考完PMP学什么?前方软考等着你~
- Effects of Scraping and Aggregation
- 『网易实习』周记(一)
- Constructor instance method inheritance of typescript37-class (extends)
- Yunhe Enmo: Let the value of the commercial database era continue to prosper in the openGauss ecosystem
- 力扣、752-打开转盘锁
猜你喜欢
Power button 1374. Generate each character string is an odd number
『网易实习』周记(一)
用位运算为你的程序加速
Hash collisions and consistent hashing
Speed up your programs with bitwise operations
[ORB_SLAM2] void Frame::ComputeImageBounds(const cv::Mat & imLeft)
A good book for newcomers to the workplace
From 2023 onwards, these regions will be able to obtain a certificate with a score lower than 45 in the soft examination.
Multi-Party Threshold Private Set Intersection with Sublinear Communication-2021: Interpretation
nacos startup error, the database has been configured, stand-alone startup
随机推荐
优炫数据库导库导错了能恢复吗?
swift project, sqlcipher3 -> 4, cannot open legacy database is there a way to fix it
『网易实习』周记(一)
Use baidu EasyDL implement factory workers smoking behavior recognition
Coding Experience Talk
Constructor instance method inheritance of typescript37-class (extends)
Remember a pit for gorm initialization
TKU remembers a single-point QPS optimization (I wish ITEYE is finally back)
"NetEase Internship" Weekly Diary (3)
LeetCode brushing diary: 53, the largest sub-array and
2022-07-30 mysql8 executes slow SQL-Q17 analysis
[LeetCode Daily Question] - 103. Zigzag Level Order Traversal of Binary Tree
PHP live source code to achieve simple barrage effect related code
From 2023 onwards, these regions will be able to obtain a certificate with a score lower than 45 in the soft examination.
60 Feature Engineering Operations: Using Custom Aggregate Functions【Favorites】
Software testing Interface automation testing Pytest framework encapsulates requests library Encapsulates unified request and multiple base path processing Interface association encapsulation Test cas
BI - SQL 丨 WHILE
swift项目,sqlcipher3 -&gt; 4,无法打开旧版数据库有办法解决吗
Effects of Scraping and Aggregation
to-be-read list