2 * Copyright (c) 2000, 2001 Greg Haerr <greg@censoft.com>
4 * nxview - Nano-X image viewer
6 * Autorecognizes and displays BMP, GIF, JPEG, PNG and XPM files
11 #define MWINCLUDECOLORS
15 main(int argc,char **argv)
18 GR_WINDOW_ID window_id;
28 printf("Usage: nxview <image file> [stretch]\n");
33 fprintf(stderr, "cannot open graphics\n");
37 if (!(image_id = GrLoadImageFromFile(argv[1], 0))) {
38 fprintf(stderr, "Can't load image file: %s\n", argv[1]);
43 /* stretch to half screen size*/
44 GrGetScreenInfo(&sinfo);
48 GrGetImageInfo(image_id, &info);
53 sprintf(title, "nxview %s", argv[1]);
54 window_id = GrNewWindowEx(GR_WM_PROPS_APPWINDOW, title,
55 GR_ROOT_WINDOW_ID, 0, 0, w, h, BLACK);
57 GrSelectEvents(window_id,
58 GR_EVENT_MASK_CLOSE_REQ|GR_EVENT_MASK_EXPOSURE);
60 GrMapWindow(window_id);
65 GrGetNextEvent(&event);
67 case GR_EVENT_TYPE_CLOSE_REQ:
68 GrDestroyWindow(window_id);
70 GrFreeImage(image_id);
74 case GR_EVENT_TYPE_EXPOSURE:
75 GrDrawImageToFit(window_id, gc_id, 0,0, w,h, image_id);