Hi,

On 22 Dec 2004, at 12:31, Siva Chandra wrote:

I have one-more question.
No problem!

The constructors which
initialise an image to a given size also ask for the
background colour. For my requirement I most of the
time set the intensity value of each pixel myself. ie.
I do something like:

int *image = new int [1000*1000];
for (int i = 0; i < 1000; i++)
    for (int j = 0; j < 1000; j++)
    {
        ... // Initialise each pixel here suitably
    }

But if I use the constructors provided, wont it lead
to performing such a pixel-by-pixel pass twice? If
yes, then it would affect the overall performance of
my algorithm.

Yes, that is correct. When I wrote the constructor, I decided to do it this way. If I do not initialize all pixels, and the user just plots to some of them, the others will be filled with garbage values. Obviously I couldn't expect the user to keep track of what pixels they've plotted to, and therefore know if the value returned from a read() was valid or not. So perhaps I could keep a list of all values plotted to... and check whether they are valid or not from read()... but that would be way too complicated. Best just set backgroundcolour to 0. The chunk that is run when using the constructor is:


tempindex = 6*hhh;
graph_[vhhh][tempindex] = (char) floor(((double)backgroundcolour_)/256);
graph_[vhhh][tempindex+1] = (char)(backgroundcolour_%256);
graph_[vhhh][tempindex+2] = (char) floor(((double)backgroundcolour_)/256);
graph_[vhhh][tempindex+3] = (char)(backgroundcolour_%256);
graph_[vhhh][tempindex+4] = (char) floor(((double)backgroundcolour_)/256);
graph_[vhhh][tempindex+5] = (char)(backgroundcolour_%256);


At compile time, with optimization, this will probably not be that bad at all.

I know it makes one uneasy to do things twice, but PNGwriter's main emphasis is on ease of use and consistency.


Paul Blackburn



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/
_______________________________________________
http://pngwriter.sourceforge.net/
PNGwriter-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/pngwriter-users

Reply via email to