def _populate_comptparms(self, img_array):
<EOL>if img_array.dtype == np.uint8:<EOL><INDENT>comp_prec = <NUM_LIT:8><EOL><DEDENT>else:<EOL><INDENT>comp_prec = <NUM_LIT:16><EOL><DEDENT>numrows, numcols, num_comps = img_array.shape<EOL>if version.openjpeg_version_tuple[<NUM_LIT:0>] == <NUM_LIT:1>:<EOL><INDENT>comptparms = (opj.ImageComptParmType * num_comps)()<EOL><DEDENT>else:<EOL><INDENT>comptparms = (opj2.ImageComptParmType * num_comps)()<EOL><DEDENT>for j in range(num_comps):<EOL><INDENT>comptparms[j].dx = self._cparams.subsampling_dx<EOL>comptparms[j].dy = self._cparams.subsampling_dy<EOL>comptparms[j].w = numcols<EOL>comptparms[j].h = numrows<EOL>comptparms[j].x0 = self._cparams.image_offset_x0<EOL>comptparms[j].y0 = self._cparams.image_offset_y0<EOL>comptparms[j].prec = comp_prec<EOL>comptparms[j].bpp = comp_prec<EOL>comptparms[j].sgnd = <NUM_LIT:0><EOL><DEDENT>self._comptparms = comptparms<EOL>
Instantiate and populate comptparms structure.

        This structure defines the image components.

        Parameters
        ----------
        img_array : ndarray
            Image data to be written to file.