def _populate_image_struct(self, image, imgdata):
numrows, numcols, num_comps = imgdata.shape<EOL>for k in range(num_comps):<EOL><INDENT>self._validate_nonzero_image_size(numrows, numcols, k)<EOL><DEDENT>image.contents.x0 = self._cparams.image_offset_x0<EOL>image.contents.y0 = self._cparams.image_offset_y0<EOL>image.contents.x1 = (image.contents.x0 +<EOL>(numcols - <NUM_LIT:1>) * self._cparams.subsampling_dx + <NUM_LIT:1>)<EOL>image.contents.y1 = (image.contents.y0 +<EOL>(numrows - <NUM_LIT:1>) * self._cparams.subsampling_dy + <NUM_LIT:1>)<EOL>for k in range(<NUM_LIT:0>, num_comps):<EOL><INDENT>if self._cparams.rsiz in (core.OPJ_PROFILE_CINEMA_2K,<EOL>core.OPJ_PROFILE_CINEMA_4K):<EOL><INDENT>image.contents.comps[k].prec = <NUM_LIT:12><EOL>image.contents.comps[k].bpp = <NUM_LIT:12><EOL><DEDENT>layer = np.ascontiguousarray(imgdata[:, :, k], dtype=np.int32)<EOL>dest = image.contents.comps[k].data<EOL>src = layer.ctypes.data<EOL>ctypes.memmove(dest, src, layer.nbytes)<EOL><DEDENT>return image<EOL>
Populates image struct needed for compression.

        Parameters
        ----------
        image : ImageType(ctypes.Structure)
            Corresponds to image_t type in openjp2 headers.
        img_array : ndarray
            Image data to be written to file.