Click here to Skip to main content
15,891,423 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi their friends i have been given with a project named such i am a beginner and know the concept of linked list. But i don't no how to read a image in c using jagged arrays.
This project is to read a image and get the black color read and store it into the list
i don't know the concept of jagged arrays can some one help please :(( :(( . I need the module which is used to read the data and storing it :sigh: . please give some info also if can give the code of the reading module i would be thankfulllllllllll to u forever. Thanks in advance
Posted

1 solution

A "jagged array" is a representation of a bi-dimensional array using an array of pointers that are addresses of other arrays.
They are typical for example, in represtentig set of strings.
In case of images, you can think to a COLORREF type to represent a pixel,
a COLORREF* to address a dynamic array of pixels (a row) and a COLORREF**
to address a sequence of rows (the image itself).

It will give you something similar to
COLORREF** image = malloc(nrows * sizeof(COLORREF*));
for(unsigned i=0; i<nrows; ++i) image[i] = malloc(pixel_in_a_row * sizeof(COLORREF));


After such an initialization, image[r][c] will represent the pixel at row r and column c.

About "reading and storing" there are various standard format (JPG, PNG, BMP, ...). The simpler one is probably the BMP when storing "true colors"(24 or 32 bits per pixel) image.

Just check the MSDN about "Bitmap File Format".

Of course remember to free all what you malloc at end !
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900