~ubuntu-branches/ubuntu/trusty/gimp/trusty

« back to all changes in this revision

Viewing changes to plug-ins/common/file-mng.c

  • Committer: Bazaar Package Importer
  • Author(s): Ari Pollak
  • Date: 2009-08-14 09:57:17 UTC
  • mto: (1.1.21 upstream) (0.1.5 squeeze)
  • mto: This revision was merged to the branch mainline in revision 48.
  • Revision ID: james.westby@ubuntu.com-20090814095717-37dh2xqy5t0rurpk
ImportĀ upstreamĀ versionĀ 2.6.7

Show diffs side-by-side

added added

removed removed

Lines of Context:
464
464
 
465
465
      if (transparent != -1)
466
466
        {
467
 
          png_color palette[256];
 
467
          png_color palette[256] = { {0, 0, 0} };
468
468
          gint i;
469
469
 
470
470
          png_set_tRNS (png_ptr, png_info_ptr, (png_bytep) trans, 1, NULL);
482
482
           * unchanged, and finally from index transparent to index 0.
483
483
           */
484
484
 
485
 
          for (i = 0; i < colors; i++)
 
485
          for (i = 1; i < colors; i++)
486
486
            {
487
487
              palette[i].red = before[3 * remap[i]];
488
488
              palette[i].green = before[3 * remap[i] + 1];
505
505
  return FALSE;
506
506
}
507
507
 
 
508
static mng_retcode
 
509
mng_putchunk_plte_wrapper (mng_handle    handle,
 
510
                           gint          numcolors,
 
511
                           const guchar *colormap)
 
512
{
 
513
  mng_palette8 palette;
 
514
 
 
515
  memset (palette, 0, sizeof palette);
 
516
  if (0 < numcolors)
 
517
    memcpy (palette, colormap, numcolors * sizeof palette[0]);
 
518
 
 
519
  return mng_putchunk_plte (handle, numcolors, palette);
 
520
}
 
521
 
 
522
static mng_retcode
 
523
mng_putchunk_trns_wrapper (mng_handle    handle,
 
524
                           gint          n_alphas,
 
525
                           const guchar *buffer)
 
526
{
 
527
  const mng_bool mng_global = TRUE;
 
528
  const mng_bool mng_empty  = TRUE;
 
529
  mng_uint8arr   alphas;
 
530
 
 
531
  memset (alphas, 0, sizeof alphas);
 
532
  if (buffer && 0 < n_alphas)
 
533
    memcpy (alphas, buffer, n_alphas * sizeof alphas[0]);
 
534
 
 
535
  return mng_putchunk_trns (handle,
 
536
                            ! mng_empty,
 
537
                            ! mng_global,
 
538
                            MNG_COLORTYPE_INDEXED,
 
539
                            n_alphas,
 
540
                            alphas,
 
541
                            0, 0, 0, 0, 0, alphas);
 
542
}
508
543
 
509
544
static gboolean
510
545
mng_save_image (const gchar  *filename,
638
673
 
639
674
  if (mng_putchunk_text (handle,
640
675
                         strlen (MNG_TEXT_TITLE), MNG_TEXT_TITLE,
641
 
                         22, "Created using GIMP") != MNG_NOERROR)
 
676
                         18, "Created using GIMP") != MNG_NOERROR)
642
677
    {
643
678
      g_warning ("Unable to mng_putchunk_text() in mng_save_image()");
644
679
      goto err3;
732
767
      palette = gimp_image_get_colormap (image_id, &numcolors);
733
768
 
734
769
      if ((numcolors != 0) &&
735
 
          (mng_putchunk_plte (handle, numcolors,
736
 
                              (mng_palette8e *) palette) != MNG_NOERROR))
 
770
          (mng_putchunk_plte_wrapper (handle, numcolors,
 
771
                                      palette) != MNG_NOERROR))
737
772
        {
738
773
          g_warning ("Unable to mng_putchunk_plte() in mng_save_image()");
739
774
          goto err3;
1169
1204
              /* If this frame's palette is the same as the global palette,
1170
1205
               * write a 0-color palette chunk.
1171
1206
               */
1172
 
              if (mng_putchunk_plte (handle,
1173
 
                                     (layer_has_unique_palette ?
1174
 
                                      (chunksize / 3) : 0),
1175
 
                                     (mng_palette8e *) chunkbuffer) !=
1176
 
                  MNG_NOERROR)
 
1207
              if (mng_putchunk_plte_wrapper (handle,
 
1208
                                             (layer_has_unique_palette ?
 
1209
                                              (chunksize / 3) : 0),
 
1210
                                             chunkbuffer) != MNG_NOERROR)
1177
1211
                {
1178
1212
                  g_warning ("Unable to mng_putchunk_plte() "
1179
1213
                             "in mng_save_image()");
1182
1216
            }
1183
1217
          else if (strncmp (chunkname, "tRNS", 4) == 0)
1184
1218
            {
1185
 
              if (mng_putchunk_trns (handle, 0, 0, 3, chunksize,
1186
 
                                     (mng_uint8 *) chunkbuffer,
1187
 
                                     0, 0, 0, 0, 0,
1188
 
                                     (mng_uint8 *) chunkbuffer) != MNG_NOERROR)
 
1219
              if (mng_putchunk_trns_wrapper (handle,
 
1220
                                             chunksize,
 
1221
                                             chunkbuffer) != MNG_NOERROR)
1189
1222
                {
1190
1223
                  g_warning ("Unable to mng_putchunk_trns() "
1191
1224
                             "in mng_save_image()");