Ejemplo n.º 1
0
void ViewerOperation::initImage()
{
	Image *ima = this->m_image;
	ImageUser iuser = *this->m_imageUser;
	void *lock;
	ImBuf *ibuf;

	/* make sure the image has the correct number of views */
	if (ima && BKE_scene_multiview_is_render_view_first(this->m_rd, this->m_viewName)) {
		BKE_image_verify_viewer_views(this->m_rd, ima, this->m_imageUser);
	}

	BLI_thread_lock(LOCK_DRAW_IMAGE);

	/* local changes to the original ImageUser */
	iuser.multi_index = BKE_scene_multiview_view_id_get(this->m_rd, this->m_viewName);
	ibuf = BKE_image_acquire_ibuf(ima, &iuser, &lock);

	if (!ibuf) {
		BLI_thread_unlock(LOCK_DRAW_IMAGE);
		return;
	}
	if (ibuf->x != (int)getWidth() || ibuf->y != (int)getHeight()) {

		imb_freerectImBuf(ibuf);
		imb_freerectfloatImBuf(ibuf);
		IMB_freezbuffloatImBuf(ibuf);
		ibuf->x = getWidth();
		ibuf->y = getHeight();
		/* zero size can happen if no image buffers exist to define a sensible resolution */
		if (ibuf->x > 0 && ibuf->y > 0)
			imb_addrectfloatImBuf(ibuf);
		ima->ok = IMA_OK_LOADED;

		ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
	}

	if (m_doDepthBuffer) {
		addzbuffloatImBuf(ibuf);
	}

	/* now we combine the input with ibuf */
	this->m_outputBuffer = ibuf->rect_float;

	/* needed for display buffer update */
	this->m_ibuf = ibuf;

	if (m_doDepthBuffer) {
		this->m_depthBuffer = ibuf->zbuf_float;
	}

	BKE_image_release_ibuf(this->m_image, this->m_ibuf, lock);

	BLI_thread_unlock(LOCK_DRAW_IMAGE);
}
void *OutputOpenExrMultiLayerMultiViewOperation::get_handle(const char *filename)
{
	unsigned int width = this->getWidth();
	unsigned int height = this->getHeight();

	if (width != 0 && height != 0) {

		void *exrhandle;
		SceneRenderView *srv;

		/* get a new global handle */
		exrhandle = IMB_exr_get_handle_name(filename);

		if (!BKE_scene_multiview_is_render_view_first(this->m_rd, this->m_viewName))
			return exrhandle;

		IMB_exr_clear_channels(exrhandle);

		/* check renderdata for amount of views */
		for (srv = (SceneRenderView *) this->m_rd->views.first; srv; srv = srv->next) {

			if (BKE_scene_multiview_is_render_view_active(this->m_rd, srv) == false)
				continue;

			IMB_exr_add_view(exrhandle, srv->name);

			for (unsigned int i = 0; i < this->m_layers.size(); ++i)
				add_exr_channels(exrhandle, this->m_layers[i].name, this->m_layers[i].datatype, srv->name, width, NULL);
		}

		BLI_make_existing_file(filename);

		/* prepare the file with all the channels for the header */
		if (IMB_exr_begin_write(exrhandle, filename, width, height, this->m_exr_codec) == 0) {
			printf("Error Writing Multilayer Multiview Openexr\n");
			IMB_exr_close(exrhandle);
		}
		else {
			IMB_exr_clear_channels(exrhandle);
			return exrhandle;
		}
	}
	return NULL;
}
void *OutputOpenExrSingleLayerMultiViewOperation::get_handle(const char *filename)
{
	size_t width = this->getWidth();
	size_t height = this->getHeight();
	SceneRenderView *srv;

	if (width != 0 && height != 0) {
		void *exrhandle;

		exrhandle = IMB_exr_get_handle_name(filename);

		if (!BKE_scene_multiview_is_render_view_first(this->m_rd, this->m_viewName))
			return exrhandle;

		IMB_exr_clear_channels(exrhandle);

		for (srv = (SceneRenderView *)this->m_rd->views.first; srv; srv = srv->next) {
			if (BKE_scene_multiview_is_render_view_active(this->m_rd, srv) == false)
				continue;

			IMB_exr_add_view(exrhandle, srv->name);
			add_exr_channels(exrhandle, NULL, this->m_datatype, srv->name, width, NULL);
		}

		BLI_make_existing_file(filename);

		/* prepare the file with all the channels */

		if (IMB_exr_begin_write(exrhandle, filename, width, height, this->m_format->exr_codec) == 0) {
			printf("Error Writing Singlelayer Multiview Openexr\n");
			IMB_exr_close(exrhandle);
		}
		else {
			IMB_exr_clear_channels(exrhandle);
			return exrhandle;
		}
	}
	return NULL;
}
void *OutputStereoOperation::get_handle(const char *filename)
{
	size_t width = this->getWidth();
	size_t height = this->getHeight();
	const char *names[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME};
	size_t i;

	if (width != 0 && height != 0) {
		void *exrhandle;

		exrhandle = IMB_exr_get_handle_name(filename);

		if (!BKE_scene_multiview_is_render_view_first(this->m_rd, this->m_viewName))
			return exrhandle;

		IMB_exr_clear_channels(exrhandle);

		for (i = 0; i < 2; i++)
			IMB_exr_add_view(exrhandle, names[i]);

		return exrhandle;
	}
	return NULL;
}