Loading .PNG image windows GDI
-
this is what I do:
HBITMAP hbm; hbm = (HBITMAP)LoadImage(NULL, L"./image1.**bmp**", IMAGE\_BITMAP, 0, 0, LR\_LOADFROMFILE|LR\_CREATEDIBSECTION);
This works on
.bmp
files. But I wish to load.png
files.Have you considered using
CImage
?"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Have you considered using
CImage
?"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
I'm trying to use DirectDraw inteface. CImage is considerable. I tried to use it and got messed in the HDC stuff.
Hanan888 wrote:
I tried to use it and got messed in the HDC stuff.
May be if you could show us the mess, someone may help you clean it up.
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
-
Hanan888 wrote:
I tried to use it and got messed in the HDC stuff.
May be if you could show us the mess, someone may help you clean it up.
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
dear god no!!
Maximilien Lincourt Your Head A Splode - Strong Bad
-
Hanan888 wrote:
I tried to use it and got messed in the HDC stuff.
May be if you could show us the mess, someone may help you clean it up.
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
Here is some mess: First look then I'll detail:
CImage image PAINTSTRUCT ps; HDC hDC = BeginPaint (m\_hWnd, &ps) ; (line 4) //image = iter->second.m\_pStaticData->m\_Texture; -> **this image was created previously but essentially by the same way like below** (line5) image.Load(L"./image.png"); image.Draw(hDC, (int) iter->second.m\_pStaticData->m\_UL.x, (int) iter->second.m\_pStaticData->m\_UL.y); //image.BitBlt(hDC,0,0); EndPaint(m\_hWnd, &ps);
This is 'below':
CImage image;
image.Load(L"./image.png");
pStatData->m_Texture = image;The bottom line - no picture were painted. Painted all white. (line 4) crashed. (line 4) and (line 5) behave differently, can't understand why. Perhaps there are some 'unwritten rules' for HDC stuff, I don't know them, I totally admit some sort of ignorance. :)
-
Here is some mess: First look then I'll detail:
CImage image PAINTSTRUCT ps; HDC hDC = BeginPaint (m\_hWnd, &ps) ; (line 4) //image = iter->second.m\_pStaticData->m\_Texture; -> **this image was created previously but essentially by the same way like below** (line5) image.Load(L"./image.png"); image.Draw(hDC, (int) iter->second.m\_pStaticData->m\_UL.x, (int) iter->second.m\_pStaticData->m\_UL.y); //image.BitBlt(hDC,0,0); EndPaint(m\_hWnd, &ps);
This is 'below':
CImage image;
image.Load(L"./image.png");
pStatData->m_Texture = image;The bottom line - no picture were painted. Painted all white. (line 4) crashed. (line 4) and (line 5) behave differently, can't understand why. Perhaps there are some 'unwritten rules' for HDC stuff, I don't know them, I totally admit some sort of ignorance. :)
GDI has nothing to do with DirectDraw. Check the return value from the CImage::Load() call....it's probably failing since you're passing an invalid path. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
Here is some mess: First look then I'll detail:
CImage image PAINTSTRUCT ps; HDC hDC = BeginPaint (m\_hWnd, &ps) ; (line 4) //image = iter->second.m\_pStaticData->m\_Texture; -> **this image was created previously but essentially by the same way like below** (line5) image.Load(L"./image.png"); image.Draw(hDC, (int) iter->second.m\_pStaticData->m\_UL.x, (int) iter->second.m\_pStaticData->m\_UL.y); //image.BitBlt(hDC,0,0); EndPaint(m\_hWnd, &ps);
This is 'below':
CImage image;
image.Load(L"./image.png");
pStatData->m_Texture = image;The bottom line - no picture were painted. Painted all white. (line 4) crashed. (line 4) and (line 5) behave differently, can't understand why. Perhaps there are some 'unwritten rules' for HDC stuff, I don't know them, I totally admit some sort of ignorance. :)
Hanan888 wrote:
L"./image.png"
this should probably be
_T(".\\image.png")
. :) forget it.If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke -
Hanan888 wrote:
L"./image.png"
this should probably be
_T(".\\image.png")
. :) forget it.If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain ClarkeI seem to recall that string literals can use either single slashes or double backslashes. I've not bothered to confirm this, however.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
I seem to recall that string literals can use either single slashes or double backslashes. I've not bothered to confirm this, however.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
I made a test, you're right. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke