This is how I load my graphics.
- Code:
bool Map2dWnd::WindowInit()
{
using namespace Frog;
DisplayDevice* display = GetDisplay();
...
// Load Robot Icon
#if _WIN32_WCE
m_pRobotIcon = Frog::LoadImage(display,_T("\\Robot.gif"));
#else
m_pRobotIcon = Frog::LoadImage(display,_T("Robot.gif"));
#endif
if (m_pRobotIcon == 0)
{
::MessageBox(0,_T("Unable to load robot icon."),_T("2D Map Window Initialization Error:"),MB_OK);
return false;
}
m_pRobotIcon->SetColorMask(0);
...
}
If LoadImage() fails, it will return a NULL pointer so you can test it for errors. SetColorMask(COLOR) will make the color COLOR transparent.
The important thing to notice, is that WinCE doesn't use "drive letters", but instead uses an absolute path ("\"), pointing to "My Computer". This goes for all fileloading on WinCE.
There is no difference between GIF,JPG,BMP. On PPC you can also load PNG:s, but don't rely to much on alpha shading cause it won't work. Neither will transparent gifs (I've written about this in another thread here somewhere).
2. How do you load image(s) from a buffer and not a resource, like for example after loading from a file using fread()?
If you look at the Blit example, you see how to load from a resource.
There is really no reason why you should want to load the file by yourself into memory, and then decode it (or Load it) into a PF Surface. However, it could be usefull if you get streamed picture data over the network and want to display it on the screen. This is how I did it:
- Code:
Surface* frame = Frog::LoadImage(m_pDisplay, (const uint8_t*)start, (const uint8_t*)end);
where start and end is two pointers, pointing to the start and end of the (binary) image data.
For more info about images, see image.h and image.cpp and also, look up imgdecmp.dll on Google.
Hope this'll help ya out.