I have a JPG file that I would like to load as a resource and save it as a file on the hard disk. What I'm doing now is saving the picture as a custom user data and outputting it as a file.
The problem i'm having is loading the jpg data from the resource. Currently, i'm using this function:
UCHAR* LoadCustomResource(int resID, HINSTANCE hinstance)
// first find the resource info block
if ((hResInfo = FindResource(hinstance,
"CUSTOMRESOURCETYPE")) == NULL)
// now get a handle to the resource
if ((hResource = LoadResource(hinstance, hResInfo)) == NULL)
// finally get and return a pointer to the resource
I'm then writing the data using this line:
ofs1.write( (char*) LoadCustomResource(IDR_JPG1, hInstance), sizeof(MAKEINTRESOURCE(IDR_JPG1)) );
I'm so lost, as when i run the program it gives me an error after opening the file to write to. Any suggestions?
I am assuming that you are using OutputStream, write function
basic_ostream& write(const E *s, streamsize n);
first thing did you try to check if the data is in the buffer before you are writing it. If so then is then are you writing the JPEG hearder before writing the buffer data.
Let me know
What does this return as a size?