This site is no longer active and is available for archival purposes only. Registration and login is disabled.

How use GetObject()  to access bits


How use GetObject()  to access bits

Postby roadkilldave » Sep 4, 2001 @ 8:58am

Does anyone know how to take a bitmap handle and use getobject() to get to the bits of the bitmap. I am trying to use the bitblt code that Larry has in his GAPI demo, but he was passing a memory pointer to a resource to the bitblt. I emailed him and he said to use getobject with the HBITMAP but I can't figure it out.<br><br>Need some help, please?
roadkilldave
pm Member
 
Posts: 40
Joined: Jul 6, 2001 @ 2:26pm


Re: How use GetObject()  to access bits

Postby Dan East » Sep 4, 2001 @ 12:02pm

Something like this:<br>[fixed]<br>HBITMAP hMyBitmap; <br><br>//Load your bitmap, etc.....<br><br>BITMAP bmp;<br>if (GetObject(hMyBitmap, sizeof(BITMAP), &bmp)) {<br>  //You can now directly access the bits through bmp.bmBits<br>} //else GetObject failed<br>[/fixed]<br><br>Dan East
User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Re: How use GetObject()  to access bits

Postby Digby » Sep 4, 2001 @ 12:27pm

Something you might want to look out for:  bmp.bmBits might be NULL.  I don't know if CE has this limitation but GetObject won't return a pointer to the bits on the Desktop unless the bitmap was created as a DIB section.  On the Desktop OS's you can use GetDIBits instead and get around this limitation.
Digby
pm Insider
 
Posts: 1011
Joined: Apr 29, 2001 @ 1:53pm


Re: How use GetObject()  to access bits

Postby Dan East » Sep 4, 2001 @ 12:40pm

That's true for CE.<br><br>Dan East
User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Re: How use GetObject()  to access bits

Postby Digby » Sep 4, 2001 @ 1:05pm

What I ended up doing was writing special case code that if bmBits were NULL:<br><br>- Create a temp DIB section of the same dimensions and color depth as the source bitmap.<br><br>- Create a memory DC via CreateCompatibleDC and select the source bitmap into the DC.<br><br>- Create another memory DC via CreateCompatibleDC and select the DIB section's HBITMAP into the DC.<br><br>- Use BitBlt and copy the source to the DIB section bitmap.<br><br>Since the DIB section has a pointer to the bits, you don't need to call GetObject at this point to retrieve the bits.<br><br>All of this is a pain in the butt and I've learned to keep my images in DIB form rather than bitmaps.  If you have the DIB you can always create a bitmap from them.  As you can see it's not so easy going the other way.<br><br>
Digby
pm Insider
 
Posts: 1011
Joined: Apr 29, 2001 @ 1:53pm


Return to Windows Mobile


Sort


Forum Description

A discussion forum for mobile device developers on the Windows Mobile platform. Any platform specific topics are welcome.

Moderators:

Dan East, sponge, Digby, David Horn, Kevin Gelso, RICoder

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron