Re: error: core dumped

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

ViNiCiUs <vlpg@xxxxxxxxxxxx> writes:

> I'm a newbie and I'm learning how to work with images...
> I compile a file test using "gcc  file.c -o file `pkg-config --cflags
> --libs gtk+-2.0`
> When I try to execute the file, I recept the error "core dumped".
> So, someone know what is wrong in this file ?
> 
> I want to get image.jpg and put in a vector, then after I can to
> manipulate the pixels
> 
>                          Thanks for the Help - ViNiCiUs
> 
> /*********** file.c ************/
> #include<gtk/gtk.h>
> #include<gdk-pixbuf/gdk-pixbuf.h>
> 
> int main(int argc,char *argv[ ]){
> gtk_init(&argc,&argv);
>  guchar *v;
> GdkPixbuf *pixbuf;
> GError **error;
>  pixbuf=gdk_pixbuf_new_from_file("image.jpg",error);
> v=gdk_pixbuf_get_pixels(pixbuf);
> gtk_main(0);
> }
> /********* end file.c *********/

Your usage of GError is wrong. Please read the API documentation on it
again. The (probably) correct code is:


int
main (int   argc,
      char *argv[])
{
  guchar    *v;
  GdkPixbuf *pixbuf;
  GError    *error = NULL;

  g_type_init ();

  pixbuf = gdk_pixbuf_new_from_file ("image.jpg", error);
  
  if (pixbuf)
    v = gdk_pixbuf_get_pixels (pixbuf);
  else
    /* handle error here */;

  return 0;
}


Sven
_______________________________________________

gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux