Hello,
I only have a small issue I would like some help with.
I originally loaded a graphic with stbi. It created a unsigned char* for the pixel data.
I then loaded that pixel data into a vector<unsigned char> image.
I am no longer using that function but i still need the data to be store in image for another function.
I've tried getting the pixels from the surfaces by casting it into a unsigned char* and then load it
into the vector like before. It returns nothing. I've watched it in the debugger watch window.
The only way for me to get anything is to cast it as a void*. So the question now is…
How do I convert it for my vector? Here's some examples of what I've tried and failed.
unsigned char* Pixels1;
int texImgSize = crpSurf1->w * crpSurf1->h * 4;
//int texImgSize = crpSurf1->pitch * crpSurf1->h;
Pixels1 = static_cast<unsigned char*>(crpSurf1->pixels);
image.clear();
const unsigned char* v = (unsigned char *) Pixels1;
std::vector<unsigned char>Pixels(v, v + texImgSize );
image = Pixels;
and this:
void* Pixels1;
int texImgSize = crpSurf1->w * crpSurf1->h * 4;
//int texImgSize = crpSurf1->pitch * crpSurf1->h;
Pixels1 = (void*)crpSurf1->pixels;
image.clear();
const unsigned char* v = (unsigned char *) Pixels1;
std::vector<unsigned char>Pixels(v, v + texImgSize );
image = Pixels;
In the void* code. I have data stored in Pixels1 but lose it when converting.
const unsigned char* v = (unsigned char *) Pixels1;
v = “”
memcpy has been my friend in different section of my code. I just haven't found out how to do it yet.
Any real help will be much appreciated.
I'll mention you in my source code along with the others I've learned from.
Thanks