Treeview changes color of Item Image












1















So I've been trying to add images to my WinAPI TreeView Common Control items. However, I have encountered something that has really been bothering me and I have no clue why it is happening. For some reason, the Image in a TreeView has a different color than the actual bitmap does. I took a screenshot of a test program I made that paints a BMP image file along with its TreeView counterpart. (It is the exact same image yet both drawings yield different results).



Window Screenshot



As you can see the image on the left is what it should look like and the image on the right is what the TreeView is drawing. Is this just the way TreeView works or something? Or is there something in my code that I'm doing wrong? It would be much appreciated if anyone could point this out because out of personal taste, the TreeView image looks visually disgusting and I would like the TreeView Control to draw my image correctly :P



The following is the code I am using to create the Treeview:



    //Load image from relative file path
g_hBmp = LoadImage(GetModuleHandle(NULL), "image.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_DEFAULTSIZE);

//Create Treeview
HWND treeview = CreateWindowEx(0, WC_TREEVIEW, NULL,
WS_VISIBLE | WS_CHILD | TVS_FULLROWSELECT,
250, 100, 500, 300,
hwnd, NULL, GetModuleHandle(NULL), NULL);

//Add single treeview item
TVITEM tvi = {0};
TVINSERTSTRUCT tvins = {0};

HIMAGELIST himl = NULL;
himl = ImageList_Create(90, 90, 0, 1, 0);
int image = ImageList_Add(himl, g_hBmp, NULL);

SendMessage(treeview, TVM_SETIMAGELIST, (WPARAM) TVSIL_NORMAL, (LPARAM) himl);

tvi.mask = TVIF_TEXT | TVIF_IMAGE;

//Set Text
tvi.pszText = "Some Item";
tvi.cchTextMax = sizeof("Some Item") - 1;
tvi.iImage = image;

tvins.item = tvi;
tvins.hInsertAfter = TVI_FIRST;
SendMessage(treeview, TVM_INSERTITEM, 0, (LPARAM)(LPTVINSERTSTRUCT) &tvins);


And here is my entire code in case you want to copy it:



#include <windows.h>
#include <commctrl.h>

HBITMAP g_hBmp = NULL;

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
switch (msg) {

case WM_CREATE: {

//Load Image
g_hBmp = LoadImage(GetModuleHandle(NULL), "image.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_DEFAULTSIZE);

//Create Treeview
HWND treeview = CreateWindowEx(0, WC_TREEVIEW, NULL,
WS_VISIBLE | WS_CHILD | TVS_FULLROWSELECT,
250, 100, 500, 300,
hwnd, NULL, GetModuleHandle(NULL), NULL);

//Add single treeview item
TVITEM tvi = {0};
TVINSERTSTRUCT tvins = {0};

HIMAGELIST himl = NULL;
himl = ImageList_Create(90, 90, 0, 1, 0);
int image = ImageList_Add(himl, g_hBmp, NULL);

SendMessage(treeview, TVM_SETIMAGELIST, (WPARAM) TVSIL_NORMAL, (LPARAM) himl);

tvi.mask = TVIF_TEXT | TVIF_IMAGE;

//Set Text
tvi.pszText = "Some Item";
tvi.cchTextMax = sizeof("Some Item") - 1;
tvi.iImage = image;

tvins.item = tvi;
tvins.hInsertAfter = TVI_FIRST;
SendMessage(treeview, TVM_INSERTITEM, 0, (LPARAM)(LPTVINSERTSTRUCT) &tvins);

break;

}
case WM_PAINT: {

PAINTSTRUCT ps = {0};

//Setup
HDC hdc = BeginPaint(hwnd, &ps);
HDC hdcPaint = CreateCompatibleDC(hdc);

HBITMAP hBmpOld = (HBITMAP) SelectObject(hdcPaint, g_hBmp);

//Painting
BitBlt(hdc, 100, 100, 90, 90, hdcPaint, 0, 0, SRCCOPY);

//Cleanup
SelectObject(hdcPaint, hBmpOld);
DeleteDC(hdcPaint);

EndPaint(hwnd, &ps);
break;

}
case WM_DESTROY: {

DeleteObject(g_hBmp);
PostQuitMessage(0);
break;

}
default: return DefWindowProc(hwnd, msg, wParam, lParam);

}

return 0;

}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) {

InitCommonControls();

HWND hwnd = NULL;
WNDCLASSEX wc = {0};

wc.cbSize = sizeof(WNDCLASSEX);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
wc.hInstance = hInstance;
wc.hbrBackground = (HBRUSH) COLOR_WINDOW;
wc.lpfnWndProc = WndProc;
wc.lpszClassName = "Parent Window";
wc.style = CS_VREDRAW | CS_HREDRAW;

RegisterClassEx(&wc);

hwnd = CreateWindowEx(0, wc.lpszClassName, "Render Window",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 1000, 1000 / 16 * 9,
NULL, NULL, hInstance, NULL);

ShowWindow(hwnd, nShowCmd);
UpdateWindow(hwnd);

MSG msg = {0};
while (GetMessage(&msg, NULL, 0, 0) > 0) {

TranslateMessage(&msg);
DispatchMessage(&msg);

}

return msg.wParam;

}









share|improve this question




















  • 3





    Make sure to specify the correct bit depht in the call to ImageList_Create(): Image List Creation Flags.

    – Swordfish
    Nov 23 '18 at 5:52
















1















So I've been trying to add images to my WinAPI TreeView Common Control items. However, I have encountered something that has really been bothering me and I have no clue why it is happening. For some reason, the Image in a TreeView has a different color than the actual bitmap does. I took a screenshot of a test program I made that paints a BMP image file along with its TreeView counterpart. (It is the exact same image yet both drawings yield different results).



Window Screenshot



As you can see the image on the left is what it should look like and the image on the right is what the TreeView is drawing. Is this just the way TreeView works or something? Or is there something in my code that I'm doing wrong? It would be much appreciated if anyone could point this out because out of personal taste, the TreeView image looks visually disgusting and I would like the TreeView Control to draw my image correctly :P



The following is the code I am using to create the Treeview:



    //Load image from relative file path
g_hBmp = LoadImage(GetModuleHandle(NULL), "image.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_DEFAULTSIZE);

//Create Treeview
HWND treeview = CreateWindowEx(0, WC_TREEVIEW, NULL,
WS_VISIBLE | WS_CHILD | TVS_FULLROWSELECT,
250, 100, 500, 300,
hwnd, NULL, GetModuleHandle(NULL), NULL);

//Add single treeview item
TVITEM tvi = {0};
TVINSERTSTRUCT tvins = {0};

HIMAGELIST himl = NULL;
himl = ImageList_Create(90, 90, 0, 1, 0);
int image = ImageList_Add(himl, g_hBmp, NULL);

SendMessage(treeview, TVM_SETIMAGELIST, (WPARAM) TVSIL_NORMAL, (LPARAM) himl);

tvi.mask = TVIF_TEXT | TVIF_IMAGE;

//Set Text
tvi.pszText = "Some Item";
tvi.cchTextMax = sizeof("Some Item") - 1;
tvi.iImage = image;

tvins.item = tvi;
tvins.hInsertAfter = TVI_FIRST;
SendMessage(treeview, TVM_INSERTITEM, 0, (LPARAM)(LPTVINSERTSTRUCT) &tvins);


And here is my entire code in case you want to copy it:



#include <windows.h>
#include <commctrl.h>

HBITMAP g_hBmp = NULL;

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
switch (msg) {

case WM_CREATE: {

//Load Image
g_hBmp = LoadImage(GetModuleHandle(NULL), "image.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_DEFAULTSIZE);

//Create Treeview
HWND treeview = CreateWindowEx(0, WC_TREEVIEW, NULL,
WS_VISIBLE | WS_CHILD | TVS_FULLROWSELECT,
250, 100, 500, 300,
hwnd, NULL, GetModuleHandle(NULL), NULL);

//Add single treeview item
TVITEM tvi = {0};
TVINSERTSTRUCT tvins = {0};

HIMAGELIST himl = NULL;
himl = ImageList_Create(90, 90, 0, 1, 0);
int image = ImageList_Add(himl, g_hBmp, NULL);

SendMessage(treeview, TVM_SETIMAGELIST, (WPARAM) TVSIL_NORMAL, (LPARAM) himl);

tvi.mask = TVIF_TEXT | TVIF_IMAGE;

//Set Text
tvi.pszText = "Some Item";
tvi.cchTextMax = sizeof("Some Item") - 1;
tvi.iImage = image;

tvins.item = tvi;
tvins.hInsertAfter = TVI_FIRST;
SendMessage(treeview, TVM_INSERTITEM, 0, (LPARAM)(LPTVINSERTSTRUCT) &tvins);

break;

}
case WM_PAINT: {

PAINTSTRUCT ps = {0};

//Setup
HDC hdc = BeginPaint(hwnd, &ps);
HDC hdcPaint = CreateCompatibleDC(hdc);

HBITMAP hBmpOld = (HBITMAP) SelectObject(hdcPaint, g_hBmp);

//Painting
BitBlt(hdc, 100, 100, 90, 90, hdcPaint, 0, 0, SRCCOPY);

//Cleanup
SelectObject(hdcPaint, hBmpOld);
DeleteDC(hdcPaint);

EndPaint(hwnd, &ps);
break;

}
case WM_DESTROY: {

DeleteObject(g_hBmp);
PostQuitMessage(0);
break;

}
default: return DefWindowProc(hwnd, msg, wParam, lParam);

}

return 0;

}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) {

InitCommonControls();

HWND hwnd = NULL;
WNDCLASSEX wc = {0};

wc.cbSize = sizeof(WNDCLASSEX);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
wc.hInstance = hInstance;
wc.hbrBackground = (HBRUSH) COLOR_WINDOW;
wc.lpfnWndProc = WndProc;
wc.lpszClassName = "Parent Window";
wc.style = CS_VREDRAW | CS_HREDRAW;

RegisterClassEx(&wc);

hwnd = CreateWindowEx(0, wc.lpszClassName, "Render Window",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 1000, 1000 / 16 * 9,
NULL, NULL, hInstance, NULL);

ShowWindow(hwnd, nShowCmd);
UpdateWindow(hwnd);

MSG msg = {0};
while (GetMessage(&msg, NULL, 0, 0) > 0) {

TranslateMessage(&msg);
DispatchMessage(&msg);

}

return msg.wParam;

}









share|improve this question




















  • 3





    Make sure to specify the correct bit depht in the call to ImageList_Create(): Image List Creation Flags.

    – Swordfish
    Nov 23 '18 at 5:52














1












1








1


1






So I've been trying to add images to my WinAPI TreeView Common Control items. However, I have encountered something that has really been bothering me and I have no clue why it is happening. For some reason, the Image in a TreeView has a different color than the actual bitmap does. I took a screenshot of a test program I made that paints a BMP image file along with its TreeView counterpart. (It is the exact same image yet both drawings yield different results).



Window Screenshot



As you can see the image on the left is what it should look like and the image on the right is what the TreeView is drawing. Is this just the way TreeView works or something? Or is there something in my code that I'm doing wrong? It would be much appreciated if anyone could point this out because out of personal taste, the TreeView image looks visually disgusting and I would like the TreeView Control to draw my image correctly :P



The following is the code I am using to create the Treeview:



    //Load image from relative file path
g_hBmp = LoadImage(GetModuleHandle(NULL), "image.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_DEFAULTSIZE);

//Create Treeview
HWND treeview = CreateWindowEx(0, WC_TREEVIEW, NULL,
WS_VISIBLE | WS_CHILD | TVS_FULLROWSELECT,
250, 100, 500, 300,
hwnd, NULL, GetModuleHandle(NULL), NULL);

//Add single treeview item
TVITEM tvi = {0};
TVINSERTSTRUCT tvins = {0};

HIMAGELIST himl = NULL;
himl = ImageList_Create(90, 90, 0, 1, 0);
int image = ImageList_Add(himl, g_hBmp, NULL);

SendMessage(treeview, TVM_SETIMAGELIST, (WPARAM) TVSIL_NORMAL, (LPARAM) himl);

tvi.mask = TVIF_TEXT | TVIF_IMAGE;

//Set Text
tvi.pszText = "Some Item";
tvi.cchTextMax = sizeof("Some Item") - 1;
tvi.iImage = image;

tvins.item = tvi;
tvins.hInsertAfter = TVI_FIRST;
SendMessage(treeview, TVM_INSERTITEM, 0, (LPARAM)(LPTVINSERTSTRUCT) &tvins);


And here is my entire code in case you want to copy it:



#include <windows.h>
#include <commctrl.h>

HBITMAP g_hBmp = NULL;

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
switch (msg) {

case WM_CREATE: {

//Load Image
g_hBmp = LoadImage(GetModuleHandle(NULL), "image.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_DEFAULTSIZE);

//Create Treeview
HWND treeview = CreateWindowEx(0, WC_TREEVIEW, NULL,
WS_VISIBLE | WS_CHILD | TVS_FULLROWSELECT,
250, 100, 500, 300,
hwnd, NULL, GetModuleHandle(NULL), NULL);

//Add single treeview item
TVITEM tvi = {0};
TVINSERTSTRUCT tvins = {0};

HIMAGELIST himl = NULL;
himl = ImageList_Create(90, 90, 0, 1, 0);
int image = ImageList_Add(himl, g_hBmp, NULL);

SendMessage(treeview, TVM_SETIMAGELIST, (WPARAM) TVSIL_NORMAL, (LPARAM) himl);

tvi.mask = TVIF_TEXT | TVIF_IMAGE;

//Set Text
tvi.pszText = "Some Item";
tvi.cchTextMax = sizeof("Some Item") - 1;
tvi.iImage = image;

tvins.item = tvi;
tvins.hInsertAfter = TVI_FIRST;
SendMessage(treeview, TVM_INSERTITEM, 0, (LPARAM)(LPTVINSERTSTRUCT) &tvins);

break;

}
case WM_PAINT: {

PAINTSTRUCT ps = {0};

//Setup
HDC hdc = BeginPaint(hwnd, &ps);
HDC hdcPaint = CreateCompatibleDC(hdc);

HBITMAP hBmpOld = (HBITMAP) SelectObject(hdcPaint, g_hBmp);

//Painting
BitBlt(hdc, 100, 100, 90, 90, hdcPaint, 0, 0, SRCCOPY);

//Cleanup
SelectObject(hdcPaint, hBmpOld);
DeleteDC(hdcPaint);

EndPaint(hwnd, &ps);
break;

}
case WM_DESTROY: {

DeleteObject(g_hBmp);
PostQuitMessage(0);
break;

}
default: return DefWindowProc(hwnd, msg, wParam, lParam);

}

return 0;

}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) {

InitCommonControls();

HWND hwnd = NULL;
WNDCLASSEX wc = {0};

wc.cbSize = sizeof(WNDCLASSEX);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
wc.hInstance = hInstance;
wc.hbrBackground = (HBRUSH) COLOR_WINDOW;
wc.lpfnWndProc = WndProc;
wc.lpszClassName = "Parent Window";
wc.style = CS_VREDRAW | CS_HREDRAW;

RegisterClassEx(&wc);

hwnd = CreateWindowEx(0, wc.lpszClassName, "Render Window",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 1000, 1000 / 16 * 9,
NULL, NULL, hInstance, NULL);

ShowWindow(hwnd, nShowCmd);
UpdateWindow(hwnd);

MSG msg = {0};
while (GetMessage(&msg, NULL, 0, 0) > 0) {

TranslateMessage(&msg);
DispatchMessage(&msg);

}

return msg.wParam;

}









share|improve this question
















So I've been trying to add images to my WinAPI TreeView Common Control items. However, I have encountered something that has really been bothering me and I have no clue why it is happening. For some reason, the Image in a TreeView has a different color than the actual bitmap does. I took a screenshot of a test program I made that paints a BMP image file along with its TreeView counterpart. (It is the exact same image yet both drawings yield different results).



Window Screenshot



As you can see the image on the left is what it should look like and the image on the right is what the TreeView is drawing. Is this just the way TreeView works or something? Or is there something in my code that I'm doing wrong? It would be much appreciated if anyone could point this out because out of personal taste, the TreeView image looks visually disgusting and I would like the TreeView Control to draw my image correctly :P



The following is the code I am using to create the Treeview:



    //Load image from relative file path
g_hBmp = LoadImage(GetModuleHandle(NULL), "image.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_DEFAULTSIZE);

//Create Treeview
HWND treeview = CreateWindowEx(0, WC_TREEVIEW, NULL,
WS_VISIBLE | WS_CHILD | TVS_FULLROWSELECT,
250, 100, 500, 300,
hwnd, NULL, GetModuleHandle(NULL), NULL);

//Add single treeview item
TVITEM tvi = {0};
TVINSERTSTRUCT tvins = {0};

HIMAGELIST himl = NULL;
himl = ImageList_Create(90, 90, 0, 1, 0);
int image = ImageList_Add(himl, g_hBmp, NULL);

SendMessage(treeview, TVM_SETIMAGELIST, (WPARAM) TVSIL_NORMAL, (LPARAM) himl);

tvi.mask = TVIF_TEXT | TVIF_IMAGE;

//Set Text
tvi.pszText = "Some Item";
tvi.cchTextMax = sizeof("Some Item") - 1;
tvi.iImage = image;

tvins.item = tvi;
tvins.hInsertAfter = TVI_FIRST;
SendMessage(treeview, TVM_INSERTITEM, 0, (LPARAM)(LPTVINSERTSTRUCT) &tvins);


And here is my entire code in case you want to copy it:



#include <windows.h>
#include <commctrl.h>

HBITMAP g_hBmp = NULL;

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
switch (msg) {

case WM_CREATE: {

//Load Image
g_hBmp = LoadImage(GetModuleHandle(NULL), "image.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_DEFAULTSIZE);

//Create Treeview
HWND treeview = CreateWindowEx(0, WC_TREEVIEW, NULL,
WS_VISIBLE | WS_CHILD | TVS_FULLROWSELECT,
250, 100, 500, 300,
hwnd, NULL, GetModuleHandle(NULL), NULL);

//Add single treeview item
TVITEM tvi = {0};
TVINSERTSTRUCT tvins = {0};

HIMAGELIST himl = NULL;
himl = ImageList_Create(90, 90, 0, 1, 0);
int image = ImageList_Add(himl, g_hBmp, NULL);

SendMessage(treeview, TVM_SETIMAGELIST, (WPARAM) TVSIL_NORMAL, (LPARAM) himl);

tvi.mask = TVIF_TEXT | TVIF_IMAGE;

//Set Text
tvi.pszText = "Some Item";
tvi.cchTextMax = sizeof("Some Item") - 1;
tvi.iImage = image;

tvins.item = tvi;
tvins.hInsertAfter = TVI_FIRST;
SendMessage(treeview, TVM_INSERTITEM, 0, (LPARAM)(LPTVINSERTSTRUCT) &tvins);

break;

}
case WM_PAINT: {

PAINTSTRUCT ps = {0};

//Setup
HDC hdc = BeginPaint(hwnd, &ps);
HDC hdcPaint = CreateCompatibleDC(hdc);

HBITMAP hBmpOld = (HBITMAP) SelectObject(hdcPaint, g_hBmp);

//Painting
BitBlt(hdc, 100, 100, 90, 90, hdcPaint, 0, 0, SRCCOPY);

//Cleanup
SelectObject(hdcPaint, hBmpOld);
DeleteDC(hdcPaint);

EndPaint(hwnd, &ps);
break;

}
case WM_DESTROY: {

DeleteObject(g_hBmp);
PostQuitMessage(0);
break;

}
default: return DefWindowProc(hwnd, msg, wParam, lParam);

}

return 0;

}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) {

InitCommonControls();

HWND hwnd = NULL;
WNDCLASSEX wc = {0};

wc.cbSize = sizeof(WNDCLASSEX);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
wc.hInstance = hInstance;
wc.hbrBackground = (HBRUSH) COLOR_WINDOW;
wc.lpfnWndProc = WndProc;
wc.lpszClassName = "Parent Window";
wc.style = CS_VREDRAW | CS_HREDRAW;

RegisterClassEx(&wc);

hwnd = CreateWindowEx(0, wc.lpszClassName, "Render Window",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 1000, 1000 / 16 * 9,
NULL, NULL, hInstance, NULL);

ShowWindow(hwnd, nShowCmd);
UpdateWindow(hwnd);

MSG msg = {0};
while (GetMessage(&msg, NULL, 0, 0) > 0) {

TranslateMessage(&msg);
DispatchMessage(&msg);

}

return msg.wParam;

}






c winapi






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 5:21







Xamser7

















asked Nov 23 '18 at 5:15









Xamser7Xamser7

7829




7829








  • 3





    Make sure to specify the correct bit depht in the call to ImageList_Create(): Image List Creation Flags.

    – Swordfish
    Nov 23 '18 at 5:52














  • 3





    Make sure to specify the correct bit depht in the call to ImageList_Create(): Image List Creation Flags.

    – Swordfish
    Nov 23 '18 at 5:52








3




3





Make sure to specify the correct bit depht in the call to ImageList_Create(): Image List Creation Flags.

– Swordfish
Nov 23 '18 at 5:52





Make sure to specify the correct bit depht in the call to ImageList_Create(): Image List Creation Flags.

– Swordfish
Nov 23 '18 at 5:52












1 Answer
1






active

oldest

votes


















0














As mentioned above by 'Swordfish', what I was missing was the proper flag when calling the ImageList_Create() function. As you can see in my call to ImageList_Create(90, 90, 0, 1, 0); I specify '0' as the third parameter (which represents the Image List Creation Flag). As stated in the documentation, the ILC_COLOR flag has a value of zero; when this flag is set it uses the 'default behavior' which is often ILC_COLOR4 (i.e. 4 bits per channel).



To fix this all I needed to do was simply call the function using the ILC_COLOR24 flag, indicating that my images have a 24-bit depth.



ImageList_Create(90, 90, ILC_COLOR24, 1, 0);





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53440960%2ftreeview-changes-color-of-item-image%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    As mentioned above by 'Swordfish', what I was missing was the proper flag when calling the ImageList_Create() function. As you can see in my call to ImageList_Create(90, 90, 0, 1, 0); I specify '0' as the third parameter (which represents the Image List Creation Flag). As stated in the documentation, the ILC_COLOR flag has a value of zero; when this flag is set it uses the 'default behavior' which is often ILC_COLOR4 (i.e. 4 bits per channel).



    To fix this all I needed to do was simply call the function using the ILC_COLOR24 flag, indicating that my images have a 24-bit depth.



    ImageList_Create(90, 90, ILC_COLOR24, 1, 0);





    share|improve this answer




























      0














      As mentioned above by 'Swordfish', what I was missing was the proper flag when calling the ImageList_Create() function. As you can see in my call to ImageList_Create(90, 90, 0, 1, 0); I specify '0' as the third parameter (which represents the Image List Creation Flag). As stated in the documentation, the ILC_COLOR flag has a value of zero; when this flag is set it uses the 'default behavior' which is often ILC_COLOR4 (i.e. 4 bits per channel).



      To fix this all I needed to do was simply call the function using the ILC_COLOR24 flag, indicating that my images have a 24-bit depth.



      ImageList_Create(90, 90, ILC_COLOR24, 1, 0);





      share|improve this answer


























        0












        0








        0







        As mentioned above by 'Swordfish', what I was missing was the proper flag when calling the ImageList_Create() function. As you can see in my call to ImageList_Create(90, 90, 0, 1, 0); I specify '0' as the third parameter (which represents the Image List Creation Flag). As stated in the documentation, the ILC_COLOR flag has a value of zero; when this flag is set it uses the 'default behavior' which is often ILC_COLOR4 (i.e. 4 bits per channel).



        To fix this all I needed to do was simply call the function using the ILC_COLOR24 flag, indicating that my images have a 24-bit depth.



        ImageList_Create(90, 90, ILC_COLOR24, 1, 0);





        share|improve this answer













        As mentioned above by 'Swordfish', what I was missing was the proper flag when calling the ImageList_Create() function. As you can see in my call to ImageList_Create(90, 90, 0, 1, 0); I specify '0' as the third parameter (which represents the Image List Creation Flag). As stated in the documentation, the ILC_COLOR flag has a value of zero; when this flag is set it uses the 'default behavior' which is often ILC_COLOR4 (i.e. 4 bits per channel).



        To fix this all I needed to do was simply call the function using the ILC_COLOR24 flag, indicating that my images have a 24-bit depth.



        ImageList_Create(90, 90, ILC_COLOR24, 1, 0);






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 3 '18 at 1:19









        Xamser7Xamser7

        7829




        7829
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53440960%2ftreeview-changes-color-of-item-image%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            If I really need a card on my start hand, how many mulligans make sense? [duplicate]

            Alcedinidae

            Can an atomic nucleus contain both particles and antiparticles? [duplicate]