Re: [Fwd: Re: How to clear/replace filter list in File Chooser?] segmentation with Glib::RefPtr<Pixbuf>
- From: oedipus <alexander arnoldt gmx de>
- To: gtkmm-list gnome org
- Subject: Re: [Fwd: Re: How to clear/replace filter list in File Chooser?] segmentation with Glib::RefPtr<Pixbuf>
- Date: Fri, 2 Mar 2007 11:42:56 -0800 (PST)
I found something more out, but it does not solve my problem. I am assigning
two pixelbuffers, I haven't told that before.
Glib::RefPtr<Pixbuf> image, histogram;
One I use to visualise some data and the other as the name points out, is a
histogram. The error does not appear anymore, if I cut out the method to put
at each pixel its values. Here is the code to it.
// create histogram and histhistogram_max and pixbuffer
~pixbuffer;
pixbuffer = Gdk::Pixbuf::create(COLORSPACE_RGB, false, 8, xx, yy) ;
guint8 *pixel, *pixels = pixbuffer -> get_pixels()
int channels = pixbuffer -> get_n_channels();
int linelength = pixbuffer -> get_rowstride();
for ( int i=0; i<xx; i++) // loop for writing into the pixbuffer
for (int j=0; j<yy; j++)
{
dat_matrix -> set_element(rw_measurement->get_data_matrix_element( i, j),
i, j);
// set up pixel value for display
pixel = pixels + i*channels +j*linelength;
pixel[0] = ( dat_matrix->get_element(i, j) )*255/(bit-1);
pixel[1] = ( dat_matrix->get_element(i, j) )*255/(bit-1);
pixel[2] = ( dat_matrix->get_element(i, j) )*255/(bit-1);
// setting up array for histogram
histogram[ dat_matrix->get_element(i, j) ]++; // write into the histogram
}
histogram_max = 0; // get the maximum value of the histogram
for (int i = 0; i<bit; i++)
{
if (histogram_max<histogram[i])
histogram_max = histogram[i]+10; // add 10 pixels for better view in
disply of histogram
}
/// this causes wiredly the segmentation fault
pixbuff_hist = Gdk::Pixbuf::create(COLORSPACE_RGB, false, 8, bit,
histogram_max);
guint8 *pixel2, *pixels2 = pixbuff_hist -> get_pixels(); // point to pixel
data of pixbuffer
int channels2 = pixbuff_hist->get_n_channels();
int linelength2 = pixbuff_hist->get_rowstride();
for ( int i=0; i<bit; i++) // loop for writing into the pixbuffer
{
for (int j=histogram_max-histogram[i]; j<=histogram_max; j++)
{
pixel2 = pixels2 + i*channels2 +j*linelength2;
pixel2[0] = 255;
pixel2[1] = 255;
pixel2[2] = 255;
}
for ( int k=0; k<=histogram_max-histogram[i]+1; k++)
{
pixel2 = pixels2 + i*channels2 +k*linelength2;
pixel2[0] = 0;
pixel2[1] = 0;
pixel2[2] = 0;
}
}/**/
--
View this message in context: http://www.nabble.com/segmentation-with-Glib%3A%3ARefPtr%3CPixbuf%3E-tf3335281.html#a9276069
Sent from the Gtkmm mailing list archive at Nabble.com.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]