c - Copying image raw data -
I get a raw image data changing from a thread every time and I want to make a copy before that one And the thread uses it if I do not know the size of raw data, how can it get it, because it randomly selects a shape and gives raw data? How do I copy raw data from this pointer?
A copy of your raw pointer "To create data", you need additional information: this Size of data Raw data points to an image, and therefore you already have the Currently, you are only forwarding the address of raw data. To gain access to other variables, you have to forward the rest to further. One of the options (for my comments) is to expand the raw data of A better way (more manageable) would be to create a Fill this structure with your data and return your address to your other function (s). Remember to clean a memory in the correct order: first, free width and
height at the time of creation; You may also have a
BPP (bytes per pixel), if it is not an 8-bit / pixel image, these three times will give you the size of raw data.
malloc ed by
width and
height (And optionally,
BP ) needs to be stored and stored at the very beginning.
struct :
struct myData_t {int width; Inti height; Zero * data; } MyData, * myDataPtr;
myDataPtr- & gt; Data , and then only free
myDataPtr .
Comments
Post a Comment