home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / x / xibm.zip / mpel / mpelPlane.c < prev    next >
C/C++ Source or Header  |  1989-11-09  |  4KB  |  125 lines

  1. /*
  2.  * Copyright IBM Corporation 1987,1988,1989
  3.  *
  4.  * All Rights Reserved
  5.  *
  6.  * Permission to use, copy, modify, and distribute this software and its
  7.  * documentation for any purpose and without fee is hereby granted,
  8.  * provided that the above copyright notice appear in all copies and that 
  9.  * both that copyright notice and this permission notice appear in
  10.  * supporting documentation, and that the name of IBM not be
  11.  * used in advertising or publicity pertaining to distribution of the
  12.  * software without specific, written prior permission.
  13.  *
  14.  * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  15.  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  16.  * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  17.  * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  18.  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  19.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  20.  * SOFTWARE.
  21.  *
  22. */
  23. /***********************************************************
  24.         Copyright IBM Corporation 1987,1988
  25.  
  26.               All Rights Reserved
  27.  
  28. Permission to use, copy, modify, and distribute this software and its
  29. documentation for any purpose and without fee is hereby granted,
  30. provided that the above copyright notice appear in all copies and that
  31. both that copyright notice and this permission notice appear in
  32. supporting documentation, and that the name of IBM not be
  33. used in advertising or publicity pertaining to distribution of the
  34. software without specific, written prior permission.
  35.  
  36. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  37. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  38. IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  39. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  40. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  41. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  42. SOFTWARE.
  43.  
  44. ******************************************************************/
  45.  
  46. /* $Header: /andrew/X11/r3src/earlyRelease/server/ddx/ibm/mpel/RCS/mpelPlane.c,v 1.4 88/11/14 18:30:38 paul Exp $ */
  47. /* $Source: /andrew/X11/r3src/earlyRelease/server/ddx/ibm/mpel/RCS/mpelPlane.c,v $ */
  48.  
  49. #ifndef lint
  50. static char *rcsid = "$Header: /andrew/X11/r3src/earlyRelease/server/ddx/ibm/mpel/RCS/mpelPlane.c,v 1.4 88/11/14 18:30:38 paul Exp $" ;
  51. #endif
  52.  
  53. #include "X.h"
  54. #include "Xmd.h"
  55. #include "servermd.h"
  56. #include "os.h"
  57.  
  58. #include "OScompiler.h"
  59.  
  60. #include "ibmTrace.h"
  61.  
  62. /***==================================================================***/
  63.  
  64.  
  65. /* Was MIGETPLANE -- gets a bitmap representing one plane of pDraw
  66.  * A helper used for CopyPlane and XY format GetImage
  67.  * No clever strategy here, we grab a scanline at a time, pull out the
  68.  * bits and then stuff them in a 1 bit deep map.
  69.  */
  70. unsigned long *
  71. mpelGetPlane( planeNum, sx, sy, w, h, result )
  72.     int planeNum ;    /* number of the bitPlane */
  73.     int sx, sy, w, h ;
  74.     unsigned long *result ;
  75. {
  76.     int i, j, k ;
  77.     register unsigned char *pp ;
  78.     unsigned char *pline ;
  79.     unsigned long int bit ;
  80. #if BITMAP_SCANLINE_UNIT == 8
  81.     register unsigned char tmpScanUnitOut ;
  82.     unsigned char *pScanUnitOut = (unsigned char *) result ;
  83. #endif
  84. #if BITMAP_SCANLINE_UNIT == 16
  85.     register CARD16 tmpScanUnitOut ;
  86.     CARD16 *pScanUnitOut = (CARD16 *) result ;
  87. #endif
  88. #if BITMAP_SCANLINE_UNIT == 32
  89.     register CARD32 tmpScanUnitOut ;
  90.     CARD32 *pScanUnitOut = (CARD32 *) result ;
  91. #endif
  92.  
  93. TRACE( ( "mpelGetPlane(%d,%d,%d,%d,%d,0x%X)\n",
  94.        planeNum, sx, sy, w, h, result ) ) ;
  95.  
  96.     pline = (unsigned char *) ALLOCATE_LOCAL( w ) ;
  97.  
  98.     for ( i = sy ; i < sy + h ; i++ ) {
  99.     /* Fetch the next line */
  100.     mpelReadColorImage( sx, i, w, 1, pline, w ) ;
  101.     for ( j = 0, pp = pline, tmpScanUnitOut = 0, k = 0 ;
  102.           j < w ;
  103.           j++, pp++ ) {
  104.         bit = (unsigned long int) ( ( *pp >> planeNum ) & 1 ) ;
  105.         /* Now insert that bit into a bitmap in XY format */
  106. #if (BITMAP_BIT_ORDER == LSBFIRST)
  107.         bit >> = k ;
  108. #else
  109.         bit <<= ( ( BITMAP_SCANLINE_UNIT - 1 ) - k ) ;
  110. #endif
  111.         tmpScanUnitOut |= bit ;
  112.         if ( ++k == BITMAP_SCANLINE_UNIT ) {
  113.         *pScanUnitOut++ = tmpScanUnitOut ;
  114.         tmpScanUnitOut = 0 ;
  115.         k = 0 ;
  116.         }
  117.         }
  118.     if ( k )
  119.       *pScanUnitOut++ = tmpScanUnitOut ;
  120.     }
  121.     DEALLOCATE_LOCAL( pline ) ;
  122.  
  123.     return result ;
  124. }
  125.