Microsoft KB Archive/152118: Difference between revisions

From BetaArchive Wiki
m (Text replacement - ".htm|" to "|")
m (Text replacement - "&" to "&")
 
(3 intermediate revisions by the same user not shown)
Line 29: Line 29:
== MORE INFORMATION ==
== MORE INFORMATION ==


The parameter &quot;pptfxDest&quot; that defines the parallelogram of the destination surface is actually a pointer to an array of type POINTFIX (not POINTFX) as defined in %DDK%\inc\winddi.h:<br />
The parameter "pptfxDest" that defines the parallelogram of the destination surface is actually a pointer to an array of type POINTFIX (not POINTFX) as defined in %DDK%\inc\winddi.h:<br />




Line 65: Line 65:
       // get the pointer to our DEVDATA structure
       // get the pointer to our DEVDATA structure
       //  
       //  
       ppdev = (PPDEV)psoSource-&gt;dhpdev;
       ppdev = (PPDEV)psoSource->dhpdev;


       //  
       //  
       // create the rotated bitmap
       // create the rotated bitmap
       //  
       //  
       sizl.cx = psoSource-&gt;sizlBitmap.cy;
       sizl.cx = psoSource->sizlBitmap.cy;
       sizl.cy = psoSource-&gt;sizlBitmap.cx;
       sizl.cy = psoSource->sizlBitmap.cx;


       if ((hSurf = (HSURF)EngCreateBitmap(
       if ((hSurf = (HSURF)EngCreateBitmap(
               sizl,
               sizl,
               sizl.cx,
               sizl.cx,
                   psoSource-&gt;iBitmapFormat,
                   psoSource->iBitmapFormat,
                   psoSource-&gt;fjBitmap,
                   psoSource->fjBitmap,
                   NULL)) == NULL )
                   NULL)) == NULL )
       {
       {
         DISPDBG((0, &quot;EngCreateBitmap FAILED; GetLastError() = %d\n&quot;,
         DISPDBG((0, "EngCreateBitmap FAILED; GetLastError() = %d\n",
   GetLastError() ));
   GetLastError() ));
             return(FALSE);
             return(FALSE);
Line 87: Line 87:
       if (!EngAssociateSurface(
       if (!EngAssociateSurface(
         hSurf,
         hSurf,
             ppdev-&gt;hdevEng, // Note: we must have stored this earlier
             ppdev->hdevEng, // Note: we must have stored this earlier
             0L) )
             0L) )
       {
       {
         DISPDBG((0, &quot;EngAssociateSurface FAILED; GetLastError() = %d\n&quot;,
         DISPDBG((0, "EngAssociateSurface FAILED; GetLastError() = %d\n",
   GetLastError() ));
   GetLastError() ));
         EngDeleteSurface(hSurf);
         EngDeleteSurface(hSurf);
Line 99: Line 99:
       // setup the destination pointfx array
       // setup the destination pointfx array
       //  
       //  
       pfxDest[0].x = sizl.cx &lt;&lt; 4; // A
       pfxDest[0].x = sizl.cx << 4; // A
       pfxDest[0].y = 0;
       pfxDest[0].y = 0;
       pfxDest[1].x = sizl.cx &lt;&lt; 4;    // B
       pfxDest[1].x = sizl.cx << 4;    // B
       pfxDest[1].y = sizl.cy &lt;&lt; 4;
       pfxDest[1].y = sizl.cy << 4;
       pfxDest[2].x = 0;        // C
       pfxDest[2].x = 0;        // C
       pfxDest[2].y = 0;
       pfxDest[2].y = 0;
Line 111: Line 111:
       rclSrc.top    = 0;
       rclSrc.top    = 0;
       rclSrc.left  = 0;
       rclSrc.left  = 0;
       rclSrc.bottom = psoSource-&gt;sizlBitmap.cy;
       rclSrc.bottom = psoSource->sizlBitmap.cy;
       rclSrc.right  = psoSource-&gt;sizlBitmap.cx;
       rclSrc.right  = psoSource->sizlBitmap.cx;


       //  
       //  
Line 122: Line 122:
             psoSource,
             psoSource,
             NULL, NULL, NULL, NULL, NULL,
             NULL, NULL, NULL, NULL, NULL,
               &amp;pfxDest[0],
               &pfxDest[0],
               &amp;rclSrc,
               &rclSrc,
               NULL,
               NULL,
               HALFTONE ))
               HALFTONE ))
       {
       {
             DISPDBG((0, &quot;EngPlgBlt FAILED; GetLastError() = %d\n&quot;,
             DISPDBG((0, "EngPlgBlt FAILED; GetLastError() = %d\n",
   GetLastError() ));
   GetLastError() ));
             EngDeleteSurface(hSurf);
             EngDeleteSurface(hSurf);

Latest revision as of 12:28, 21 July 2020

DOC: EngPlgBlt for Rotating a Bitmap Surface

Q152118



The information in this article applies to:


  • Microsoft Win32 Device Driver Kit (DDK) for Windows NT, version 3.51





SUMMARY

There is an error in the online documentation for the EngPlgBlt function, and it is quite un-intuitive. This function is used for both Win32 display drivers and Win32 printer drivers.



MORE INFORMATION

The parameter "pptfxDest" that defines the parallelogram of the destination surface is actually a pointer to an array of type POINTFIX (not POINTFX) as defined in %DDK%\inc\winddi.h:


   typedef LONG FIX;
   typedef struct  _POINTFIX
   {
       FIX   x;
       FIX   y;
   } POINTFIX, *PPOINTFIX; 


The members x and y are of type LONG. It is implied that they must be in 28.4 fixed notation. Thus, to properly use this function, you need to shift the LONG values by 4 bits to the left to comply with the 28.4 notation.

NOTE: If the Destination surface is less than the Source surface, the image will shrink and rotate accordingly. If the Destination surface is greater than the Source surface, the image will also stretch and rotate accordingly. Otherwise, the surface will just rotate accordingly.

SAMPLE

////////////////////////////////////////////////////////////////////////// 
// 
// This routine simply rotates a surface's bitmap 90 degrees to the right.
// Note: DISPDBG() is from %DDK%\src\video\displays\vga\debug.*
// 
   BOOL
   RotateSurface(
      SURFOBJ *psoSource
      )
   {
       PPDEV       ppdev;
       HSURF       hSurf;
       SURFOBJ    *psoDest;
       SIZEL       sizl;
       RECTL       rclSrc;
       POINTFIX    pfxDest[3];

       // 
       // get the pointer to our DEVDATA structure
       // 
       ppdev = (PPDEV)psoSource->dhpdev;

       // 
       // create the rotated bitmap
       // 
       sizl.cx = psoSource->sizlBitmap.cy;
       sizl.cy = psoSource->sizlBitmap.cx;

       if ((hSurf = (HSURF)EngCreateBitmap(
               sizl,
               sizl.cx,
                  psoSource->iBitmapFormat,
                  psoSource->fjBitmap,
                  NULL)) == NULL )
      {
         DISPDBG((0, "EngCreateBitmap FAILED; GetLastError() = %d\n",
   GetLastError() ));
            return(FALSE);
      }

       if (!EngAssociateSurface(
         hSurf,
            ppdev->hdevEng, // Note: we must have stored this earlier
            0L) )
      {
         DISPDBG((0, "EngAssociateSurface FAILED; GetLastError() = %d\n",
   GetLastError() ));
         EngDeleteSurface(hSurf);
            return(FALSE);
      }

       // 
       // setup the destination pointfx array
       // 
       pfxDest[0].x = sizl.cx << 4; // A
       pfxDest[0].y = 0;
       pfxDest[1].x = sizl.cx << 4;    // B
       pfxDest[1].y = sizl.cy << 4;
       pfxDest[2].x = 0;         // C
       pfxDest[2].y = 0;

       // 
       // setup the source rectangle
       // 
       rclSrc.top    = 0;
       rclSrc.left   = 0;
       rclSrc.bottom = psoSource->sizlBitmap.cy;
       rclSrc.right  = psoSource->sizlBitmap.cx;

       // 
       // rotate the original bitmap 90 degrees to the right onto the new
   bitmap
       // 
       if (!EngPlgBlt(
         psoDest,
            psoSource,
            NULL, NULL, NULL, NULL, NULL,
               &pfxDest[0],
               &rclSrc,
               NULL,
               HALFTONE ))
       {
            DISPDBG((0, "EngPlgBlt FAILED; GetLastError() = %d\n",
   GetLastError() ));
            EngDeleteSurface(hSurf);
            return(FALSE);
       }

       // 
       // you now have your rotated bitmap in psoDest until you delete it.
       // 

       EngDeleteSurface(hSurf);

       return(TRUE);
   } 



REFERENCES

For additional information on the iMode parameter, please see the following article in the Microsoft Knowledge Base:


Q140674 DOCERR: Incorrect iModes Parameter to DDI StretchBlt Functions

Additional query words: 3.51

Keywords : kbdocfix
Issue type :
Technology : kbAudDeveloper kbWinDDKSearch kbWin32sSearch kbWin32DDKSearch kbWin32DDKNT351 kbWin32DDKNTSearch


Last Reviewed: March 6, 1999
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.