#include #include #include #include #include #include #include #define GLOBAL #include "global.h" #include "fallbacks.h" #include #include #include #include #include #include XtAppContext app; int infilefd; const int ysize = 288 * 352; const int usize = 144 * 176; const int vsize = 144 * 176; int horizontal_size, vertical_size; u_char ycoeff[ysize]; u_char ucoeff[usize]; u_char vcoeff[vsize]; void exit_self(Widget w, XtPointer client, XtPointer call) { /* Do all clean up */ finish_display(); XtAppSetExitFlag(app); } void ButtonCallbk(Widget wid, XtPointer client_data, XtPointer call_data) { read(infilefd, ycoeff, ysize); read(infilefd, ucoeff, usize); if( read(infilefd, vcoeff, vsize) != vsize) { finish_display(); XtAppSetExitFlag(app); return; } render_image(ycoeff, ucoeff, vcoeff, horizontal_size, vertical_size); display_image(True); } int main(int argc, char**argv) { Widget toplevel, drawingW, picW, formW, exitW; if( (infilefd = open(argv[1], O_RDONLY)) < 0) { perror("file open "); exit(0); } toplevel = XtVaAppInitialize(&app, "RJPpicviewer", NULL, 0, &argc, argv, fallbacks, NULL); formW = XtCreateManagedWidget("box", boxWidgetClass, toplevel, NULL, 0); XtVaSetValues(formW, XtNheight, 320, NULL); XtVaSetValues(formW, XtNwidth, 400, NULL); drawingW = XtCreateManagedWidget("press and die", toggleWidgetClass, formW, NULL, 0); exitW = XtCreateManagedWidget("Exit", commandWidgetClass, formW, NULL, 0); picW = XtCreateManagedWidget("picw", coreWidgetClass, formW, NULL, 0); XtVaSetValues(picW, XtNheight, 300, NULL); XtVaSetValues(picW, XtNwidth, 375, NULL); XtAddCallback(drawingW,XtNcallback,ButtonCallbk , NULL); XtAddCallback(exitW, XtNcallback, exit_self, NULL); // XtAddEventHandler(picW, ExposureMask, FALSE, Redisplay, NULL); XtRealizeWidget(toplevel); horizontal_size = 352; vertical_size = 288; init_display(toplevel, picW, horizontal_size, vertical_size); read(infilefd, ycoeff, ysize); read(infilefd, ucoeff, usize); if( read(infilefd, vcoeff, vsize) != vsize) { fprintf(stderr, "read error"); } render_image(ycoeff, ucoeff, vcoeff, horizontal_size, vertical_size); XtAppMainLoop(app); return 0; }