MCPcopy Index your code
hub / github.com/MapServer/MapServer / msImageCreate

Function msImageCreate

maputil.c:1450–1587  ·  view source on GitHub ↗

* Generic function to Initalize an image object. */

Source from the content-addressed store, hash-verified

1448 * Generic function to Initalize an image object.
1449 */
1450imageObj *msImageCreate(int width, int height, outputFormatObj *format,
1451 char *imagepath, char *imageurl, double resolution,
1452 double defresolution, colorObj *bg)
1453{
1454 imageObj *image = NULL;
1455 if(MS_RENDERER_PLUGIN(format)) {
1456
1457 image = format->vtable->createImage(width,height,format,bg);
1458 if (image == NULL)
1459 {
1460 msSetError(MS_MEMERR, "Unable to create new image object.", "msImageCreate()");
1461 return NULL;
1462 }
1463
1464 image->format = format;
1465 format->refcount++;
1466
1467 image->width = width;
1468 image->height = height;
1469 image->imagepath = NULL;
1470 image->imageurl = NULL;
1471 image->tilecache = NULL;
1472 image->ntiles = 0;
1473 image->resolution = resolution;
1474 image->resolutionfactor = resolution/defresolution;
1475
1476 if (imagepath)
1477 image->imagepath = msStrdup(imagepath);
1478 if (imageurl)
1479 image->imageurl = msStrdup(imageurl);
1480
1481 return image;
1482 }
1483 else if( MS_RENDERER_RAWDATA(format) )
1484 {
1485 if( format->imagemode != MS_IMAGEMODE_INT16
1486 && format->imagemode != MS_IMAGEMODE_FLOAT32
1487 && format->imagemode != MS_IMAGEMODE_BYTE )
1488 {
1489 msSetError(MS_IMGERR,
1490 "Attempt to use illegal imagemode with rawdata renderer.",
1491 "msImageCreate()" );
1492 return NULL;
1493 }
1494
1495 image = (imageObj *)calloc(1,sizeof(imageObj));
1496 if (image == NULL)
1497 {
1498 msSetError(MS_MEMERR, "Unable to create new image object.", "msImageCreate()");
1499 return NULL;
1500 }
1501
1502 if( format->imagemode == MS_IMAGEMODE_INT16 )
1503 image->img.raw_16bit = (short *)
1504 msSmallCalloc(sizeof(short),width*height*format->bands);
1505 else if( format->imagemode == MS_IMAGEMODE_FLOAT32 )
1506 image->img.raw_float = (float *)
1507 msSmallCalloc(sizeof(float),width*height*format->bands);

Callers 14

msDrawScalebarFunction · 0.85
msPrepareImageFunction · 0.85
msDrawLayerFunction · 0.85
getTileFunction · 0.85
msDrawLegendIconFunction · 0.85
msCreateLegendIconFunction · 0.85
msDrawLegendFunction · 0.85
mainFunction · 0.85
msWCSGetCoverageFunction · 0.85
msWCSGetCoverage20Function · 0.85
msResampleGDALToMapFunction · 0.85
msTileExtractSubTileFunction · 0.85

Calls 9

msSetErrorFunction · 0.85
msStrdupFunction · 0.85
msSmallCallocFunction · 0.85
msFreeFunction · 0.85
msAllocBitArrayFunction · 0.85
msGetOutputFormatOptionFunction · 0.85
msImageCreateIMFunction · 0.85
msImageInitIMFunction · 0.85
createImageMethod · 0.80

Tested by

no test coverage detected