Click here to Skip to main content
15,914,419 members
Home / Discussions / Graphics
   

Graphics

 
AnswerRe: 3D item to code Pin
El Corazon27-Feb-07 9:44
El Corazon27-Feb-07 9:44 
QuestionGetting GPU memory speed and bandwidth Pin
anshulmalik25-Feb-07 5:21
anshulmalik25-Feb-07 5:21 
Questionwindows grapics system and mouse movement Pin
bil_geo24-Feb-07 22:17
bil_geo24-Feb-07 22:17 
AnswerRe: windows grapics system and mouse movement Pin
Waldermort24-Feb-07 22:54
Waldermort24-Feb-07 22:54 
AnswerRe: windows grapics system and mouse movement Pin
John R. Shaw3-Mar-07 1:33
John R. Shaw3-Mar-07 1:33 
QuestionUrgent :Windows and multi monitor query Pin
bil_geo24-Feb-07 19:42
bil_geo24-Feb-07 19:42 
AnswerRe: Urgent :Windows and multi monitor query Pin
Christian Graus26-Feb-07 9:44
protectorChristian Graus26-Feb-07 9:44 
QuestionC++/MFC - Problem with GDI+ Bitmap::GetHBITMAP() Pin
PJ Arends23-Feb-07 11:37
professionalPJ Arends23-Feb-07 11:37 
[ VC8 on XP SP2 ]

Hey All,

I am having a problem using Bitmap::GetHBITMAP when the image contained in the Bitmap object has a transparent colour. (ie an icon or transparent gif). It seems that no matter what I try I am only able to get the transparent colour to be drawn as a shade of blue.

Maybe I am misunderstanding the documentation, but this is what it says
Syntax
 
    Status GetHBITMAP(
        const Color &colorBackground,
        HBITMAP *hbmReturn
    );
 
Parameters
 
    colorBackground
        [in] Reference to a Color object that specifies the background color.
             This parameter is ignored if the bitmap is totally opaque. 
    hbmReturn
        [out] Pointer to an HBITMAP that receives a handle to the GDI bitmap. 
 
Return Value

If the method succeeds, it returns Ok, which is an element of the Status enumeration.

If the method fails, it returns one of the other elements of the Status enumeration.

I read that as saying that colorBackground will be the colour that is used to fill the transparent parts of the image. But for some reason it does not work that way.

Here is my code (ShowGraphic is a function that displays images):
bool CImageViewerDoc::LoadImageFile(CString FilePath)
{
    Gdiplus::Bitmap Image((LPCWSTR)CT2W(FilePath));
    ShowGraphic(Image, _T("%s loaded into Gdiplus::Image"), FilePath);

    HBITMAP bmp;
a:  COLORREF BackGround = (COLORREF)AfxGetMainWnd()->SendMessage(WMU_GETBGCOLOUR, 0, 0);
    Gdiplus::Color clr;
b:  clr.SetFromCOLORREF(BackGround);
    if (Gdiplus::Ok == Image.GetHBITMAP(clr, &bmp))
    {
c:      ShowGraphic(bmp, _T("%s in HBITMAP"), FilePath);
        DeleteObject(bmp);
    }
}
As I step through the code with various background colours this is what I get:
a: Background       b: clr                c: Actual colour in bitmap
RGB(0, 0, 255)      0xff0000ff            RGB(0, 0, 255)
RGB(0, 255, 0)      0xff00ff00            RGB(0, 0, 0)
RGB(255, 0, 0)      0xffff0000            RGB(0, 0, 0)
RGB(192, 192, 192)  0xffc0c0c0            RGB(0, 0, 192)
RGB(236, 233, 216)  0xffece9d8            RGB(0, 0, 216)


As you can see the red and green values I supply are ignored and set to zero and only the blue value is used is the final image.

Am I using the GetHBITMAP function incorrectly? or is the function simply broken?

BTW this code works perfectly if the image does not have any transparent bits.




You may be right
I may be crazy
-- Billy Joel --


Within you lies the power for good - Use it!

QuestionRe: C++/MFC - Problem with GDI+ Bitmap::GetHBITMAP() Pin
Mark Salsbery24-Feb-07 9:59
Mark Salsbery24-Feb-07 9:59 
AnswerRe: C++/MFC - Problem with GDI+ Bitmap::GetHBITMAP() Pin
PJ Arends24-Feb-07 10:13
professionalPJ Arends24-Feb-07 10:13 
GeneralRe: C++/MFC - Problem with GDI+ Bitmap::GetHBITMAP() [modified] Pin
Mark Salsbery24-Feb-07 15:34
Mark Salsbery24-Feb-07 15:34 
GeneralRe: C++/MFC - Problem with GDI+ Bitmap::GetHBITMAP() Pin
PJ Arends24-Feb-07 15:43
professionalPJ Arends24-Feb-07 15:43 
GeneralRe: C++/MFC - Problem with GDI+ Bitmap::GetHBITMAP() Pin
Mark Salsbery24-Feb-07 16:24
Mark Salsbery24-Feb-07 16:24 
GeneralRe: C++/MFC - Problem with GDI+ Bitmap::GetHBITMAP() Pin
PJ Arends25-Feb-07 6:40
professionalPJ Arends25-Feb-07 6:40 
GeneralRe: C++/MFC - Problem with GDI+ Bitmap::GetHBITMAP() Pin
Mark Salsbery25-Feb-07 6:58
Mark Salsbery25-Feb-07 6:58 
GeneralRe: C++/MFC - Problem with GDI+ Bitmap::GetHBITMAP() Pin
PJ Arends25-Feb-07 8:51
professionalPJ Arends25-Feb-07 8:51 
GeneralRe: C++/MFC - Problem with GDI+ Bitmap::GetHBITMAP() Pin
Mark Salsbery25-Feb-07 9:02
Mark Salsbery25-Feb-07 9:02 
GeneralRe: C++/MFC - Problem with GDI+ Bitmap::GetHBITMAP() Pin
Mark Salsbery25-Feb-07 9:33
Mark Salsbery25-Feb-07 9:33 
GeneralRe: C++/MFC - Problem with GDI+ Bitmap::GetHBITMAP() Pin
PJ Arends25-Feb-07 9:39
professionalPJ Arends25-Feb-07 9:39 
GeneralRe: C++/MFC - Problem with GDI+ Bitmap::GetHBITMAP() Pin
PJ Arends25-Feb-07 12:20
professionalPJ Arends25-Feb-07 12:20 
GeneralRe: C++/MFC - Problem with GDI+ Bitmap::GetHBITMAP() Pin
Mark Salsbery26-Feb-07 7:30
Mark Salsbery26-Feb-07 7:30 
GeneralRe: C++/MFC - Problem with GDI+ Bitmap::GetHBITMAP() Pin
Mark Salsbery26-Feb-07 8:47
Mark Salsbery26-Feb-07 8:47 
GeneralRe: C++/MFC - Problem with GDI+ Bitmap::GetHBITMAP() Pin
PJ Arends26-Feb-07 9:31
professionalPJ Arends26-Feb-07 9:31 
GeneralRe: C++/MFC - Problem with GDI+ Bitmap::GetHBITMAP() Pin
Mark Salsbery26-Feb-07 9:52
Mark Salsbery26-Feb-07 9:52 
GeneralRe: C++/MFC - Problem with GDI+ Bitmap::GetHBITMAP() Pin
PJ Arends26-Feb-07 10:19
professionalPJ Arends26-Feb-07 10:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.