mirror of https://github.com/GNOME/gimp.git
parent
77ddb24fa4
commit
29e9112114
|
@ -1,3 +1,7 @@
|
|||
Tue Mar 17 01:38:18 PST 1998 Manish Singh <yosh@gimp.org>
|
||||
|
||||
* updated gif, animationplay, animoptimize, and bmp plugins
|
||||
|
||||
Mon Mar 16 21:52:46 CST 1998 Larry Ewing <lewing@gimp.org>
|
||||
|
||||
* app/convert.c (indexed_ok_callback): added gimage_ID to the
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Animation Playback plug-in version 0.84.0
|
||||
* Animation Playback plug-in version 0.85.0
|
||||
*
|
||||
* by Adam D. Moss, 1997-98
|
||||
* adam@gimp.org
|
||||
|
@ -11,6 +11,9 @@
|
|||
/*
|
||||
* REVISION HISTORY:
|
||||
*
|
||||
* 98.03.16 : version 0.85.0
|
||||
* Implemented some more rare opaque/alpha combinations.
|
||||
*
|
||||
* 98.03.15 : version 0.84.0
|
||||
* Tried to clear up the GTK object/cast warnings. Only
|
||||
* partially successful. Could use some help.
|
||||
|
@ -619,6 +622,24 @@ render_frame(gint32 whichframe)
|
|||
else
|
||||
{
|
||||
/* noalpha */
|
||||
|
||||
srcptr = rawframe;
|
||||
|
||||
for (j=rawy; j<rawheight+rawy; j++)
|
||||
{
|
||||
for (i=rawx; i<rawwidth+rawx; i++)
|
||||
{
|
||||
if ((i>=0 && i<width) &&
|
||||
(j>=0 && j<height))
|
||||
{
|
||||
preview_data[(j*width+i)*3 ] = *(srcptr);
|
||||
preview_data[(j*width+i)*3 +1] = *(srcptr+1);
|
||||
preview_data[(j*width+i)*3 +2] = *(srcptr+2);
|
||||
}
|
||||
|
||||
srcptr += 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Display the preview buffer... finally. */
|
||||
|
@ -736,6 +757,27 @@ render_frame(gint32 whichframe)
|
|||
else
|
||||
{
|
||||
/* noalpha */
|
||||
|
||||
srcptr = rawframe;
|
||||
|
||||
for (j=rawy; j<rawheight+rawy; j++)
|
||||
{
|
||||
for (i=rawx; i<rawwidth+rawx; i++)
|
||||
{
|
||||
if ((i>=0 && i<width) &&
|
||||
(j>=0 && j<height))
|
||||
{
|
||||
preview_data[(j*width+i)*3 ] =
|
||||
palette[3*(*(srcptr))];
|
||||
preview_data[(j*width+i)*3 +1] =
|
||||
palette[1+3*(*(srcptr))];
|
||||
preview_data[(j*width+i)*3 +2] =
|
||||
palette[2+3*(*(srcptr))];
|
||||
}
|
||||
|
||||
srcptr ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Display the preview buffer... finally. */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Animation Optimizer plug-in version 0.60.0
|
||||
* Animation Optimizer plug-in version 0.61.0
|
||||
*
|
||||
* by Adam D. Moss, 1997
|
||||
* by Adam D. Moss, 1997-98
|
||||
* adam@gimp.org
|
||||
* adam@foxbox.org
|
||||
*
|
||||
|
@ -11,6 +11,9 @@
|
|||
/*
|
||||
* REVISION HISTORY:
|
||||
*
|
||||
* 98.03.16 : version 0.61.0
|
||||
* Support more rare opaque/transparent combinations.
|
||||
*
|
||||
* 97.12.09 : version 0.60.0
|
||||
* Added support for INDEXED* and GRAY* images.
|
||||
*
|
||||
|
@ -594,9 +597,26 @@ do_optimizations(void)
|
|||
else
|
||||
{
|
||||
/* RGB no alpha, diff size */
|
||||
/* SHOULDN'T OCCUR - GIMP doesn't let you have
|
||||
* non-alpha layers, except for the bottom one
|
||||
*/
|
||||
|
||||
destptr = this_frame;
|
||||
srcptr = rawframe;
|
||||
|
||||
for (j=rawy; j<rawheight+rawy; j++)
|
||||
{
|
||||
for (i=rawx; i<rawwidth+rawx; i++)
|
||||
{
|
||||
if ((i>=0 && i<width) &&
|
||||
(j>=0 && j<height))
|
||||
{
|
||||
this_frame[(j*width+i)*4 ] = *(srcptr);
|
||||
this_frame[(j*width+i)*4 +1] = *(srcptr+1);
|
||||
this_frame[(j*width+i)*4 +2] = *(srcptr+2);
|
||||
this_frame[(j*width+i)*4 +3] = 255;
|
||||
}
|
||||
|
||||
srcptr += 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break; /* case RGB */
|
||||
|
@ -682,9 +702,25 @@ do_optimizations(void)
|
|||
else
|
||||
{
|
||||
/* I, no alpha, diff size */
|
||||
/* SHOULDN'T OCCUR - GIMP doesn't let you have
|
||||
* non-alpha layers, except for the bottom one
|
||||
*/
|
||||
|
||||
srcptr = rawframe;
|
||||
|
||||
for (j=rawy; j<rawheight+rawy; j++)
|
||||
{
|
||||
for (i=rawx; i<rawwidth+rawx; i++)
|
||||
{
|
||||
if ((i>=0 && i<width) &&
|
||||
(j>=0 && j<height))
|
||||
{
|
||||
this_frame[(j*width+i)*pixelstep]
|
||||
= *srcptr;
|
||||
this_frame[(j*width+i)*pixelstep
|
||||
+ pixelstep - 1] = 255;
|
||||
}
|
||||
|
||||
srcptr ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break; /* case INDEXED/GRAY */
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* bmp.c */
|
||||
/* bmp.c */
|
||||
/* Version 0.4 */
|
||||
/* This is a File input and output filter for */
|
||||
/* Gimp. It loads and saves images in windows(TM) */
|
||||
/* bitmap format. */
|
||||
|
@ -9,6 +10,30 @@
|
|||
/* */
|
||||
/* Alexander.Schulz@stud.uni-karlsruhe.de */
|
||||
|
||||
/* Changes: 28.11.1997 Noninteractive operation */
|
||||
/* 16.03.1998 Endian-independent!! */
|
||||
|
||||
/*
|
||||
* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include <libgimp/gimp.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
@ -39,7 +64,7 @@ GPlugInInfo PLUG_IN_INFO =
|
|||
run, /* run_proc */
|
||||
};
|
||||
|
||||
MAIN ()
|
||||
MAIN ();
|
||||
|
||||
static void
|
||||
query ()
|
||||
|
@ -116,6 +141,23 @@ run (char *name,
|
|||
|
||||
if (strcmp (name, "file_bmp_load") == 0)
|
||||
{
|
||||
switch (run_mode)
|
||||
{
|
||||
case RUN_INTERACTIVE:
|
||||
interactive_bmp = TRUE;
|
||||
break;
|
||||
|
||||
case RUN_NONINTERACTIVE:
|
||||
/* Make sure all the arguments are there! */
|
||||
interactive_bmp = FALSE;
|
||||
if (nparams != 3)
|
||||
status = STATUS_CALLING_ERROR;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
image_ID = ReadBMP(param[1].data.d_string);
|
||||
|
||||
if (image_ID != -1)
|
||||
|
@ -163,3 +205,26 @@ run (char *name,
|
|||
}
|
||||
}
|
||||
|
||||
gint32 ToL(guchar *puffer)
|
||||
{
|
||||
return(puffer[0] | puffer[1]<<8 | puffer[2]<<16 | puffer[3]<<24);
|
||||
}
|
||||
|
||||
gint16 ToS(guchar *puffer)
|
||||
{
|
||||
return(puffer[0] | puffer[1]<<8);
|
||||
}
|
||||
|
||||
void FromL(gint32 wert, guchar *bopuffer)
|
||||
{
|
||||
bopuffer[0]=(wert & 0x000000ff)>>0x00;
|
||||
bopuffer[1]=(wert & 0x0000ff00)>>0x08;
|
||||
bopuffer[2]=(wert & 0x00ff0000)>>0x10;
|
||||
bopuffer[3]=(wert & 0xff000000)>>0x18;
|
||||
}
|
||||
|
||||
void FromS(gint16 wert, guchar *bopuffer)
|
||||
{
|
||||
bopuffer[0]=(wert & 0x00ff)>>0x00;
|
||||
bopuffer[1]=(wert & 0xff00)>>0x08;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,10 @@
|
|||
#define ReadOK(file,buffer,len) (fread(buffer, len, 1, file) != 0)
|
||||
#define WriteOK(file,buffer,len) (fwrite(buffer, len, 1, file) != 0)
|
||||
|
||||
extern gint32 ToL(guchar *);
|
||||
extern void FromL(gint32, guchar *);
|
||||
extern gint16 ToS(guchar *);
|
||||
extern void FromS(gint16, guchar *);
|
||||
extern gint32 ReadBMP (char *);
|
||||
extern gint WriteBMP (char *,gint32,gint32);
|
||||
extern gint ReadColorMap(FILE *, unsigned char[256][3], int, int, int *);
|
||||
|
@ -34,7 +38,8 @@ static struct
|
|||
{
|
||||
unsigned long biWidth; /* 12 */
|
||||
unsigned long biHeight; /* 16 */
|
||||
unsigned long biPlanes_biBitCnt; /* 1A */
|
||||
unsigned short biPlanes; /* 1A */
|
||||
unsigned short biBitCnt; /* 1C */
|
||||
unsigned long biCompr; /* 1E */
|
||||
unsigned long biSizeIm; /* 22 */
|
||||
unsigned long biXPels; /* 26 */
|
||||
|
@ -46,11 +51,8 @@ static struct
|
|||
|
||||
static struct
|
||||
{
|
||||
unsigned long bcWidth_bcHeight; /* 12 */
|
||||
unsigned long bcPlanes_bcBitCnt; /* 1A */
|
||||
unsigned short bcWidth; /* 12 */
|
||||
unsigned short bcHeight; /* 14 */
|
||||
unsigned short bcPlanes; /* 16 */
|
||||
unsigned short bcBitCnt; /* 18 */
|
||||
}Bitmap_OS2_Head;
|
||||
|
||||
#define biBitCnt ((Bitmap_Head.biPlanes_biBitCnt & 0xffff0000) >> 16)
|
||||
#define bcBitCnt ((Bitmap_OS2_Head.biPlanes_biBitCnt & 0xffff0000) >> 16)
|
||||
#define bcHeight ((Bitmap_OS2_Head.bcWidth_bcHeight & 0xffff0000) >> 16)
|
||||
#define bcWidth (Bitmap_OS2_Head.bcWidth_bcHeight & 0x0000ffff)
|
||||
|
|
|
@ -17,11 +17,15 @@ gint32 ReadBMP (name)
|
|||
char buf[5];
|
||||
int ColormapSize, SpeicherZeile, Maps, Grey;
|
||||
unsigned char ColorMap[256][3];
|
||||
guchar puffer[50];
|
||||
|
||||
temp_buf = g_malloc (strlen (name) + 11);
|
||||
sprintf (temp_buf, "Loading %s:", name);
|
||||
gimp_progress_init (temp_buf);
|
||||
g_free (temp_buf);
|
||||
if (interactive_bmp)
|
||||
{
|
||||
temp_buf = g_malloc (strlen (name) + 11);
|
||||
sprintf (temp_buf, "Loading %s:", name);
|
||||
gimp_progress_init (temp_buf);
|
||||
g_free (temp_buf);
|
||||
}
|
||||
|
||||
filename = name;
|
||||
fd = fopen (filename, "rb");
|
||||
|
@ -44,59 +48,84 @@ gint32 ReadBMP (name)
|
|||
|
||||
/* How long is the Header? */
|
||||
|
||||
if (!ReadOK (fd, &Bitmap_File_Head, 0x10))
|
||||
if (!ReadOK (fd, puffer, 0x10))
|
||||
{
|
||||
printf ("%s: error reading bitmap file header\n", prog_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* bring them to the rigth byreorder. Not too nice, but it should work */
|
||||
|
||||
Bitmap_File_Head.bfSize=ToL(&puffer[0]);
|
||||
Bitmap_File_Head.reserverd=ToL(&puffer[4]);
|
||||
Bitmap_File_Head.bfOffs=ToL(&puffer[8]);
|
||||
Bitmap_File_Head.biSize=ToL(&puffer[12]);
|
||||
|
||||
/* Is it a Windows (R) Bitmap or not */
|
||||
|
||||
if (Bitmap_File_Head.biSize!=40)
|
||||
{
|
||||
printf("\nos2 unsupported!\n");
|
||||
if (!ReadOK (fd, &Bitmap_OS2_Head, Bitmap_File_Head.biSize))
|
||||
if (!ReadOK (fd, puffer, Bitmap_File_Head.biSize))
|
||||
{
|
||||
printf ("%s: error reading bitmap header\n", prog_name);
|
||||
return -1;
|
||||
}
|
||||
Bitmap_Head.biPlanes_biBitCnt=Bitmap_OS2_Head.bcPlanes_bcBitCnt;
|
||||
|
||||
Bitmap_OS2_Head.bcWidth=ToS(&puffer[0]);
|
||||
Bitmap_OS2_Head.bcHeight=ToS(&puffer[2]);
|
||||
Bitmap_OS2_Head.bcPlanes=ToS(&puffer[4]);
|
||||
Bitmap_OS2_Head.bcBitCnt=ToS(&puffer[6]);
|
||||
|
||||
Bitmap_Head.biPlanes=Bitmap_OS2_Head.bcPlanes;
|
||||
Bitmap_Head.biBitCnt=Bitmap_OS2_Head.bcBitCnt;
|
||||
Bitmap_File_Head.bfSize=(Bitmap_File_Head.bfSize*4)-(Bitmap_File_Head.bfOffs*3);
|
||||
Bitmap_Head.biHeight=bcHeight;
|
||||
Bitmap_Head.biWidth=bcWidth;
|
||||
Bitmap_Head.biHeight=Bitmap_OS2_Head.bcHeight;
|
||||
Bitmap_Head.biWidth=Bitmap_OS2_Head.bcWidth;
|
||||
Bitmap_Head.biClrUsed=0;
|
||||
Bitmap_Head.biCompr=0;
|
||||
Maps=3;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!ReadOK (fd, &Bitmap_Head, 36))
|
||||
if (!ReadOK (fd, puffer, 36))
|
||||
{
|
||||
printf ("\n%s: error reading bitmap header\n", prog_name);
|
||||
return -1;
|
||||
}
|
||||
Bitmap_Head.biWidth=ToL(&puffer[0x00]); /* 12 */
|
||||
Bitmap_Head.biHeight=ToL(&puffer[0x04]); /* 16 */
|
||||
Bitmap_Head.biPlanes=ToS(&puffer[0x08]); /* 1A */
|
||||
Bitmap_Head.biBitCnt=ToS(&puffer[0x0A]); /* 1C */
|
||||
Bitmap_Head.biCompr=ToL(&puffer[0x0C]); /* 1E */
|
||||
Bitmap_Head.biSizeIm=ToL(&puffer[0x10]); /* 22 */
|
||||
Bitmap_Head.biXPels=ToL(&puffer[0x14]); /* 26 */
|
||||
Bitmap_Head.biYPels=ToL(&puffer[0x18]); /* 2A */
|
||||
Bitmap_Head.biClrUsed=ToL(&puffer[0x1C]); /* 2E */
|
||||
Bitmap_Head.biClrImp=ToL(&puffer[0x20]); /* 32 */
|
||||
/* 36 */
|
||||
Maps=4;
|
||||
}
|
||||
|
||||
/* This means wrong file Format. I test this because it could crash the */
|
||||
/* entire gimp. */
|
||||
|
||||
if (biBitCnt>24)
|
||||
if (Bitmap_Head.biBitCnt>24)
|
||||
{
|
||||
printf("\n%s: to many colors: %u\n",prog_name,(unsigned int) biBitCnt);
|
||||
printf("\n%s: to many colors: %u\n",prog_name,(unsigned int) Bitmap_Head.biBitCnt);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* There should be some colors used! */
|
||||
|
||||
ColormapSize = (Bitmap_File_Head.bfOffs-Bitmap_File_Head.biSize-14) / Maps;
|
||||
if ((Bitmap_Head.biClrUsed==0) && (biBitCnt<24)) Bitmap_Head.biClrUsed=ColormapSize;
|
||||
if (biBitCnt==24) SpeicherZeile=((Bitmap_File_Head.bfSize-Bitmap_File_Head.bfOffs)/Bitmap_Head.biHeight);
|
||||
else SpeicherZeile=((Bitmap_File_Head.bfSize-Bitmap_File_Head.bfOffs)/Bitmap_Head.biHeight)*(8/biBitCnt);
|
||||
if ((Bitmap_Head.biClrUsed==0) && (Bitmap_Head.biBitCnt<24)) Bitmap_Head.biClrUsed=ColormapSize;
|
||||
if (Bitmap_Head.biBitCnt==24) SpeicherZeile=((Bitmap_File_Head.bfSize-Bitmap_File_Head.bfOffs)/Bitmap_Head.biHeight);
|
||||
else SpeicherZeile=((Bitmap_File_Head.bfSize-Bitmap_File_Head.bfOffs)/Bitmap_Head.biHeight)*(8/Bitmap_Head.biBitCnt);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("\nSize: %u, Colors: %u, Bits: %u, Width: %u, Height: %u, Comp: %u, Zeile: %u\n",
|
||||
Bitmap_File_Head.bfSize,Bitmap_Head.biClrUsed,biBitCnt,Bitmap_Head.biWidth,
|
||||
Bitmap_File_Head.bfSize,Bitmap_Head.biClrUsed,Bitmap_Head.biBitCnt,Bitmap_Head.biWidth,
|
||||
Bitmap_Head.biHeight, Bitmap_Head.biCompr, SpeicherZeile);
|
||||
#endif
|
||||
|
||||
|
@ -111,7 +140,7 @@ gint32 ReadBMP (name)
|
|||
/* Get the Image and return the ID or -1 on error*/
|
||||
|
||||
return(ReadImage(fd, Bitmap_Head.biWidth, Bitmap_Head.biHeight, ColorMap,
|
||||
Bitmap_Head.biClrUsed, biBitCnt, Bitmap_Head.biCompr, SpeicherZeile, Grey));
|
||||
Bitmap_Head.biClrUsed, Bitmap_Head.biBitCnt, Bitmap_Head.biCompr, SpeicherZeile, Grey));
|
||||
|
||||
}
|
||||
|
||||
|
@ -174,25 +203,25 @@ Image ReadImage (fd, len, height, cmap, ncols, bpp, compression, spzeile, grey)
|
|||
|
||||
if (grey)
|
||||
{
|
||||
image = gimp_image_new (len, height, GRAY);
|
||||
layer = gimp_layer_new (image, "Background", len, height, GRAY_IMAGE, 100, NORMAL_MODE);
|
||||
channels = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bpp<24)
|
||||
{
|
||||
image = gimp_image_new (len, height, INDEXED);
|
||||
layer = gimp_layer_new (image, "Background", len, height, INDEXED_IMAGE, 100, NORMAL_MODE);
|
||||
channels = 1;
|
||||
image = gimp_image_new (len, height, GRAY);
|
||||
layer = gimp_layer_new (image, "Background", len, height, GRAY_IMAGE, 100, NORMAL_MODE);
|
||||
channels = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
image = gimp_image_new (len, height, RGB);
|
||||
layer = gimp_layer_new (image, "Background", len, height, RGB_IMAGE, 100, NORMAL_MODE);
|
||||
channels = 3;
|
||||
if (bpp<24)
|
||||
{
|
||||
image = gimp_image_new (len, height, INDEXED);
|
||||
layer = gimp_layer_new (image, "Background", len, height, INDEXED_IMAGE, 100, NORMAL_MODE);
|
||||
channels = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
image = gimp_image_new (len, height, RGB);
|
||||
layer = gimp_layer_new (image, "Background", len, height, RGB_IMAGE, 100, NORMAL_MODE);
|
||||
channels = 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
name_buf = g_malloc (strlen (filename) + 10);
|
||||
sprintf (name_buf, "%s", filename);
|
||||
|
@ -201,7 +230,7 @@ Image ReadImage (fd, len, height, cmap, ncols, bpp, compression, spzeile, grey)
|
|||
|
||||
gimp_image_add_layer(image,layer,0);
|
||||
drawable = gimp_drawable_get(layer);
|
||||
|
||||
|
||||
dest = g_malloc(drawable->width*drawable->height*channels);
|
||||
rowstride = drawable->width * channels;
|
||||
|
||||
|
@ -226,18 +255,18 @@ Image ReadImage (fd, len, height, cmap, ncols, bpp, compression, spzeile, grey)
|
|||
ypos--;
|
||||
xpos=0;
|
||||
cur_progress++;
|
||||
if ((cur_progress % 5) == 0)
|
||||
if ((interactive_bmp) &&((cur_progress % 5) == 0))
|
||||
gimp_progress_update ((double) cur_progress / (double) max_progress);
|
||||
}
|
||||
if (ypos < 0) break;
|
||||
}
|
||||
if (ypos < 0) break;
|
||||
}
|
||||
}
|
||||
else { switch(compression)
|
||||
{
|
||||
case 0: /* uncompressed */
|
||||
{
|
||||
while (ReadOK(fd,&v,1))
|
||||
{
|
||||
while (ReadOK(fd,&v,1))
|
||||
{
|
||||
for (i=1;(i<=(8/bpp)) && (xpos<len);i++,xpos++)
|
||||
{
|
||||
temp = dest + (ypos * rowstride) + (xpos * channels);
|
||||
|
@ -250,77 +279,77 @@ Image ReadImage (fd, len, height, cmap, ncols, bpp, compression, spzeile, grey)
|
|||
ypos--;
|
||||
xpos=0;
|
||||
cur_progress++;
|
||||
if ((cur_progress % 5) == 0)
|
||||
if ((interactive_bmp) && ((cur_progress % 5) == 0))
|
||||
gimp_progress_update ((double) cur_progress / (double) max_progress);
|
||||
}
|
||||
if (ypos < 0) break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: /* Compressed images */
|
||||
{
|
||||
while (TRUE)
|
||||
{
|
||||
/*temp = dest + (ypos * rowstride) + (xpos * channels);*/
|
||||
egal=ReadOK(fd,buf,2);
|
||||
if ((unsigned char) buf[0]!=0)
|
||||
/* Count + Color - record */
|
||||
{
|
||||
for (j=0;((unsigned char) j < (unsigned char) buf[0]) && (xpos<len);)
|
||||
{
|
||||
#ifdef DEBUG2
|
||||
printf("%u %u | ",xpos,len);
|
||||
#endif
|
||||
for (i=1;((i<=(8/bpp)) && (xpos<len) && ((unsigned char) j < (unsigned char) buf[0]));i++,xpos++,j++)
|
||||
{
|
||||
temp = dest + (ypos * rowstride) + (xpos * channels);
|
||||
*temp=( buf[1] & ( ((1<<bpp)-1) << (8-(i*bpp)) ) ) >> (8-(i*bpp));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (((unsigned char) buf[0]==0) && ((unsigned char) buf[1]>2))
|
||||
/* unkomprimierter record */
|
||||
{
|
||||
wieviel=buf[1];
|
||||
for (j=0;j<wieviel;j+=(8/bpp))
|
||||
{
|
||||
egal=ReadOK(fd,&v,1);
|
||||
i=1;
|
||||
while ((i<=(8/bpp)) && (xpos<len))
|
||||
{
|
||||
temp = dest + (ypos * rowstride) + (xpos * channels);
|
||||
*temp=(v & ( ((1<<bpp)-1) << (8-(i*bpp)) ) ) >> (8-(i*bpp));
|
||||
i++;
|
||||
xpos++;
|
||||
}
|
||||
}
|
||||
if ( (wieviel / (8/bpp)) % 2) egal=ReadOK(fd,&v,1);
|
||||
/*if odd(x div (8 div bpp )) then blockread(f,z^,1);*/
|
||||
}
|
||||
if (((unsigned char) buf[0]==0) && ((unsigned char) buf[1]==0))
|
||||
/* Zeilenende */
|
||||
{
|
||||
ypos--;
|
||||
xpos=0;
|
||||
cur_progress++;
|
||||
if ((cur_progress % 5) == 0)
|
||||
gimp_progress_update ((double) cur_progress / (double) max_progress);
|
||||
}
|
||||
if (((unsigned char) buf[0]==0) && ((unsigned char) buf[1]==1))
|
||||
/* Bitmapende */
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (((unsigned char) buf[0]==0) && ((unsigned char) buf[1]==2))
|
||||
/* Deltarecord */
|
||||
{
|
||||
xpos+=(unsigned char) buf[2];
|
||||
ypos+=(unsigned char) buf[3];
|
||||
}
|
||||
}
|
||||
break;
|
||||
if (ypos < 0) break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}}
|
||||
default: /* Compressed images */
|
||||
{
|
||||
while (TRUE)
|
||||
{
|
||||
egal=ReadOK(fd,buf,2);
|
||||
if ((unsigned char) buf[0]!=0)
|
||||
/* Count + Color - record */
|
||||
{
|
||||
for (j=0;((unsigned char) j < (unsigned char) buf[0]) && (xpos<len);)
|
||||
{
|
||||
#ifdef DEBUG2
|
||||
printf("%u %u | ",xpos,len);
|
||||
#endif
|
||||
for (i=1;((i<=(8/bpp)) && (xpos<len) && ((unsigned char) j < (unsigned char) buf[0]));i++,xpos++,j++)
|
||||
{
|
||||
temp = dest + (ypos * rowstride) + (xpos * channels);
|
||||
*temp=( buf[1] & ( ((1<<bpp)-1) << (8-(i*bpp)) ) ) >> (8-(i*bpp));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (((unsigned char) buf[0]==0) && ((unsigned char) buf[1]>2))
|
||||
/* uncompressed record */
|
||||
{
|
||||
wieviel=buf[1];
|
||||
for (j=0;j<wieviel;j+=(8/bpp))
|
||||
{
|
||||
egal=ReadOK(fd,&v,1);
|
||||
i=1;
|
||||
while ((i<=(8/bpp)) && (xpos<len))
|
||||
{
|
||||
temp = dest + (ypos * rowstride) + (xpos * channels);
|
||||
*temp=(v & ( ((1<<bpp)-1) << (8-(i*bpp)) ) ) >> (8-(i*bpp));
|
||||
i++;
|
||||
xpos++;
|
||||
}
|
||||
}
|
||||
if ( (wieviel / (8/bpp)) % 2) egal=ReadOK(fd,&v,1);
|
||||
/*if odd(x div (8 div bpp )) then blockread(f,z^,1);*/
|
||||
}
|
||||
if (((unsigned char) buf[0]==0) && ((unsigned char) buf[1]==0))
|
||||
/* Zeilenende */
|
||||
{
|
||||
ypos--;
|
||||
xpos=0;
|
||||
cur_progress++;
|
||||
if ((interactive_bmp) && ((cur_progress % 5) == 0))
|
||||
gimp_progress_update ((double) cur_progress / (double) max_progress);
|
||||
}
|
||||
if (((unsigned char) buf[0]==0) && ((unsigned char) buf[1]==1))
|
||||
/* Bitmapende */
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (((unsigned char) buf[0]==0) && ((unsigned char) buf[1]==2))
|
||||
/* Deltarecord */
|
||||
{
|
||||
xpos+=(unsigned char) buf[2];
|
||||
ypos+=(unsigned char) buf[3];
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fd);
|
||||
if (bpp<24) for (i = 0, j = 0; i < ncols; i++)
|
||||
|
@ -329,8 +358,8 @@ Image ReadImage (fd, len, height, cmap, ncols, bpp, compression, spzeile, grey)
|
|||
gimp_cmap[j++] = cmap[i][1];
|
||||
gimp_cmap[j++] = cmap[i][2];
|
||||
}
|
||||
|
||||
gimp_progress_update (1);
|
||||
|
||||
if (interactive_bmp) gimp_progress_update (1);
|
||||
gimp_pixel_rgn_init(&pixel_rgn, drawable, 0, 0, drawable->width, drawable->height, TRUE, FALSE);
|
||||
gimp_pixel_rgn_set_rect(&pixel_rgn, dest, 0, 0, drawable->width, drawable->height);
|
||||
if (bpp<24) gimp_image_set_cmap(image, gimp_cmap, ncols);
|
||||
|
@ -338,5 +367,5 @@ Image ReadImage (fd, len, height, cmap, ncols, bpp, compression, spzeile, grey)
|
|||
gimp_drawable_detach(drawable);
|
||||
g_free(dest);
|
||||
return(image);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -37,16 +37,6 @@ static void save_ok_callback (GtkWidget *widget,
|
|||
static void save_toggle_update (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
/*
|
||||
static void item_callback (int, void *, void *);
|
||||
static void ok_callback (int, void *, void *);
|
||||
static void cancel_callback (int, void *, void *);
|
||||
|
||||
static int dialog_ID;
|
||||
static int group_ID;
|
||||
static int encoded_ID;
|
||||
*/
|
||||
|
||||
gint
|
||||
WriteBMP (filename,image,drawable_ID)
|
||||
char *filename;
|
||||
|
@ -64,6 +54,7 @@ WriteBMP (filename,image,drawable_ID)
|
|||
GPixelRgn pixel_rgn;
|
||||
GDrawable *drawable;
|
||||
GDrawableType drawable_type;
|
||||
guchar puffer[50];
|
||||
int i;
|
||||
|
||||
/* first: can we save this image? */
|
||||
|
@ -146,10 +137,13 @@ WriteBMP (filename,image,drawable_ID)
|
|||
|
||||
/* And let's begin the progress */
|
||||
|
||||
temp_buf = g_malloc (strlen (filename) + 11);
|
||||
sprintf (temp_buf, "Saving %s:", filename);
|
||||
gimp_progress_init (temp_buf);
|
||||
g_free (temp_buf);
|
||||
if (interactive_bmp)
|
||||
{
|
||||
temp_buf = g_malloc (strlen (filename) + 11);
|
||||
sprintf (temp_buf, "Saving %s:", filename);
|
||||
gimp_progress_init (temp_buf);
|
||||
g_free (temp_buf);
|
||||
}
|
||||
cur_progress = 0;
|
||||
max_progress = drawable->height;
|
||||
|
||||
|
@ -168,7 +162,8 @@ WriteBMP (filename,image,drawable_ID)
|
|||
Bitmap_File_Head.biSize=40;
|
||||
Bitmap_Head.biWidth=cols;
|
||||
Bitmap_Head.biHeight=rows;
|
||||
Bitmap_Head.biPlanes_biBitCnt=(BitsPerPixel << 16) + 1;
|
||||
Bitmap_Head.biPlanes=1;
|
||||
Bitmap_Head.biBitCnt=BitsPerPixel;
|
||||
if (encoded==0) Bitmap_Head.biCompr=0;
|
||||
else if (BitsPerPixel==8) Bitmap_Head.biCompr=1;
|
||||
else if (BitsPerPixel==4) Bitmap_Head.biCompr=2;
|
||||
|
@ -182,15 +177,33 @@ WriteBMP (filename,image,drawable_ID)
|
|||
|
||||
#ifdef DEBUG
|
||||
printf("\nSize: %u, Colors: %u, Bits: %u, Width: %u, Height: %u, Comp: %u, Zeile: %u\n",
|
||||
Bitmap_File_Head.bfSize,Bitmap_Head.biClrUsed,biBitCnt,Bitmap_Head.biWidth,
|
||||
Bitmap_File_Head.bfSize,Bitmap_Head.biClrUsed,Bitmap_Head.biBitCnt,Bitmap_Head.biWidth,
|
||||
Bitmap_Head.biHeight, Bitmap_Head.biCompr,SpZeile);
|
||||
#endif
|
||||
|
||||
/* And now write the header and the colormap (if any) to disk */
|
||||
|
||||
WriteOK(outfile,"BM",2);
|
||||
WriteOK(outfile,&Bitmap_File_Head,16);
|
||||
WriteOK(outfile,&Bitmap_Head,36);
|
||||
|
||||
FromL(Bitmap_File_Head.bfSize,&puffer[0x00]);
|
||||
FromL(Bitmap_File_Head.reserverd,&puffer[0x04]);
|
||||
FromL(Bitmap_File_Head.bfOffs,&puffer[0x08]);
|
||||
FromL(Bitmap_File_Head.biSize,&puffer[0x0C]);
|
||||
|
||||
WriteOK(outfile,puffer,16);
|
||||
|
||||
FromL(Bitmap_Head.biWidth,&puffer[0x00]);
|
||||
FromL(Bitmap_Head.biHeight,&puffer[0x04]);
|
||||
FromS(Bitmap_Head.biPlanes,&puffer[0x08]);
|
||||
FromS(Bitmap_Head.biBitCnt,&puffer[0x0A]);
|
||||
FromL(Bitmap_Head.biCompr,&puffer[0x0C]);
|
||||
FromL(Bitmap_Head.biSizeIm,&puffer[0x10]);
|
||||
FromL(Bitmap_Head.biXPels,&puffer[0x14]);
|
||||
FromL(Bitmap_Head.biYPels,&puffer[0x18]);
|
||||
FromL(Bitmap_Head.biClrUsed,&puffer[0x1C]);
|
||||
FromL(Bitmap_Head.biClrImp,&puffer[0x20]);
|
||||
|
||||
WriteOK(outfile,puffer,36);
|
||||
WriteColorMap(outfile,Red,Green,Blue,MapSize);
|
||||
|
||||
/* After that is done, we write the image ... */
|
||||
|
@ -253,7 +266,7 @@ void WriteImage(f, src, width, height, encoded, channels, bpp, spzeile)
|
|||
}
|
||||
WriteOK(f,&buf[3],spzeile-(width*3));
|
||||
cur_progress++;
|
||||
if ((cur_progress % 5) == 0) gimp_progress_update ((double) cur_progress / (double) max_progress);
|
||||
if ((interactive_bmp) && ((cur_progress % 5) == 0)) gimp_progress_update ((double) cur_progress / (double) max_progress);
|
||||
xpos=0;
|
||||
}
|
||||
} else {
|
||||
|
@ -276,7 +289,7 @@ void WriteImage(f, src, width, height, encoded, channels, bpp, spzeile)
|
|||
WriteOK(f,&buf[3],spzeile-(width/(8/bpp)));
|
||||
xpos=0;
|
||||
cur_progress++;
|
||||
if ((cur_progress % 5) == 0)
|
||||
if ((interactive_bmp) && ((cur_progress % 5) == 0))
|
||||
gimp_progress_update ((double) cur_progress / (double) max_progress);
|
||||
}
|
||||
break;
|
||||
|
@ -348,7 +361,7 @@ void WriteImage(f, src, width, height, encoded, channels, bpp, spzeile)
|
|||
WriteOK(f,&buf[14],2); /* End of row */
|
||||
laenge+=2;
|
||||
cur_progress++;
|
||||
if ((cur_progress % 5) == 0) gimp_progress_update ((double) cur_progress / (double) max_progress);
|
||||
if ((interactive_bmp) &&((cur_progress % 5) == 0)) gimp_progress_update ((double) cur_progress / (double) max_progress);
|
||||
}
|
||||
fseek(f,-2,SEEK_CUR); /* Overwrite last End of row */
|
||||
WriteOK(f,&buf[12],2); /* End of file */
|
||||
|
@ -360,7 +373,7 @@ void WriteImage(f, src, width, height, encoded, channels, bpp, spzeile)
|
|||
}
|
||||
}
|
||||
}
|
||||
gimp_progress_update(1);
|
||||
if (interactive_bmp) gimp_progress_update(1);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Animation Playback plug-in version 0.84.0
|
||||
* Animation Playback plug-in version 0.85.0
|
||||
*
|
||||
* by Adam D. Moss, 1997-98
|
||||
* adam@gimp.org
|
||||
|
@ -11,6 +11,9 @@
|
|||
/*
|
||||
* REVISION HISTORY:
|
||||
*
|
||||
* 98.03.16 : version 0.85.0
|
||||
* Implemented some more rare opaque/alpha combinations.
|
||||
*
|
||||
* 98.03.15 : version 0.84.0
|
||||
* Tried to clear up the GTK object/cast warnings. Only
|
||||
* partially successful. Could use some help.
|
||||
|
@ -619,6 +622,24 @@ render_frame(gint32 whichframe)
|
|||
else
|
||||
{
|
||||
/* noalpha */
|
||||
|
||||
srcptr = rawframe;
|
||||
|
||||
for (j=rawy; j<rawheight+rawy; j++)
|
||||
{
|
||||
for (i=rawx; i<rawwidth+rawx; i++)
|
||||
{
|
||||
if ((i>=0 && i<width) &&
|
||||
(j>=0 && j<height))
|
||||
{
|
||||
preview_data[(j*width+i)*3 ] = *(srcptr);
|
||||
preview_data[(j*width+i)*3 +1] = *(srcptr+1);
|
||||
preview_data[(j*width+i)*3 +2] = *(srcptr+2);
|
||||
}
|
||||
|
||||
srcptr += 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Display the preview buffer... finally. */
|
||||
|
@ -736,6 +757,27 @@ render_frame(gint32 whichframe)
|
|||
else
|
||||
{
|
||||
/* noalpha */
|
||||
|
||||
srcptr = rawframe;
|
||||
|
||||
for (j=rawy; j<rawheight+rawy; j++)
|
||||
{
|
||||
for (i=rawx; i<rawwidth+rawx; i++)
|
||||
{
|
||||
if ((i>=0 && i<width) &&
|
||||
(j>=0 && j<height))
|
||||
{
|
||||
preview_data[(j*width+i)*3 ] =
|
||||
palette[3*(*(srcptr))];
|
||||
preview_data[(j*width+i)*3 +1] =
|
||||
palette[1+3*(*(srcptr))];
|
||||
preview_data[(j*width+i)*3 +2] =
|
||||
palette[2+3*(*(srcptr))];
|
||||
}
|
||||
|
||||
srcptr ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Display the preview buffer... finally. */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Animation Optimizer plug-in version 0.60.0
|
||||
* Animation Optimizer plug-in version 0.61.0
|
||||
*
|
||||
* by Adam D. Moss, 1997
|
||||
* by Adam D. Moss, 1997-98
|
||||
* adam@gimp.org
|
||||
* adam@foxbox.org
|
||||
*
|
||||
|
@ -11,6 +11,9 @@
|
|||
/*
|
||||
* REVISION HISTORY:
|
||||
*
|
||||
* 98.03.16 : version 0.61.0
|
||||
* Support more rare opaque/transparent combinations.
|
||||
*
|
||||
* 97.12.09 : version 0.60.0
|
||||
* Added support for INDEXED* and GRAY* images.
|
||||
*
|
||||
|
@ -594,9 +597,26 @@ do_optimizations(void)
|
|||
else
|
||||
{
|
||||
/* RGB no alpha, diff size */
|
||||
/* SHOULDN'T OCCUR - GIMP doesn't let you have
|
||||
* non-alpha layers, except for the bottom one
|
||||
*/
|
||||
|
||||
destptr = this_frame;
|
||||
srcptr = rawframe;
|
||||
|
||||
for (j=rawy; j<rawheight+rawy; j++)
|
||||
{
|
||||
for (i=rawx; i<rawwidth+rawx; i++)
|
||||
{
|
||||
if ((i>=0 && i<width) &&
|
||||
(j>=0 && j<height))
|
||||
{
|
||||
this_frame[(j*width+i)*4 ] = *(srcptr);
|
||||
this_frame[(j*width+i)*4 +1] = *(srcptr+1);
|
||||
this_frame[(j*width+i)*4 +2] = *(srcptr+2);
|
||||
this_frame[(j*width+i)*4 +3] = 255;
|
||||
}
|
||||
|
||||
srcptr += 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break; /* case RGB */
|
||||
|
@ -682,9 +702,25 @@ do_optimizations(void)
|
|||
else
|
||||
{
|
||||
/* I, no alpha, diff size */
|
||||
/* SHOULDN'T OCCUR - GIMP doesn't let you have
|
||||
* non-alpha layers, except for the bottom one
|
||||
*/
|
||||
|
||||
srcptr = rawframe;
|
||||
|
||||
for (j=rawy; j<rawheight+rawy; j++)
|
||||
{
|
||||
for (i=rawx; i<rawwidth+rawx; i++)
|
||||
{
|
||||
if ((i>=0 && i<width) &&
|
||||
(j>=0 && j<height))
|
||||
{
|
||||
this_frame[(j*width+i)*pixelstep]
|
||||
= *srcptr;
|
||||
this_frame[(j*width+i)*pixelstep
|
||||
+ pixelstep - 1] = 255;
|
||||
}
|
||||
|
||||
srcptr ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break; /* case INDEXED/GRAY */
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* Based around original GIF code by David Koblas.
|
||||
*
|
||||
*
|
||||
* Version 2.0.0 - 98/03/15
|
||||
* Version 2.0.1 - 98/03/16
|
||||
* Adam D. Moss - <adam@gimp.org> <adam@foxbox.org>
|
||||
*/
|
||||
/*
|
||||
|
@ -23,6 +23,10 @@
|
|||
/*
|
||||
* REVISION HISTORY
|
||||
*
|
||||
* 98/03/16
|
||||
* 2.00.01 - Fixed a long-standing bug when loading GIFs which layer
|
||||
* opaque frames onto transparent ones.
|
||||
*
|
||||
* 98/03/15
|
||||
* 2.00.00 - No longer beta. Uses the current GIMP brush background
|
||||
* colour as the transparent-index colour for viewers that
|
||||
|
@ -830,6 +834,8 @@ DoExtension (FILE *fd,
|
|||
Gif89.delayTime = LM_to_uint (buf[1], buf[2]);
|
||||
if ((buf[0] & 0x1) != 0)
|
||||
Gif89.transparent = buf[3];
|
||||
else
|
||||
Gif89.transparent = -1;
|
||||
|
||||
while (GetDataBlock (fd, (unsigned char *) buf) != 0)
|
||||
;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* Based around original GIF code by David Koblas.
|
||||
*
|
||||
*
|
||||
* Version 2.0.0 - 98/03/15
|
||||
* Version 2.0.1 - 98/03/16
|
||||
* Adam D. Moss - <adam@gimp.org> <adam@foxbox.org>
|
||||
*/
|
||||
/*
|
||||
|
@ -23,6 +23,10 @@
|
|||
/*
|
||||
* REVISION HISTORY
|
||||
*
|
||||
* 98/03/16
|
||||
* 2.00.01 - Fixed a long-standing bug when loading GIFs which layer
|
||||
* opaque frames onto transparent ones.
|
||||
*
|
||||
* 98/03/15
|
||||
* 2.00.00 - No longer beta. Uses the current GIMP brush background
|
||||
* colour as the transparent-index colour for viewers that
|
||||
|
@ -830,6 +834,8 @@ DoExtension (FILE *fd,
|
|||
Gif89.delayTime = LM_to_uint (buf[1], buf[2]);
|
||||
if ((buf[0] & 0x1) != 0)
|
||||
Gif89.transparent = buf[3];
|
||||
else
|
||||
Gif89.transparent = -1;
|
||||
|
||||
while (GetDataBlock (fd, (unsigned char *) buf) != 0)
|
||||
;
|
||||
|
|
Loading…
Reference in New Issue