Direct access to PictureBox pixel's via .hdc 
Author Message
 Direct access to PictureBox pixel's via .hdc

I am writing a DLL in NASM to suppliment the windows GDI functions
(i.e. to add a thick patterned line function), and I'm trying to
figure out how to directly access a bitmap given it's DC. The API
knows how to do this, for example:

  SetPixelV Picture1.hdc, X, Y, rgb(255, 255, 255)
  Picture1.Refresh

SetPixelV is given only the DC handle and it knows where the bitmap
is. If the API can access the bitmap via the DC handle, I should also
be able to also through the same handle. How can I directly access the
BITMAP or DIB structure (including original pixel data) given only the
hdc? I don't want to work with a copy of the bitmap.

It seems that the CreateDIBSection function might work, but does that
grant access to the original bitmap or does it just make a copy?



Tue, 25 May 2004 03:54:27 GMT  
 Direct access to PictureBox pixel's via .hdc
Hi, try this link:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q161299


Quote:
> I am writing a DLL in NASM to suppliment the windows GDI functions
> (i.e. to add a thick patterned line function), and I'm trying to
> figure out how to directly access a bitmap given it's DC. The API
> knows how to do this, for example:

>   SetPixelV Picture1.hdc, X, Y, rgb(255, 255, 255)
>   Picture1.Refresh

> SetPixelV is given only the DC handle and it knows where the bitmap
> is. If the API can access the bitmap via the DC handle, I should also
> be able to also through the same handle. How can I directly access the
> BITMAP or DIB structure (including original pixel data) given only the
> hdc? I don't want to work with a copy of the bitmap.

> It seems that the CreateDIBSection function might work, but does that
> grant access to the original bitmap or does it just make a copy?



Tue, 25 May 2004 18:33:06 GMT  
 Direct access to PictureBox pixel's via .hdc


Quote:
>I am writing a DLL in NASM to suppliment the windows GDI functions
>(i.e. to add a thick patterned line function), and I'm trying to
>figure out how to directly access a bitmap given it's DC. The API
>knows how to do this, for example:

>  SetPixelV Picture1.hdc, X, Y, rgb(255, 255, 255)
>  Picture1.Refresh

>SetPixelV is given only the DC handle and it knows where the bitmap
>is. If the API can access the bitmap via the DC handle, I should also
>be able to also through the same handle. How can I directly access the
>BITMAP or DIB structure (including original pixel data) given only the
>hdc? I don't want to work with a copy of the bitmap.

Use GetDiBits.

With SetPixelV you are modifying Picture1.Image so define a BITMAPINFO
structure that tells GetDiBits how to translate Picture1.Image and an
array, dimensioned to the image size, to receive the image data

 GetDIBits(Picture1.hdc, Picture1.Image, ....

Modify the image data in the array as you wish and then use
SetDiBits(Picture1.hdc, Picture1.Image, ....

--
Richard Mason



Wed, 26 May 2004 02:59:53 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Picturebox Upgrade...Where's the hDC property?

2. PNG direct pixel access

3. Get hDc for controls that don't expose hDc property

4. hDC: bits-per-pixel based on display?

5. Direct Access to Parallel Port or Via Driver

6. What can cause PictureBox hDC to change?

7. Displaying Access Bitmaps in A PictureBox Control Via ADO

8. Bitmap in ACCESS into a Picturebox via datacontrol

9. How to get a hWnd or hDC from a Picturebox

10. PIXELS, PIXELS, PIXELS

11. Direct 'net db access from vb app?

12. Getting Current Pixel Color in a PictureBox control

 

 
Powered by phpBB® Forum Software