Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
kenberkun  
#1 Posted : Monday, January 10, 2005 2:12:00 PM(UTC)
kenberkun

Rank: Member

Groups: Member
Joined: 1/5/2005(UTC)
Posts: 20

I need to take a bitmap that I've manipulated with Graphics Mill and pass it to another routine that is expecting a handle to a bitmap. I'm a total stranger to the IPictureDisp concept and having gone nuts trying to understand it, I'm giving up and asking for help. Please note that this is in C++.

I execute:
Code:
IPictureDisp * pPicDisp;
piBitmapData->get_Picture(&pPicDisp);


But then I get lost. Any help is greatly appreciated.

Thanks,
Ken

Edited by user Monday, December 24, 2007 4:20:01 PM(UTC)  | Reason: Not specified

Andrew  
#2 Posted : Tuesday, January 11, 2005 4:58:00 PM(UTC)
Andrew

Rank: Advanced Member

Groups: Member, Administration
Joined: 8/2/2003(UTC)
Posts: 866

Thanks: 2 times
Was thanked: 26 time(s) in 26 post(s)
It should be something like this:

Code:
CComPtr<IPicture> piPicture;
piBitmapData->get_Picture(&piPicture);

...
OLE_HANDLE hBmp;
piPicture->get_Handle(&hBmp);

...


Hope draw attention, get_Picture returns a copy of pixels. So if you need handle to bitmap to modify it, you need to copy the data back to the Bitmap.

To get more information about using IPicture and related things, read about OleCreatePictureIndirect function, IPicture/IPictureDisp interface, PICTDESC structure, etc in MSDN.

Edited by user Monday, December 24, 2007 4:20:17 PM(UTC)  | Reason: Not specified

kenberkun  
#3 Posted : Thursday, January 13, 2005 9:09:00 AM(UTC)
kenberkun

Rank: Member

Groups: Member
Joined: 1/5/2005(UTC)
Posts: 20

The problem is that piBitmapData->get_Picture() expects a IPictureDisp pointer, not an IPicture pointer. And IPictureDisp does not have a get_Handle method, so what you've posted won't work.

I have tried the following, but it doesn't work and I'm probably doing some stupid thing wrong.

Code:
CComPtr<IPicture> piPicture; 
CComPtr<IPictureDisp> piPictureDisp;
CComPtr<IBitmapData> piBitmapData;

piBitmap->get_Data(&piBitmapData);
piBitmapData->get_Picture(&piPictureDisp); 
HBITMAP hBmp; 
piPictureDisp->QueryInterface(IID_IPicture,(LPVOID*)&piPicture);
piPicture->get_Handle((OLE_HANDLE*)&hBmp);


but the hBmp does not appear to be a handle to a bitmap. I've been unable to use it for the routine I need to call, nor can I use it successfully in OleCreatePictureIndirect. But the documentation for all these structures and interfaces is very very poor.

This is very important for my application (I'm getting around it by writing to a file and then reading the file in again, but obviously this is very slow), so if you actually have this working somewhere, I'd sure appreciate it!

Yours,

Ken

Edited by user Monday, December 24, 2007 4:20:36 PM(UTC)  | Reason: Not specified

Andrew  
#4 Posted : Thursday, January 13, 2005 6:46:00 PM(UTC)
Andrew

Rank: Advanced Member

Groups: Member, Administration
Joined: 8/2/2003(UTC)
Posts: 866

Thanks: 2 times
Was thanked: 26 time(s) in 26 post(s)
Do you mean that the hBmp is filled with "trash"/NULL?

What the pixel format the bitmap has? Also, could you try get_Width/get_Height properties of the IPicture (to ensure whether the picture was create successfully at all)?
kenberkun  
#5 Posted : Tuesday, January 18, 2005 8:16:00 AM(UTC)
kenberkun

Rank: Member

Groups: Member
Joined: 1/5/2005(UTC)
Posts: 20

Just to close this out, I gave up entirely on using the IPictDisp interface. Documentation is so bad that it is unusable. Instead I built my own bitmap using Scan0, and it works just fine.

Thanks for all your help.

ken
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.