mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 19:00:47 +00:00
avoid obsolete macros
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@32412 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
89b2b64d5e
commit
fed6ff1796
5 changed files with 115 additions and 107 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2011-02-28 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/NSBitmapImageRep.m:
|
||||||
|
* Source/NSBitmapImageRep+GIF.m:
|
||||||
|
* Source/NSBitmapImageRep+JPEG.m:
|
||||||
|
* Source/tiff.m:
|
||||||
|
Avoid obsolete OBJC_... macros
|
||||||
|
|
||||||
2011-02-28 Riccardo Mottola <rm@gnu.org>
|
2011-02-28 Riccardo Mottola <rm@gnu.org>
|
||||||
|
|
||||||
* Source/GSLayoutManager.m
|
* Source/GSLayoutManager.m
|
||||||
|
|
|
@ -407,7 +407,7 @@ static int gs_gif_output(GifFileType *file, const GifByteType *buffer, int len)
|
||||||
|
|
||||||
width = [self pixelsWide];
|
width = [self pixelsWide];
|
||||||
height = [self pixelsHigh];
|
height = [self pixelsHigh];
|
||||||
if ( !width || !height )
|
if (!width || !height)
|
||||||
{
|
{
|
||||||
SET_ERROR_MSG(@"GIFRepresentation: image is zero size");
|
SET_ERROR_MSG(@"GIFRepresentation: image is zero size");
|
||||||
return nil;
|
return nil;
|
||||||
|
@ -417,69 +417,69 @@ static int gs_gif_output(GifFileType *file, const GifByteType *buffer, int len)
|
||||||
colorSpaceName = [self colorSpaceName];
|
colorSpaceName = [self colorSpaceName];
|
||||||
isRGB = ([colorSpaceName isEqualToString: NSDeviceRGBColorSpace] ||
|
isRGB = ([colorSpaceName isEqualToString: NSDeviceRGBColorSpace] ||
|
||||||
[colorSpaceName isEqualToString: NSCalibratedRGBColorSpace]);
|
[colorSpaceName isEqualToString: NSCalibratedRGBColorSpace]);
|
||||||
if ( !isRGB )
|
if (!isRGB)
|
||||||
{
|
{
|
||||||
SET_ERROR_MSG(@"GIFRepresentation: Only RGB is supported at this time.");
|
SET_ERROR_MSG(@"GIFRepresentation: Only RGB is supported at this time.");
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
hasAlpha = [self hasAlpha];
|
|
||||||
if ([self isPlanar])
|
|
||||||
{
|
|
||||||
[self getBitmapDataPlanes: planes];
|
|
||||||
redPlane = planes[0];
|
|
||||||
greenPlane = planes[1];
|
|
||||||
bluePlane = planes[2];
|
|
||||||
}
|
|
||||||
else // interleaved RGB or RGBA
|
|
||||||
{
|
|
||||||
OBJC_MALLOC(rgbPlanes, GifByteType, width*height*3);
|
|
||||||
if ( !rgbPlanes )
|
|
||||||
{
|
|
||||||
SET_ERROR_MSG(@"GIFRepresentation: malloc out of memory.");
|
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
redPlane = rgbPlanes;
|
hasAlpha = [self hasAlpha];
|
||||||
greenPlane = redPlane + width*height;
|
if ([self isPlanar])
|
||||||
bluePlane = greenPlane + width*height;
|
|
||||||
bitmapData = [self bitmapData];
|
|
||||||
for (h = 0; h < width*height; h++)
|
|
||||||
{
|
{
|
||||||
*redPlane++ = *bitmapData++;
|
[self getBitmapDataPlanes: planes];
|
||||||
*greenPlane++ = *bitmapData++;
|
redPlane = planes[0];
|
||||||
*bluePlane++ = *bitmapData++;
|
greenPlane = planes[1];
|
||||||
if (hasAlpha) bitmapData++; // ignore alpha channel
|
bluePlane = planes[2];
|
||||||
|
}
|
||||||
|
else // interleaved RGB or RGBA
|
||||||
|
{
|
||||||
|
rgbPlanes = malloc(sizeof(GifByteType)*width*height*3);
|
||||||
|
if (!rgbPlanes)
|
||||||
|
{
|
||||||
|
SET_ERROR_MSG(@"GIFRepresentation: malloc out of memory.");
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
redPlane = rgbPlanes;
|
||||||
|
greenPlane = redPlane + width*height;
|
||||||
|
bluePlane = greenPlane + width*height;
|
||||||
|
bitmapData = [self bitmapData];
|
||||||
|
for (h = 0; h < width*height; h++)
|
||||||
|
{
|
||||||
|
*redPlane++ = *bitmapData++;
|
||||||
|
*greenPlane++ = *bitmapData++;
|
||||||
|
*bluePlane++ = *bitmapData++;
|
||||||
|
if (hasAlpha) bitmapData++; // ignore alpha channel
|
||||||
|
}
|
||||||
|
redPlane = rgbPlanes;
|
||||||
|
greenPlane = redPlane + width*height;
|
||||||
|
bluePlane = greenPlane + width*height;
|
||||||
}
|
}
|
||||||
redPlane = rgbPlanes;
|
|
||||||
greenPlane = redPlane + width*height;
|
|
||||||
bluePlane = greenPlane + width*height;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If you have a color table, you must be certain that it is GIF format
|
// If you have a color table, you must be certain that it is GIF format
|
||||||
colorTable = [self valueForProperty: NSImageRGBColorTable]; // nil is OK
|
colorTable = [self valueForProperty: NSImageRGBColorTable]; // nil is OK
|
||||||
colorMapSize = (colorTable)? [colorTable length]/sizeof(GifColorType) : 256;
|
colorMapSize = (colorTable)? [colorTable length]/sizeof(GifColorType) : 256;
|
||||||
GIFColorMap = MakeMapObject(colorMapSize, [colorTable bytes]);
|
GIFColorMap = MakeMapObject(colorMapSize, [colorTable bytes]);
|
||||||
if ( !GIFColorMap )
|
if (!GIFColorMap)
|
||||||
{
|
{
|
||||||
SET_ERROR_MSG(@"GIFRepresentation (giflib): MakeMapObject() failed.");
|
SET_ERROR_MSG(@"GIFRepresentation (giflib): MakeMapObject() failed.");
|
||||||
OBJC_FREE(rgbPlanes);
|
free(rgbPlanes);
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
OBJC_MALLOC(GIFImage, GifByteType, height*width);
|
GIFImage = malloc(sizeof(GifByteType)*height*width);
|
||||||
if ( !GIFImage )
|
if (!GIFImage)
|
||||||
{
|
{
|
||||||
SET_ERROR_MSG(@"GIFRepresentation: malloc out of memory.");
|
SET_ERROR_MSG(@"GIFRepresentation: malloc out of memory.");
|
||||||
OBJC_FREE(rgbPlanes);
|
free(rgbPlanes);
|
||||||
}
|
}
|
||||||
status = QuantizeBuffer(width, height, &colorMapSize,
|
status = QuantizeBuffer(width, height, &colorMapSize,
|
||||||
redPlane, greenPlane, bluePlane,
|
redPlane, greenPlane, bluePlane,
|
||||||
GIFImage, GIFColorMap->Colors);
|
GIFImage, GIFColorMap->Colors);
|
||||||
if (status == GIF_ERROR)
|
if (status == GIF_ERROR)
|
||||||
{
|
{
|
||||||
OBJC_FREE(GIFImage);
|
free(GIFImage);
|
||||||
OBJC_FREE(rgbPlanes);
|
free(rgbPlanes);
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
// QuantizeBuffer returns an optimized colorMapSize,
|
// QuantizeBuffer returns an optimized colorMapSize,
|
||||||
// but we must round up to nearest power of 2
|
// but we must round up to nearest power of 2
|
||||||
|
@ -490,48 +490,48 @@ static int gs_gif_output(GifFileType *file, const GifByteType *buffer, int len)
|
||||||
GIFColorMap->ColorCount = colorMapSize;
|
GIFColorMap->ColorCount = colorMapSize;
|
||||||
GIFColorMap->BitsPerPixel = h;
|
GIFColorMap->BitsPerPixel = h;
|
||||||
|
|
||||||
if ( ![self isPlanar] ) OBJC_FREE(rgbPlanes);
|
if (![self isPlanar]) free(rgbPlanes);
|
||||||
|
|
||||||
// Write the converted image out to the NSData
|
// Write the converted image out to the NSData
|
||||||
GIFRep = [NSMutableData dataWithLength: 0];
|
GIFRep = [NSMutableData dataWithLength: 0];
|
||||||
if ( !GIFRep )
|
if (!GIFRep)
|
||||||
{
|
{
|
||||||
OBJC_FREE(GIFImage);
|
free(GIFImage);
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
GIFFile = EGifOpen(GIFRep, gs_gif_output);
|
GIFFile = EGifOpen(GIFRep, gs_gif_output);
|
||||||
status = EGifPutScreenDesc(GIFFile, width, height, 8, 0, NULL);
|
status = EGifPutScreenDesc(GIFFile, width, height, 8, 0, NULL);
|
||||||
if (status == GIF_ERROR)
|
if (status == GIF_ERROR)
|
||||||
{
|
{
|
||||||
SET_ERROR_MSG(@"GIFRepresentation (giflib): EGifPutScreenDesc() failed.");
|
SET_ERROR_MSG(@"GIFRepresentation (giflib): EGifPutScreenDesc() failed.");
|
||||||
OBJC_FREE(GIFImage);
|
free(GIFImage);
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
// note we are not supporting interlaced mode
|
// note we are not supporting interlaced mode
|
||||||
status = EGifPutImageDesc(GIFFile, 0, 0, width, height, FALSE, GIFColorMap);
|
status = EGifPutImageDesc(GIFFile, 0, 0, width, height, FALSE, GIFColorMap);
|
||||||
if (status == GIF_ERROR)
|
if (status == GIF_ERROR)
|
||||||
{
|
{
|
||||||
SET_ERROR_MSG(@"GIFRepresentation (giflib): EGifPutImageDesc() failed.");
|
SET_ERROR_MSG(@"GIFRepresentation (giflib): EGifPutImageDesc() failed.");
|
||||||
OBJC_FREE(GIFImage);
|
free(GIFImage);
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
GIFImageP = GIFImage;
|
GIFImageP = GIFImage;
|
||||||
for (h = 0; h < height ; h++)
|
for (h = 0; h < height ; h++)
|
||||||
{
|
|
||||||
status = EGifPutLine(GIFFile, GIFImageP, width);
|
|
||||||
if (status == GIF_ERROR)
|
|
||||||
{
|
{
|
||||||
SET_ERROR_MSG(@"GIFRepresentation (giflib): EGifPutLine() failed.");
|
status = EGifPutLine(GIFFile, GIFImageP, width);
|
||||||
OBJC_FREE(GIFImage);
|
if (status == GIF_ERROR)
|
||||||
return nil;
|
{
|
||||||
|
SET_ERROR_MSG(@"GIFRepresentation (giflib): EGifPutLine() failed.");
|
||||||
|
free(GIFImage);
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
GIFImageP += width;
|
||||||
}
|
}
|
||||||
GIFImageP += width;
|
|
||||||
}
|
|
||||||
status = EGifCloseFile(GIFFile);
|
status = EGifCloseFile(GIFFile);
|
||||||
|
|
||||||
OBJC_FREE(GIFImage);
|
free(GIFImage);
|
||||||
|
|
||||||
return GIFRep;
|
return GIFRep;
|
||||||
}
|
}
|
||||||
|
|
|
@ -631,36 +631,36 @@ static void gs_jpeg_memory_dest_destroy (j_compress_ptr cinfo)
|
||||||
jpeg_start_compress (&cinfo, TRUE);
|
jpeg_start_compress (&cinfo, TRUE);
|
||||||
|
|
||||||
if (isRGB && [self hasAlpha]) // strip alpha channel before encoding
|
if (isRGB && [self hasAlpha]) // strip alpha channel before encoding
|
||||||
{
|
|
||||||
unsigned char * RGB, * pRGB, * pRGBA;
|
|
||||||
unsigned int iRGB, iRGBA;
|
|
||||||
OBJC_MALLOC(RGB, unsigned char, 3*width);
|
|
||||||
while (cinfo.next_scanline < cinfo.image_height)
|
|
||||||
{
|
{
|
||||||
iRGBA = cinfo.next_scanline * row_stride;
|
unsigned char * RGB, * pRGB, * pRGBA;
|
||||||
pRGBA = &imageSource[iRGBA];
|
unsigned int iRGB, iRGBA;
|
||||||
pRGB = RGB;
|
RGB = malloc(sizeof(unsigned char)*3*width);
|
||||||
for (iRGB = 0; iRGB < 3*width; iRGB += 3)
|
while (cinfo.next_scanline < cinfo.image_height)
|
||||||
{
|
{
|
||||||
memcpy(pRGB, pRGBA, 3);
|
iRGBA = cinfo.next_scanline * row_stride;
|
||||||
pRGB +=3;
|
pRGBA = &imageSource[iRGBA];
|
||||||
pRGBA +=4;
|
pRGB = RGB;
|
||||||
}
|
for (iRGB = 0; iRGB < 3*width; iRGB += 3)
|
||||||
row_pointer[0] = RGB;
|
{
|
||||||
jpeg_write_scanlines (&cinfo, row_pointer, 1);
|
memcpy(pRGB, pRGBA, 3);
|
||||||
|
pRGB +=3;
|
||||||
|
pRGBA +=4;
|
||||||
|
}
|
||||||
|
row_pointer[0] = RGB;
|
||||||
|
jpeg_write_scanlines (&cinfo, row_pointer, 1);
|
||||||
|
}
|
||||||
|
free(RGB);
|
||||||
}
|
}
|
||||||
OBJC_FREE(RGB);
|
|
||||||
}
|
|
||||||
else // no alpha channel
|
else // no alpha channel
|
||||||
{
|
|
||||||
while (cinfo.next_scanline < cinfo.image_height)
|
|
||||||
{
|
{
|
||||||
int index = cinfo.next_scanline * row_stride;
|
while (cinfo.next_scanline < cinfo.image_height)
|
||||||
|
{
|
||||||
|
int index = cinfo.next_scanline * row_stride;
|
||||||
|
|
||||||
row_pointer[0] = &imageSource[index];
|
row_pointer[0] = &imageSource[index];
|
||||||
jpeg_write_scanlines (&cinfo, row_pointer, 1);
|
jpeg_write_scanlines (&cinfo, row_pointer, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
jpeg_finish_compress(&cinfo);
|
jpeg_finish_compress(&cinfo);
|
||||||
|
|
||||||
|
|
|
@ -1932,12 +1932,12 @@ _set_bit_value(unsigned char *base, long msb_off, int bit_width,
|
||||||
|
|
||||||
if (NSTiffRead(image, info, [self bitmapData]))
|
if (NSTiffRead(image, info, [self bitmapData]))
|
||||||
{
|
{
|
||||||
OBJC_FREE(info);
|
free(info);
|
||||||
RELEASE(self);
|
RELEASE(self);
|
||||||
NSLog(@"Tiff read invalid TIFF image data in directory %d", imageNumber);
|
NSLog(@"Tiff read invalid TIFF image data in directory %d", imageNumber);
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
OBJC_FREE(info);
|
free(info);
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,7 +161,7 @@ TiffHandleClose(thandle_t handle)
|
||||||
chandle_t* chand = (chandle_t *)handle;
|
chandle_t* chand = (chandle_t *)handle;
|
||||||
|
|
||||||
/* Presumably, we don't need the handle anymore */
|
/* Presumably, we don't need the handle anymore */
|
||||||
OBJC_FREE(chand);
|
free(chand);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,7 +202,7 @@ NSTiffOpenDataRead(const char* data, long size)
|
||||||
TIFFSetWarningHandler(NSTiffWarning);
|
TIFFSetWarningHandler(NSTiffWarning);
|
||||||
}
|
}
|
||||||
|
|
||||||
OBJC_MALLOC(handle, chandle_t, 1);
|
handle = malloc(sizeof(chandle_t));
|
||||||
handle->data = (char*)data;
|
handle->data = (char*)data;
|
||||||
handle->outdata = 0;
|
handle->outdata = 0;
|
||||||
handle->position = 0;
|
handle->position = 0;
|
||||||
|
@ -221,7 +221,7 @@ TIFF*
|
||||||
NSTiffOpenDataWrite(char **data, long *size)
|
NSTiffOpenDataWrite(char **data, long *size)
|
||||||
{
|
{
|
||||||
chandle_t* handle;
|
chandle_t* handle;
|
||||||
OBJC_MALLOC(handle, chandle_t, 1);
|
handle = malloc(sizeof(chandle_t));
|
||||||
handle->data = *data;
|
handle->data = *data;
|
||||||
handle->outdata = data;
|
handle->outdata = data;
|
||||||
handle->position = 0;
|
handle->position = 0;
|
||||||
|
@ -269,7 +269,7 @@ NSTiffGetInfo(int imageNumber, TIFF* image)
|
||||||
if (image == NULL)
|
if (image == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
OBJC_MALLOC(info, NSTiffInfo, 1);
|
info = malloc(sizeof(NSTiffInfo));
|
||||||
memset(info, 0, sizeof(NSTiffInfo));
|
memset(info, 0, sizeof(NSTiffInfo));
|
||||||
if (imageNumber >= 0)
|
if (imageNumber >= 0)
|
||||||
{
|
{
|
||||||
|
@ -567,14 +567,14 @@ NSTiffGetColormap(TIFF* image)
|
||||||
if (info->photoInterp != PHOTOMETRIC_PALETTE)
|
if (info->photoInterp != PHOTOMETRIC_PALETTE)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
OBJC_MALLOC(map, NSTiffColormap, 1);
|
map = malloc(sizeof(NSTiffColormap));
|
||||||
map->size = 1 << info->bitsPerSample;
|
map->size = 1 << info->bitsPerSample;
|
||||||
|
|
||||||
if (!TIFFGetField(image, TIFFTAG_COLORMAP,
|
if (!TIFFGetField(image, TIFFTAG_COLORMAP,
|
||||||
&map->red, &map->green, &map->blue))
|
&map->red, &map->green, &map->blue))
|
||||||
{
|
{
|
||||||
TIFFError(TIFFFileName(image), "Missing required \"Colormap\" tag");
|
TIFFError(TIFFFileName(image), "Missing required \"Colormap\" tag");
|
||||||
OBJC_FREE(map);
|
free(map);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (CheckAndCorrectColormap(map) == 8)
|
if (CheckAndCorrectColormap(map) == 8)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue