loading
 
HBITMAP?
Anonymous
16 year
How would you go about changing the HBITMAP file, you get from using the getBitmap function, into a normal Image or Bitmap file in visual c++?
Anonymous 16 year
Im using the following code:

Bitmap^ bitmaps;
    HBITMAP ashir = rr.getBitmap("processed", image, &width, &height,width*height*3);
    
    GetObject(ashir, sizeof(BITMAP),&bitmaps);    
        
    return bitmaps;

Im really not sure how to deal with a HBITMAP since visual c++ seems to cater for the hbitmap class and not HBITMAP. When i run this code the program crashes and windows closes it down (offering to send details of the bug to Microsoft)
Anonymous 16 year
This is a common programming issue ..  I think you mean CBitmap in C++.

We used HBITMAP since that does not require MFC (for some of the older apps). You can do a search on Google (great research site!) for "Convert HBITMAP CBitmap". Try that link

http://www.google.com/search?q=convert+Hbitmap+CBitmap&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a

and see the first couple results.

STeven.
Anonymous 16 year
I dont know about Cbitmaps I just use the Bitmap and Image classes from the System::Drawing library. I mention hbitmap because the Image function in visual c++ allows for an image to be taken from an hbitmap file using the Image->Fromhbitmap function.
Anonymous 16 year
Ok a quick search on google for "Image->Fromhbitmap c++" yields this example:

http://www.codeproject.com/KB/mcpp/ijwscrcap.aspx

Perhaps that can help? It seems to use that function and a PictureBox class.

STeven.
Anonymous 16 year
That kind of confuses me more. I have this code so far:

Bitmap^ bitmaps;
    HBITMAP hbitmap = (rr.getBitmap("processed", image, &width, &height,width*height*3));
    
    
    Image^ tester=Image::FromHbitmap(hbitmap);

This gives me the error:
error C2665: 'System::Drawing::Image::FromHbitmap' : none of the 2 overloads could convert all the argument types.
Is there a simple way to take the HBITMAP and change it into a bitmap? It sounds elementary but I just dont have a clue on how to do it. I dont know what an HBITMAP is strictly speaking...
Anonymous 16 year
Has anyone else got the getBitmap function working? Have you been able to save the HBITMAP into a normal bitmap file?
Anonymous 16 year
Made further changes to the code:

    Bitmap^ bitmaps;
    HBITMAP hbitmap = rr.getBitmap("processed", image, &width, &height,width*height*3);
    GetObject(hbitmap, sizeof(hbitmap), &bitmaps);
        
    return bitmaps;

Im trying to get the HBITMAP and allocate it into a Bitmap^ variable but when I do this and step through the program the value returned for "hbitmap" is zero and the Bitmap variable "bitmaps" returned has a value of "<undefined value>" is there something wrong with my code? Ive checked and the program steps through the whole of the getBitmap function and returns "hbitmap" from within the function but this doesnt have a value either.
Anonymous 16 year
I found a way to get a bitmap from the HBITMAP you get using getBitmap. You use this line of coding:

HBITMAP hbmp;
...
Bitmap^ bmp = Image::FromHbitmap(IntPtr((int)hbmp));

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index