--- /dev/null
+#define bg_width 48
+#define bg_height 48
+static unsigned char bg_bits[] = {
+ 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff };
#include "lbx.h"
#include "image.h"
+#include "bg.xbm"
+
static GtkTreeStore *archives;
static GtkBuilder *builder;
static GtkWidget *canvas;
+static GdkGC *bg_gc;
+
static LBX_IMG *image;
/* LBX images can have up to three palettes, with each superseding the last. */
static struct lbx_colour palette_external[256];
stride = gdk_pixbuf_get_rowstride(buf);
for (unsigned i = 0; i < info.height; i++) {
- unsigned char (*p)[3] = (void *)(data + i*stride);
+ unsigned char (*p)[4] = (void *)(data + i*stride);
for (unsigned j = 0; j < info.width; j++) {
if (imgmask[i][j]) {
get_colour(imgdata[i][j], p[j]);
+ p[j][3] = -1;
} else {
- p[j][0] = 0;
- p[j][1] = 0;
- p[j][2] = 0;
+ p[j][3] = 0;
}
}
}
if (!framebuf)
return TRUE;
+ gdk_draw_rectangle(canvas->window, bg_gc, TRUE,
+ event->area.x, event->area.y,
+ event->area.width, event->area.height);
+
gdk_draw_pixbuf(canvas->window, NULL, framebuf,
event->area.x, event->area.y, event->area.x, event->area.y,
event->area.width, event->area.height,
return 0;
lbximg_getinfo(image, &info);
- framebuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8,
+ framebuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8,
info.width, info.height);
if (!framebuf) {
printf("failed to allocate pixbuf\n");
gtk_combo_box_entry_set_text_column(GTK_COMBO_BOX_ENTRY(combo), 0);
}
+GdkBitmap *init_bg(GdkDrawable *drawable, GdkGC *gc)
+{
+ GdkColor fg = { .red = 0x6666, .green = 0x6666, .blue = 0x6666 };
+ GdkColor bg = { .red = 0x9999, .green = 0x9999, .blue = 0x9999 };
+ GdkBitmap *bitmap;
+
+ bitmap = gdk_bitmap_create_from_data(drawable, bg_bits,
+ bg_width, bg_height);
+
+ gdk_gc_set_rgb_fg_color(gc, &fg);
+ gdk_gc_set_rgb_bg_color(gc, &bg);
+ gdk_gc_set_fill(gc, GDK_OPAQUE_STIPPLED);
+ gdk_gc_set_stipple(gc, bitmap);
+ gdk_gc_set_ts_origin(gc, 0, 0);
+ return bitmap;
+}
+
int main(int argc, char **argv)
{
GtkWidget *window;
g_timeout_add(10, timeout, NULL);
gtk_widget_show_all(window);
+
+ bg_gc = gdk_gc_new(canvas->window);
+ init_bg(canvas->window, bg_gc);
gtk_main();
}