>I may be misunderstanding you but it sounds as though you are trying  
>take a layer from one image and add it to another image directly. 

Oh, no!. There are different layers created for different images. The
problem comes when i close the first image, and open a new image; then i
create this new image, create the new layers and associate these new layers
to the new image, but when i try to get the image ID from one of these new
layers, it returns -1. If i don't close the first image it works fine (with
both images opened).

my load -gimp relevant- code:

image = gimp_image_new (50, 50, GIMP_GRAY);
for (i = 0; i < dataset_num_rasterbands; i++) {
         get_band_data (&band[i], GDALGetRasterBand(dataset, i + 1), image,
layer_number);      /* rasterband count starts in 1 */
         gimp_image_add_layer (image, band[i].layer_id, i);

gimp_image_resize_to_layers (image);
gimp_display_new (image);

and the get_band_data code:

   band->layer_id = gimp_layer_new (image, band->colorspace_name,
band->width, band->height, GIMP_GRAY_IMAGE, 100.0, GIMP_NORMAL_MODE);
   drawable = gimp_drawable_get (band->layer_id);
   gimp_pixel_rgn_init (&pr, drawable, 0, 0, band->width, band->height,
   gimp_pixel_rgn_set_rect (&pr, scaled_data, 0, 0, drawable->width,
   gimp_drawable_flush (drawable);
   gimp_drawable_detach (drawable);

That's all.

View this message in context: 
Sent from the Gimp Developer mailing list archive at Nabble.com.

Gimp-developer mailing list

Reply via email to