Hello all,

I am using pngwriter (v0.5.3) with libpng (v1.2.8) on a SunBlade1000
system with SunOS 5.8 as the operating system. I am recieving a
segmentation fault in all the constructors of pngwriter class. Below I
am attaching an example of log snippet from gdb.

===================================================================
GNU gdb 5.2
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "sparc-sun-solaris2.8"...
(gdb) r 0 0 100 -0.37 -0.612 256 256 1000 test.png
Starting program: /home/r64032/fun/progs/a.out 0 0 100 -0.37 -0.612
256 256 1000 test.png
Customizing environment for Sun operating system ...

Program received signal SIGSEGV, Segmentation fault.
0x000153f0 in pngwriter::pngwriter(int, int, int, char*) (this=Cannot
access memory at address 0xf3beefd4
)
    at /home/r64032/fun/share/src/pngwriter-0.5.3/src/pngwriter.cc:179
179     {
(gdb) 
===================================================================

The code I am trying  to compile is written below.

===================================================================
/* Creates fractals based on Julia sets and dumps the pixel
information in xpm format */

#include <iostream>
#include <pngwriter.h>
using namespace std;

// Define 24-bit true colors
#define NCOL_R 256
#define NCOL_G 256
#define NCOL_B 256
#define MAX_COLORS NCOL_R*NCOL_G*NCOL_B

double cr=0.0, ci=0.0, zoom=100, creal=-0.37, cimg=-0.617;
int w=256, h=256, max_itr=1000;
char *output_file_name="test.png";

struct color {
        int red, green, blue;
};

int main (int argc, char **argv);
int recurs (double, double, int); //Mandelbrot
int recurs (double, double, double, double, int); //Julia

int main (int argc, char **argv) {
        
        int i=0, j=0, k=0, col=0;
        int dcol_r=0xffff/NCOL_R, dcol_g=0xffff/NCOL_G, dcol_b=0xffff/NCOL_B;
        long int pixel;
        pngwriter image (w, h, 0, output_file_name);
        
        if (argc<9) { cout<<"USAGE: julia_xpm cr ci zoom creal cimg w h
max_itr output_file_name\n"; return 0; }
        cr=atof (argv[1]);
        ci=atof (argv[2]);
        zoom=atof (argv[3]);
        creal=atof (argv[4]);
        cimg=atof (argv[5]);
        w=atoi (argv[6]);
        h=atoi (argv[7]);
        max_itr=atoi (argv[8]);
        output_file_name=argv[9];
        cout<<"Arguments read successfully\n";
        


        // create color palette
        color color_palette[MAX_COLORS];
        for (i=0; i<NCOL_R; i++) {
                for (j=0; j<NCOL_G; j++) {
                        for (k=0; k<NCOL_B; k++) {
                                color_palette[col].red=0xffff-dcol_r*i;
                                color_palette[col].green=0xffff-dcol_g*j;
                                color_palette[col].blue=0xffff-dcol_b*k;
                                col++;
                        }
                }
        }

        // draw the picture
        for (i=0; i<h; i++) {
                for (j=0; j<w; j++) {
                        pixel=(double) recurs (cr+(j-w/2)/zoom, 
ci+(i-h/2)/zoom, creal,
cimg, max_itr)/max_itr*MAX_COLORS;
                        image.plot (i, j, color_palette[pixel].red,
color_palette[pixel].green, color_palette[pixel].blue);
                }
        }
        image.close ();
        return (0);
}

int recurs (double zr=0, double zi=0, int max_itr=1000) {
  int n=0;
  double tr=0.0, ti=0.0;
  for (n=0; n<max_itr; n++){
    tr=zr*zr-zi*zi;
    ti=2*zr*zi;
    if ((tr*tr+ti*ti)>2.0) break;
    zr=tr;
    zi=ti;
  }
  return (n);
}

int recurs (double zr=0.0, double zi=0.0, double creal=-0.37, double
cimg=-0.612, int max_itr=1000) {
        int n=0;
        double tr=0.0, ti=0.0;
        for (n=0; n<max_itr; n++) {
                tr=zr*zr-zi*zi+creal;
                ti=2*zr*zi+cimg;
                if ((tr*tr+ti*ti)>2.0) break;
                zr=tr;
                zi=ti;
        }
        return (n);
}
===================================================================
I am compiling the above code without any Freetype support. Can
someone help me out with what exactly is going wrong because I have
kinda givenup in figure out the reason behind the problem. Does it
have to do anything with g++ version (gnu-gcc-3.3.2)?
-- 
Regards
Madhur Kashyap


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&op=click
_______________________________________________
http://pngwriter.sourceforge.net/
PNGwriter-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pngwriter-users

Reply via email to