MCPcopy Create free account
hub / github.com/creatale/node-dv / cvInitImageHeader

Function cvInitImageHeader

deps/opencv/modules/core/src/array.cpp:2901–2952  ·  view source on GitHub ↗

initialize IplImage header, allocated by the user

Source from the content-addressed store, hash-verified

2899
2900// initialize IplImage header, allocated by the user
2901CV_IMPL IplImage*
2902cvInitImageHeader( IplImage * image, CvSize size, int depth,
2903 int channels, int origin, int align )
2904{
2905 const char *colorModel, *channelSeq;
2906
2907 if( !image )
2908 CV_Error( CV_HeaderIsNull, "null pointer to header" );
2909
2910 memset( image, 0, sizeof( *image ));
2911 image->nSize = sizeof( *image );
2912
2913 icvGetColorModel( channels, &colorModel, &channelSeq );
2914 strncpy( image->colorModel, colorModel, 4 );
2915 strncpy( image->channelSeq, channelSeq, 4 );
2916
2917 if( size.width < 0 || size.height < 0 )
2918 CV_Error( CV_BadROISize, "Bad input roi" );
2919
2920 if( (depth != (int)IPL_DEPTH_1U && depth != (int)IPL_DEPTH_8U &&
2921 depth != (int)IPL_DEPTH_8S && depth != (int)IPL_DEPTH_16U &&
2922 depth != (int)IPL_DEPTH_16S && depth != (int)IPL_DEPTH_32S &&
2923 depth != (int)IPL_DEPTH_32F && depth != (int)IPL_DEPTH_64F) ||
2924 channels < 0 )
2925 CV_Error( CV_BadDepth, "Unsupported format" );
2926 if( origin != CV_ORIGIN_BL && origin != CV_ORIGIN_TL )
2927 CV_Error( CV_BadOrigin, "Bad input origin" );
2928
2929 if( align != 4 && align != 8 )
2930 CV_Error( CV_BadAlign, "Bad input align" );
2931
2932 image->width = size.width;
2933 image->height = size.height;
2934
2935 if( image->roi )
2936 {
2937 image->roi->coi = 0;
2938 image->roi->xOffset = image->roi->yOffset = 0;
2939 image->roi->width = size.width;
2940 image->roi->height = size.height;
2941 }
2942
2943 image->nChannels = MAX( channels, 1 );
2944 image->depth = depth;
2945 image->align = align;
2946 image->widthStep = (((image->width * image->nChannels *
2947 (image->depth & ~IPL_DEPTH_SIGN) + 7)/8)+ align - 1) & (~(align - 1));
2948 image->origin = origin;
2949 image->imageSize = image->widthStep * image->height;
2950
2951 return image;
2952}
2953
2954
2955CV_IMPL void

Callers 5

matrix.cppFile · 0.85
cvGetImageFunction · 0.85
cvCreateImageHeaderFunction · 0.85
WImageViewMethod · 0.85
WImageViewCMethod · 0.85

Calls 1

icvGetColorModelFunction · 0.85

Tested by

no test coverage detected