- Trick to hooking DrvAlphaBlend in printer driver
- Posted by Joe Hindmarsh on November 5th, 2003
I am attempting to add support for the DrvAlphaBlend
function to the msplot sample from the DDK. I create the
function definition, add it to DrvFuncTable then add
HOOK_ALPHABLEND to the EngAssociateSurface() call. However
when I call AlphaBlend() from the GDI side my DrvAlphaBlend
() is never called, rather the function just returns
ERROR_INVALID_PARAMETER. Yet when I try the same call on a
Window or Unidrv device context they work fine.
Anyone have any idea what extra things I need to do?
Regards,
Joe Hindmarsh
- Posted by vipin on November 5th, 2003
In case of printer drivers if I remmeber properly
AlphaBlend(...) call results in GDI creating a temporary
bitmap and sending to DrvBitBlt(...). Also don't expect
blending to happen unless its a banding driver.calls like
TransparentBlt(...) don't work on printer dcs.
vipin
- Posted by Joe Hindmarsh on November 5th, 2003
The interesting thing is if you play with the Unidrv
rendering plug in and hook the DDI DrvAlphaBlend and
DrvTransparentBlt calls within it, then they do get called
when AlphaBlend or TransparentBlt are called. So unless
Unidrv is using some type of backdoor to advertise these
functions to GDI there must be a way of hooking them.
Joe Hindmarsh
- Posted by vipin on November 6th, 2003
they won't work. transpaerentblt, I am saying because the
driver doesn't have access to the device pixels. It
doesn't work unless its a banding driver where driver does
have access to the pixels. whether it hits the entry point
isn't the solution, there is no f/w implementation for
these calls.
vipin
- Posted by Joe Hindmarsh on December 5th, 2003
Vipin, surely whether or not the device pixels are there
to be written on is up to the device driver to decide, not
GDI. Using a device managed surface is simply advertising
that your surface is not is a GDI compatible format - it
does not always mean that the pixels are not actually
there. All GDI should do is check to see if these
functions are hooked and if so call them when the
appropriate GDI call is made.
Now I have investigated this a bit further and found the
following:
1) If you use an intermediate metafile (either banding or
spooling metafile) then these functions will get called. I
imagine this is because the metafile playback function
just naively passes through the records when it sees that
the functions are hooked.
2) The documentation for GetDeviceCaps(SHADEBLENDCAPS)
says: "For a printer, GetDeviceCaps returns whatever the
printer reports". The interesting thing is that there is
no way of setting this inside the driver. The place where
you would, GDIINFO.flShadeBlend is documented as "Should
be ignored by the driver and remain zero-initialized." If
I try the obvious and set it to SB_CONST_ALPHA |
SB_PIXEL_ALPHA then GetDeviceCaps() does return these
values, but DrvAlphaBlend is still not called.
3) I acually created a simple bitmap driver with a GDI
managed surface but no banding (ie no metafile) and tried
to hook these functions, and it still didn't work.
Joe Hindmarsh