I have a sqlite3 DB with a .png image stored in it as a BLOB
I am trying to retrieve the raw data via the C++ interface like so
RawImageWrapper* obj = 0;
int rc = sqlite3_exec(db, action.c_str(), imageSelectCallback, obj, &errMsg);
Where action is just my SQL statement (it returns the correct record) and RawImageWrapper looks like this
struct RawImageWrapper
{
int callback(int argc, char **argv, char **azColName) {
for (int i = 0; i < argc; i++) {
if (strcmp(azColName[i], "Image") == 0) {
buff = std::string(argv[i]);
return 0;
}
}
return 1;
}
std::string buff;
};
Using a string to hold the image data probably isn't the best but I just wanted a quick object to wrap the char[]. However this fails with an access violation when it tries to construct buff.
What is the proper way to retrieve this image blob from my database and load it into some container? I am planning on reconstituting the image from it's raw data at a later point