+ free(i1->data); i1->data = 0;
+ XDestroyImage(i1);
+ XPutImage(dpy, p2, gc, i2, 0, 0, 0, 0, i2->width, i2->height);
+ XFreeGC (dpy, gc);
+ free(i2->data); i2->data = 0;
+ XDestroyImage(i2);
+ XFreePixmap(dpy, pixmap);
+ return p2;
+}
+
+
+static void
+init_images (struct state *st)
+{
+ PM *images[8];
+ struct { const unsigned char *png; unsigned long size; } bits[8];
+ XWindowAttributes xgwa;
+ XGetWindowAttributes (st->dpy, st->window, &xgwa);
+
+ int i = 0;
+ images[i++] = &st->left1;
+ images[i++] = &st->left2;
+ images[i++] = &st->right1;
+ images[i++] = &st->right2;
+ images[i++] = &st->left_front;
+ images[i++] = &st->right_front;
+ images[i++] = &st->front;
+ images[i] = &st->down;
+
+#define DEF(N,S) bits[i].png = N; bits[i].size = S; i++
+ i = 0;
+ DEF(nose_l1_png, sizeof(nose_l1_png));
+ DEF(nose_l2_png, sizeof(nose_l2_png));
+ DEF(nose_r1_png, sizeof(nose_r1_png));
+ DEF(nose_r2_png, sizeof(nose_r2_png));
+ DEF(nose_f2_png, sizeof(nose_f2_png));
+ DEF(nose_f3_png, sizeof(nose_f3_png));
+ DEF(nose_f1_png, sizeof(nose_f1_png));
+ DEF(nose_f4_png, sizeof(nose_f4_png));
+
+ for (i = 0; i < sizeof (images) / sizeof(*images); i++)
+ {
+ Pixmap mask = 0;
+ Pixmap pixmap = image_data_to_pixmap (st->dpy, st->window,
+ bits[i].png, bits[i].size,
+ &st->pix_w, &st->pix_h, &mask);
+ if (!pixmap)
+ {
+ fprintf (stderr, "%s: Can't load nose images\n", progname);
+ exit (1);
+ }
+ images[i]->p = pixmap;
+ images[i]->m = mask;
+ }
+
+ if (xgwa.width > 2560) /* Retina display */
+ {
+ for (i = 0; i < sizeof (images) / sizeof(*images); i++)
+ {
+ images[i]->p = double_pixmap (st->dpy, xgwa.visual, xgwa.depth,
+ images[i]->p, st->pix_w, st->pix_h);
+ images[i]->m = double_pixmap (st->dpy, xgwa.visual, 1,
+ images[i]->m, st->pix_w, st->pix_h);
+ }
+ st->pix_w *= 2;
+ st->pix_h *= 2;
+ }