Thread: Is possible access memory like 2-3 dimensional array?

  1. #1
    Registered User
    Join Date
    Dec 2013
    Posts
    46

    Is possible access memory like 2-3 dimensional array?

    x+y*picturewidth*bytesperpixel+colorcomponent
    which means x is 0-xxx
    y=0-(pictureswidth - 1)
    colorcompoent is 0-3 which tells what color compoent i want
    access 0=Alpha chanel 1=red component 2=green component 3=blue component
    bytesperpixel=is constant which tells one pixel is 4 bytes this time.
    ja memory is arraged in sequence ARGBARGB
    and x ,y and colorcomponent is array parameters and array is made form bytes is thistime if doesmatter...sometimes direct arraylike way is better understanded here (of coursei can make function which allows eaily this kindaccess but i bet is slower and painting etc programs slowness is not good thing at all) and i cannot use normal arrays they seem save sizelimits here and i cannot load (maybe save) using platforms features to them. which i dont tell more but what i understanded it is thisway functions what i gimes structure where is pointer to truecolordat (structure has also other values as well,and way what i going use i get truecolor data...)...

  2. #2
    Registered User
    Join Date
    Dec 2013
    Posts
    46
    And want way which dont care platform.

  3. #3
    Registered User
    Join Date
    Sep 2014
    Posts
    364
    I don't know what you exactly mean (my english is a little bit rusty).
    But you can build your own structures for pixel.
    Code:
    typedef struct pixel_argb_t {
        uint8_t alpha;
        uint8_t red;
        uint8_t green;
        uint8_t blue;
    } Pixel_ARGB;
    With this, you can allocate memory for every picture that you want.
    Code:
    Pixel_ARGB *pic;
    …
    if ((pic = malloc( sizeof(*pic) * x * y )) == NULL) {
        fprintf(stderr, "no memory left!\n");
        return -1;
    }
    …
    Is this what you mean?
    Other have classes, we are class

  4. #4
    Registered User
    Join Date
    Dec 2013
    Posts
    46
    Quote Originally Posted by WoodSTokk View Post
    I don't know what you exactly mean (my english is a little bit rusty).
    But you can build your own structures for pixel.
    Code:
    typedef struct pixel_argb_t {
        uint8_t alpha;
        uint8_t red;
        uint8_t green;
        uint8_t blue;
    } Pixel_ARGB;
    With this, you can allocate memory for every picture that you want.
    Code:
    Pixel_ARGB *pic;
    …
    if ((pic = malloc( sizeof(*pic) * x * y )) == NULL) {
        fprintf(stderr, "no memory left!\n");
        return -1;
    }
    …
    Is this what you mean?
    Yes but another thing is access such way memory area what i have address allready. which operating systems what i talk gives me part of one structure.

  5. #5
    Registered User
    Join Date
    Dec 2013
    Posts
    46
    I forgot fact in this OS API is recommend copy needed data to safe and then release such object. which means i can copy data what os gives to such area. or actually need it. and i have basic tools do thing with your source. which is not fully direct solution hard describe better but my imaination solves other things.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to access different things in two dimensional arrays
    By Liangine in forum C++ Programming
    Replies: 4
    Last Post: 10-28-2013, 10:56 PM
  2. Replies: 4
    Last Post: 09-02-2013, 11:19 AM
  3. Segfaulting/memory access for array (Linux)
    By Blasz in forum C Programming
    Replies: 19
    Last Post: 06-06-2010, 01:10 PM
  4. two dimensional int array access problems ;/
    By krST in forum C Programming
    Replies: 6
    Last Post: 01-04-2006, 07:02 AM
  5. memory allocation problem with 2 dimensional array
    By nano_nasa in forum C++ Programming
    Replies: 7
    Last Post: 06-13-2002, 11:34 AM