viewer/showim.cpp

Go to the documentation of this file.
00001 
00020 #include          "mfcpch.h"
00021 #include          "grphshm.h"
00022 #include          "showim.h"
00023 
00024 void (*show_func) (IMAGE *, INT32, INT32, INT32, INT32, WINDOW, INT32,
00025 INT32) = def_show_sub_image;
00026 
00030 DLLSYM void def_show_sub_image(                //show this image
00031                                IMAGE *source,  //image to show
00032                                INT32 xstart,   //start coords
00033                                INT32 ystart,
00034                                INT32 xext,     //extent to show
00035                                INT32 yext,
00036                                WINDOW win,     //window to draw in
00037                                INT32 xpos,     //position to show at
00038                                INT32 ypos      //y position
00039                               ) {
00040   EIGHTOP *newop;                //message structure
00041   INT32 y;                       //y coord
00042   INT32 linelength;              //bytes per line
00043   IMAGE dummyimage;              //used for copying to
00044   IMAGEOP *sendline;             //transmitted line
00045   INT32 structsize;              //size of structure
00046   INT32 destbpp;                 //destination bits per pixel
00047 
00048   destbpp = source->get_bpp ();  //send all images unchanged
00049 
00050   newop = (EIGHTOP *) getshm (sizeof (EIGHTOP));
00051   if (newop != NULL) {
00052                                  //send the fd
00053     newop->header.fd = win->get_fd ();
00054     newop->type = SHOWIMAGE;     //send the operator
00055     newop->param.p[0].i = xext;  //send parameters
00056     newop->param.p[1].i = yext;
00057     newop->param.p[2].i = destbpp;
00058     newop->param.p[3].i = xpos;
00059     newop->param.p[4].i = ypos;
00060 
00061                                  //bytes required
00062     linelength = COMPUTE_IMAGE_XDIM (xext, destbpp);
00063     linelength++;                //round up to next
00064     linelength &= ~1;            //multiple of 2
00065                                  //size of structure
00066     structsize = (INT32) (sizeof (IMAGEOP) + linelength - 2);
00067     for (y = yext - 1; y >= 0; --y) {
00068                                  //get space
00069       sendline = (IMAGEOP *) getshm (structsize);
00070       if (sendline != NULL) {
00071         sendline->header.fd = win->get_fd ();
00072         sendline->type = SHOWLINE;
00073         sendline->size = structsize;
00074         dummyimage.capture (sendline->line, xext, 1, (INT8) destbpp);
00075         //ready for copy
00076                                  //copy to shm
00077         copy_sub_image (source, xstart, ystart + y, xext, 1, &dummyimage, 0, 0, FALSE);
00078       }
00079     }
00080   }
00081 }

Generated on Wed Feb 28 19:49:12 2007 for Tesseract by  doxygen 1.5.1