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 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.

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 malloc ed by width and height (And optionally, BP ) needs to be stored and stored at the very beginning.

A better way (more manageable) would be to create a struct :

  struct myData_t {int width; Inti height; Zero * data; } MyData, * myDataPtr;   

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 myDataPtr- & gt; Data , and then only free myDataPtr .

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -