mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 17:52:42 +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
e1fdfb3ee4
commit
edb6aa47ee
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>
|
||||
|
||||
* Source/GSLayoutManager.m
|
||||
|
|
|
@ -407,7 +407,7 @@ static int gs_gif_output(GifFileType *file, const GifByteType *buffer, int len)
|
|||
|
||||
width = [self pixelsWide];
|
||||
height = [self pixelsHigh];
|
||||
if ( !width || !height )
|
||||
if (!width || !height)
|
||||
{
|
||||
SET_ERROR_MSG(@"GIFRepresentation: image is zero size");
|
||||
return nil;
|
||||
|
@ -417,69 +417,69 @@ static int gs_gif_output(GifFileType *file, const GifByteType *buffer, int len)
|
|||
colorSpaceName = [self colorSpaceName];
|
||||
isRGB = ([colorSpaceName isEqualToString: NSDeviceRGBColorSpace] ||
|
||||
[colorSpaceName isEqualToString: NSCalibratedRGBColorSpace]);
|
||||
if ( !isRGB )
|
||||
{
|
||||
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.");
|
||||
if (!isRGB)
|
||||
{
|
||||
SET_ERROR_MSG(@"GIFRepresentation: Only RGB is supported at this time.");
|
||||
return nil;
|
||||
}
|
||||
redPlane = rgbPlanes;
|
||||
greenPlane = redPlane + width*height;
|
||||
bluePlane = greenPlane + width*height;
|
||||
bitmapData = [self bitmapData];
|
||||
for (h = 0; h < width*height; h++)
|
||||
hasAlpha = [self hasAlpha];
|
||||
if ([self isPlanar])
|
||||
{
|
||||
*redPlane++ = *bitmapData++;
|
||||
*greenPlane++ = *bitmapData++;
|
||||
*bluePlane++ = *bitmapData++;
|
||||
if (hasAlpha) bitmapData++; // ignore alpha channel
|
||||
[self getBitmapDataPlanes: planes];
|
||||
redPlane = planes[0];
|
||||
greenPlane = planes[1];
|
||||
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
|
||||
colorTable = [self valueForProperty: NSImageRGBColorTable]; // nil is OK
|
||||
colorMapSize = (colorTable)? [colorTable length]/sizeof(GifColorType) : 256;
|
||||
GIFColorMap = MakeMapObject(colorMapSize, [colorTable bytes]);
|
||||
if ( !GIFColorMap )
|
||||
{
|
||||
SET_ERROR_MSG(@"GIFRepresentation (giflib): MakeMapObject() failed.");
|
||||
OBJC_FREE(rgbPlanes);
|
||||
return nil;
|
||||
}
|
||||
if (!GIFColorMap)
|
||||
{
|
||||
SET_ERROR_MSG(@"GIFRepresentation (giflib): MakeMapObject() failed.");
|
||||
free(rgbPlanes);
|
||||
return nil;
|
||||
}
|
||||
|
||||
OBJC_MALLOC(GIFImage, GifByteType, height*width);
|
||||
if ( !GIFImage )
|
||||
{
|
||||
SET_ERROR_MSG(@"GIFRepresentation: malloc out of memory.");
|
||||
OBJC_FREE(rgbPlanes);
|
||||
}
|
||||
GIFImage = malloc(sizeof(GifByteType)*height*width);
|
||||
if (!GIFImage)
|
||||
{
|
||||
SET_ERROR_MSG(@"GIFRepresentation: malloc out of memory.");
|
||||
free(rgbPlanes);
|
||||
}
|
||||
status = QuantizeBuffer(width, height, &colorMapSize,
|
||||
redPlane, greenPlane, bluePlane,
|
||||
GIFImage, GIFColorMap->Colors);
|
||||
if (status == GIF_ERROR)
|
||||
{
|
||||
OBJC_FREE(GIFImage);
|
||||
OBJC_FREE(rgbPlanes);
|
||||
return nil;
|
||||
}
|
||||
{
|
||||
free(GIFImage);
|
||||
free(rgbPlanes);
|
||||
return nil;
|
||||
}
|
||||
|
||||
// QuantizeBuffer returns an optimized colorMapSize,
|
||||
// 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->BitsPerPixel = h;
|
||||
|
||||
if ( ![self isPlanar] ) OBJC_FREE(rgbPlanes);
|
||||
if (![self isPlanar]) free(rgbPlanes);
|
||||
|
||||
// Write the converted image out to the NSData
|
||||
GIFRep = [NSMutableData dataWithLength: 0];
|
||||
if ( !GIFRep )
|
||||
{
|
||||
OBJC_FREE(GIFImage);
|
||||
return nil;
|
||||
}
|
||||
if (!GIFRep)
|
||||
{
|
||||
free(GIFImage);
|
||||
return nil;
|
||||
}
|
||||
GIFFile = EGifOpen(GIFRep, gs_gif_output);
|
||||
status = EGifPutScreenDesc(GIFFile, width, height, 8, 0, NULL);
|
||||
if (status == GIF_ERROR)
|
||||
{
|
||||
SET_ERROR_MSG(@"GIFRepresentation (giflib): EGifPutScreenDesc() failed.");
|
||||
OBJC_FREE(GIFImage);
|
||||
return nil;
|
||||
}
|
||||
{
|
||||
SET_ERROR_MSG(@"GIFRepresentation (giflib): EGifPutScreenDesc() failed.");
|
||||
free(GIFImage);
|
||||
return nil;
|
||||
}
|
||||
|
||||
// note we are not supporting interlaced mode
|
||||
status = EGifPutImageDesc(GIFFile, 0, 0, width, height, FALSE, GIFColorMap);
|
||||
if (status == GIF_ERROR)
|
||||
{
|
||||
SET_ERROR_MSG(@"GIFRepresentation (giflib): EGifPutImageDesc() failed.");
|
||||
OBJC_FREE(GIFImage);
|
||||
return nil;
|
||||
}
|
||||
{
|
||||
SET_ERROR_MSG(@"GIFRepresentation (giflib): EGifPutImageDesc() failed.");
|
||||
free(GIFImage);
|
||||
return nil;
|
||||
}
|
||||
|
||||
GIFImageP = GIFImage;
|
||||
for (h = 0; h < height ; h++)
|
||||
{
|
||||
status = EGifPutLine(GIFFile, GIFImageP, width);
|
||||
if (status == GIF_ERROR)
|
||||
{
|
||||
SET_ERROR_MSG(@"GIFRepresentation (giflib): EGifPutLine() failed.");
|
||||
OBJC_FREE(GIFImage);
|
||||
return nil;
|
||||
status = EGifPutLine(GIFFile, GIFImageP, width);
|
||||
if (status == GIF_ERROR)
|
||||
{
|
||||
SET_ERROR_MSG(@"GIFRepresentation (giflib): EGifPutLine() failed.");
|
||||
free(GIFImage);
|
||||
return nil;
|
||||
}
|
||||
GIFImageP += width;
|
||||
}
|
||||
GIFImageP += width;
|
||||
}
|
||||
status = EGifCloseFile(GIFFile);
|
||||
|
||||
OBJC_FREE(GIFImage);
|
||||
free(GIFImage);
|
||||
|
||||
return GIFRep;
|
||||
}
|
||||
|
|
|
@ -631,36 +631,36 @@ static void gs_jpeg_memory_dest_destroy (j_compress_ptr cinfo)
|
|||
jpeg_start_compress (&cinfo, TRUE);
|
||||
|
||||
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;
|
||||
pRGBA = &imageSource[iRGBA];
|
||||
pRGB = RGB;
|
||||
for (iRGB = 0; iRGB < 3*width; iRGB += 3)
|
||||
{
|
||||
memcpy(pRGB, pRGBA, 3);
|
||||
pRGB +=3;
|
||||
pRGBA +=4;
|
||||
}
|
||||
row_pointer[0] = RGB;
|
||||
jpeg_write_scanlines (&cinfo, row_pointer, 1);
|
||||
unsigned char * RGB, * pRGB, * pRGBA;
|
||||
unsigned int iRGB, iRGBA;
|
||||
RGB = malloc(sizeof(unsigned char)*3*width);
|
||||
while (cinfo.next_scanline < cinfo.image_height)
|
||||
{
|
||||
iRGBA = cinfo.next_scanline * row_stride;
|
||||
pRGBA = &imageSource[iRGBA];
|
||||
pRGB = RGB;
|
||||
for (iRGB = 0; iRGB < 3*width; iRGB += 3)
|
||||
{
|
||||
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
|
||||
{
|
||||
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];
|
||||
jpeg_write_scanlines (&cinfo, row_pointer, 1);
|
||||
row_pointer[0] = &imageSource[index];
|
||||
jpeg_write_scanlines (&cinfo, row_pointer, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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]))
|
||||
{
|
||||
OBJC_FREE(info);
|
||||
free(info);
|
||||
RELEASE(self);
|
||||
NSLog(@"Tiff read invalid TIFF image data in directory %d", imageNumber);
|
||||
return nil;
|
||||
}
|
||||
OBJC_FREE(info);
|
||||
free(info);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -161,7 +161,7 @@ TiffHandleClose(thandle_t handle)
|
|||
chandle_t* chand = (chandle_t *)handle;
|
||||
|
||||
/* Presumably, we don't need the handle anymore */
|
||||
OBJC_FREE(chand);
|
||||
free(chand);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -202,7 +202,7 @@ NSTiffOpenDataRead(const char* data, long size)
|
|||
TIFFSetWarningHandler(NSTiffWarning);
|
||||
}
|
||||
|
||||
OBJC_MALLOC(handle, chandle_t, 1);
|
||||
handle = malloc(sizeof(chandle_t));
|
||||
handle->data = (char*)data;
|
||||
handle->outdata = 0;
|
||||
handle->position = 0;
|
||||
|
@ -221,7 +221,7 @@ TIFF*
|
|||
NSTiffOpenDataWrite(char **data, long *size)
|
||||
{
|
||||
chandle_t* handle;
|
||||
OBJC_MALLOC(handle, chandle_t, 1);
|
||||
handle = malloc(sizeof(chandle_t));
|
||||
handle->data = *data;
|
||||
handle->outdata = data;
|
||||
handle->position = 0;
|
||||
|
@ -269,7 +269,7 @@ NSTiffGetInfo(int imageNumber, TIFF* image)
|
|||
if (image == NULL)
|
||||
return NULL;
|
||||
|
||||
OBJC_MALLOC(info, NSTiffInfo, 1);
|
||||
info = malloc(sizeof(NSTiffInfo));
|
||||
memset(info, 0, sizeof(NSTiffInfo));
|
||||
if (imageNumber >= 0)
|
||||
{
|
||||
|
@ -567,14 +567,14 @@ NSTiffGetColormap(TIFF* image)
|
|||
if (info->photoInterp != PHOTOMETRIC_PALETTE)
|
||||
return NULL;
|
||||
|
||||
OBJC_MALLOC(map, NSTiffColormap, 1);
|
||||
map = malloc(sizeof(NSTiffColormap));
|
||||
map->size = 1 << info->bitsPerSample;
|
||||
|
||||
if (!TIFFGetField(image, TIFFTAG_COLORMAP,
|
||||
&map->red, &map->green, &map->blue))
|
||||
{
|
||||
TIFFError(TIFFFileName(image), "Missing required \"Colormap\" tag");
|
||||
OBJC_FREE(map);
|
||||
free(map);
|
||||
return NULL;
|
||||
}
|
||||
if (CheckAndCorrectColormap(map) == 8)
|
||||
|
|
Loading…
Reference in a new issue