FreeImage WinAPI PNG Image Loading

I am still confused about how to successfully load a PNG image using FreeImage.

My code below compiles successfully, but the image doesn't show up in the window. Suggestions?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
      case WM_CREATE: {

          FIBITMAP *dib = FreeImage_Load(FIF_PNG, "Mac.png", PNG_DEFAULT);

          SetStretchBltMode(hDC, COLORONCOLOR);
          StretchDIBits(hDC, rcDest.left, rcDest.top,

          rcDest.right-rcDest.left, rcDest.bottom-rcDest.top,
          0, 0, FreeImage_GetWidth(dib), FreeImage_GetHeight(dib),
          FreeImage_GetBits(dib), FreeImage_GetInfo(dib), DIB_RGB_COLORS, SRCCOPY);

          Label1 = CreateWindow("STATIC", "Program",
                        WS_CHILD | WS_VISIBLE | SS_LEFT,
                        233, 9, 90, 13,
                        hwnd, (HMENU) 1, NULL, NULL);

          Label2 = CreateWindow("STATIC", "Ready",
                        WS_CHILD | WS_VISIBLE | SS_LEFT,
                        256, 149, 190, 13,
                        hwnd, (HMENU) 1, NULL, NULL);

          PrgBar1 = CreateWindowEx(0, PROGRESS_CLASS, NULL,
                WS_CHILD | WS_VISIBLE | PBS_SMOOTH,
                12, 123, 524, 23, hwnd, NULL, g_hinst, NULL);

          Btn1 = CreateWindow("BUTTON", "Go",
                WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
                227, 305, 87, 23, hwnd, (HMENU) 1, g_hinst, NULL);

          HFONT hFont=CreateFont(13, // height
                                 0,  // width
                                 0,
                                 0,FW_DONTCARE,FALSE,FALSE,FALSE,DEFAULT_CHARSET,OUT_OUTLINE_PRECIS,
                    CLIP_DEFAULT_PRECIS,ANTIALIASED_QUALITY, VARIABLE_PITCH,"Microsoft Sans Serif");

          SendMessage(Btn1,             // Handle of edit control
                    WM_SETFONT,         // Message to change the font
                    (WPARAM) hFont,     // handle of the font
                    MAKELPARAM(TRUE, 0) // Redraw text
                    );
          SendMessage(Label1,             // Handle of edit control
                    WM_SETFONT,         // Message to change the font
                    (WPARAM) hFont,     // handle of the font
                    MAKELPARAM(TRUE, 0) // Redraw text
                    );
          SendMessage(Label2,             // Handle of edit control
                    WM_SETFONT,         // Message to change the font
                    (WPARAM) hFont,     // handle of the font
                    MAKELPARAM(TRUE, 0) // Redraw text
                    );
          SendMessage(PrgBar1, PBM_SETRANGE, 0, MAKELPARAM(0, 150));
          SendMessage(PrgBar1, PBM_SETSTEP, 1, 0 );

          FreeImage_Unload(dib);

          } break;
Are you trying to use the PNG as the background for the window??
No. I am just trying to display a PNG image on the Win32 Window in a specified location.
Inside what window ?| Window have SS_BITMAP style to a static control which requires a HBITMAP handle.

If you have a DC handle and want to paint itself use it inside WM_PAINT, not inside WM_CREATE as you do.
Topic archived. No new replies allowed.