Hey all. I'm trying to play around with wxImage alpha channel data and I seem to be a little stumped with how to handle unsigned char* 's properly.
Basically, wxImage::GetAlpha() returns a pointer to an unsigned char* array so I can directly manipulate the alpha channel. Before doing this though, I'd like to copy the array so I have an unmodified version that I can put back when I'm done.
So my question is, how can I copy an unsigned char* array? memcpy()? (which doesn't work). I'd also like to know how to get the length because strnlen() doesn't work either.
Anyone?
copying unsigned char array? Topic is solved
copying unsigned char array?
[INSERT LAME SIG HERE]
Just guessing here, but the length could be
wxImage::GetHeight() * wxImage::GetWidth()
I would try something like this:
How does your memcpy code look like?
wxImage::GetHeight() * wxImage::GetWidth()
I would try something like this:
Code: Select all
unsigned char* alphaCopy = new unsigned char[length];
memcpy(alphaCopy, wxImage::GetAlpha(), length);
Geez i can be such a n00b sometimes. I swear i tried that, except you just showed me that my syntax was incorrect. I was doingMartin wrote:Just guessing here, but the length could be
wxImage::GetHeight() * wxImage::GetWidth()
I would try something like this:How does your memcpy code look like?Code: Select all
unsigned char* alphaCopy = new unsigned char[length]; memcpy(alphaCopy, wxImage::GetAlpha(), length);
Code: Select all
new unsigned char( length )
Code: Select all
new unsigned char[length]
Thanks heaps.
[INSERT LAME SIG HERE]