| 3891 | } |
| 3892 | |
| 3893 | static void |
| 3894 | icvWriteImage( CvFileStorage* fs, const char* name, |
| 3895 | const void* struct_ptr, CvAttrList /*attr*/ ) |
| 3896 | { |
| 3897 | const IplImage* image = (const IplImage*)struct_ptr; |
| 3898 | char dt_buf[16], *dt; |
| 3899 | CvSize size; |
| 3900 | int y, depth; |
| 3901 | |
| 3902 | assert( CV_IS_IMAGE(image) ); |
| 3903 | |
| 3904 | if( image->dataOrder == IPL_DATA_ORDER_PLANE ) |
| 3905 | CV_Error( CV_StsUnsupportedFormat, |
| 3906 | "Images with planar data layout are not supported" ); |
| 3907 | |
| 3908 | cvStartWriteStruct( fs, name, CV_NODE_MAP, CV_TYPE_NAME_IMAGE ); |
| 3909 | cvWriteInt( fs, "width", image->width ); |
| 3910 | cvWriteInt( fs, "height", image->height ); |
| 3911 | cvWriteString( fs, "origin", image->origin == IPL_ORIGIN_TL |
| 3912 | ? "top-left" : "bottom-left", 0 ); |
| 3913 | cvWriteString( fs, "layout", image->dataOrder == IPL_DATA_ORDER_PLANE |
| 3914 | ? "planar" : "interleaved", 0 ); |
| 3915 | if( image->roi ) |
| 3916 | { |
| 3917 | cvStartWriteStruct( fs, "roi", CV_NODE_MAP + CV_NODE_FLOW ); |
| 3918 | cvWriteInt( fs, "x", image->roi->xOffset ); |
| 3919 | cvWriteInt( fs, "y", image->roi->yOffset ); |
| 3920 | cvWriteInt( fs, "width", image->roi->width ); |
| 3921 | cvWriteInt( fs, "height", image->roi->height ); |
| 3922 | cvWriteInt( fs, "coi", image->roi->coi ); |
| 3923 | cvEndWriteStruct( fs ); |
| 3924 | } |
| 3925 | |
| 3926 | depth = IPL2CV_DEPTH(image->depth); |
| 3927 | sprintf( dt_buf, "%d%c", image->nChannels, icvTypeSymbol[depth] ); |
| 3928 | dt = dt_buf + (dt_buf[2] == '\0' && dt_buf[0] == '1'); |
| 3929 | cvWriteString( fs, "dt", dt, 0 ); |
| 3930 | |
| 3931 | size = cvSize(image->width, image->height); |
| 3932 | if( size.width*image->nChannels*CV_ELEM_SIZE(depth) == image->widthStep ) |
| 3933 | { |
| 3934 | size.width *= size.height; |
| 3935 | size.height = 1; |
| 3936 | } |
| 3937 | |
| 3938 | cvStartWriteStruct( fs, "data", CV_NODE_SEQ + CV_NODE_FLOW ); |
| 3939 | for( y = 0; y < size.height; y++ ) |
| 3940 | cvWriteRawData( fs, image->imageData + y*image->widthStep, size.width, dt ); |
| 3941 | cvEndWriteStruct( fs ); |
| 3942 | cvEndWriteStruct( fs ); |
| 3943 | } |
| 3944 | |
| 3945 | |
| 3946 | static void* |
nothing calls this directly
no test coverage detected