Re: Converting Bitmap into 2D-Array
Lucress Carol wrote:
But my problem is that the vector of gray values should be given to
the function which has to calculate the fft and I have never worked
before with vector.
std::vector is a class that contains a dynamically resizable array. You can
pass it to and from a function like any other type. Keep in the back of you
head that this isn't necessarily performant though, but for the beginning
this should work correctly.
I'm not an c++-expert but i guess i have to write the following
statement
#include<vector> right?
Yes, correct. However, the question is wrong. The reason is that this is
explained in really every C++ book so you shouldn't have to ask here. If
you don't have a book, check out the book reviews at http://accu.org and
pick one of the better books.
Another question.what does the following statement means?I didn't know
one can implement two strutures once at the time.......
struct bitmap {
struct column {
pixel const& operator[](size_t row) const;
pixel& operator[](size_t row);
...
};
column const& operator[](size_t col) const;
column& operator[](size_t col);
...
};
Do you mind explaining me this?
This is called a nested type. You can nest any type and namespaces within a
namespace (including the global namespace) and you can nest types within
classes and structures (I'm not sure if you can do so with unions, too).
This is just a very convenient and clear way to group closely related
things.
bitmap b;
bitmap::column const& c = b[42];
bitmap::pixel const& p = c[13];
Note: I assumed that the type for the pixel is also nested inside class
bitmap, possibly with a simple 'typedef unsigned pixel;' or a small wrapper
class that allows you to set greyscale values.
Uli
--
C++ FAQ: http://parashift.com/c++-faq-lite
Sator Laser GmbH
Gesch??ftsf??hrer: Michael W??hrmann, Amtsgericht Hamburg HR B62 932