您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ BKE_image_release_ibuf函数代码示例

51自学网 2021-06-01 19:50:51
  C++
这篇教程C++ BKE_image_release_ibuf函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中BKE_image_release_ibuf函数的典型用法代码示例。如果您正苦于以下问题:C++ BKE_image_release_ibuf函数的具体用法?C++ BKE_image_release_ibuf怎么用?C++ BKE_image_release_ibuf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了BKE_image_release_ibuf函数的23个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: rna_Image_save_render

static void rna_Image_save_render(Image *image, bContext *C, ReportList *reports, const char *path, Scene *scene){	ImBuf *ibuf;	if (scene == NULL) {		scene = CTX_data_scene(C);	}	if (scene) {		ImageUser iuser;		void *lock;		iuser.scene = scene;		iuser.ok = 1;		ibuf = BKE_image_acquire_ibuf(image, &iuser, &lock);		if (ibuf == NULL) {			BKE_reportf(reports, RPT_ERROR, "Couldn't acquire buffer from image");		}		else {			/* temp swap out the color */			const unsigned char imb_depth_back= ibuf->depth;			const float dither_back= ibuf->dither; 			ibuf->depth= scene->r.planes;			ibuf->dither= scene->r.dither_intensity;			if (!BKE_write_ibuf(ibuf, path, scene->r.imtype, scene->r.subimtype, scene->r.quality)) {				BKE_reportf(reports, RPT_ERROR, "Couldn't write image: %s", path);			}			ibuf->depth= imb_depth_back;			ibuf->dither= dither_back;		}		BKE_image_release_ibuf(image, lock);	} else {		BKE_reportf(reports, RPT_ERROR, "Scene not in context, couldn't get save parameters");	}}
开发者ID:OldBrunet,项目名称:BGERTPS,代码行数:38,


示例2: image_rect_update

static void image_rect_update(void *rjv, RenderResult *rr, volatile rcti *renrect){	RenderJob *rj = rjv;	Image *ima = rj->image;	ImBuf *ibuf;	void *lock;	/* only update if we are displaying the slot being rendered */	if (ima->render_slot != ima->last_render_slot) {		rj->image_outdated = true;		return;	}	else if (rj->image_outdated) {		/* update entire render */		rj->image_outdated = false;		BKE_image_signal(ima, NULL, IMA_SIGNAL_COLORMANAGE);		*(rj->do_update) = TRUE;		return;	}	/* update part of render */	render_image_update_pass_and_layer(rj, rr, &rj->iuser);	ibuf = BKE_image_acquire_ibuf(ima, &rj->iuser, &lock);	if (ibuf) {		/* Don't waste time on CPU side color management if		 * image will be displayed using GLSL.		 */		if (ibuf->channels == 1 ||		    U.image_draw_method != IMAGE_DRAW_METHOD_GLSL)		{			image_buffer_rect_update(rj->scene, rr, ibuf, &rj->iuser, renrect);		}		/* make jobs timer to send notifier */		*(rj->do_update) = TRUE;	}	BKE_image_release_ibuf(ima, ibuf, lock);}
开发者ID:silkentrance,项目名称:blender,代码行数:38,


示例3: BKE_image_acquire_ibuf

void ViewerOperation::initImage(){	Image *ima = this->m_image;	void *lock;	ImBuf *ibuf = BKE_image_acquire_ibuf(ima, this->m_imageUser, &lock);	if (!ibuf) return;	BLI_lock_thread(LOCK_DRAW_IMAGE);	if (ibuf->x != (int)getWidth() || ibuf->y != (int)getHeight()) {		imb_freerectImBuf(ibuf);		imb_freerectfloatImBuf(ibuf);		IMB_freezbuffloatImBuf(ibuf);		ibuf->x = getWidth();		ibuf->y = getHeight();		imb_addrectfloatImBuf(ibuf);		ima->ok = IMA_OK_LOADED;		ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;	}	if (m_doDepthBuffer) {		addzbuffloatImBuf(ibuf);	}	BLI_unlock_thread(LOCK_DRAW_IMAGE);	/* 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);}
开发者ID:YasirArafath,项目名称:blender-git,代码行数:38,


示例4: rna_Image_pixels_get

static void rna_Image_pixels_get(PointerRNA *ptr, float *values){	Image *ima = ptr->id.data;	ImBuf *ibuf;	void *lock;	int i, size;	ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);	if (ibuf) {		size = ibuf->x * ibuf->y * ibuf->channels;		if (ibuf->rect_float) {			memcpy(values, ibuf->rect_float, sizeof(float) * size);		}		else {			for (i = 0; i < size; i++)				values[i] = ((unsigned char *)ibuf->rect)[i] * (1.0f / 255.0f);		}	}	BKE_image_release_ibuf(ima, ibuf, lock);}
开发者ID:silkentrance,项目名称:blender,代码行数:23,


示例5: gpu_shader_texture

static int gpu_shader_texture(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out){	Tex *tex = (Tex *)node->id;	if (tex && tex->type == TEX_IMAGE && tex->ima) {		GPUNodeLink *texlink = GPU_image(tex->ima, &tex->iuser, false);		int ret = GPU_stack_link(mat, "texture_image", in, out, texlink);		if (ret) {			ImBuf *ibuf = BKE_image_acquire_ibuf(tex->ima, &tex->iuser, NULL);			if (ibuf && (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA) == 0 &&			    GPU_material_do_color_management(mat))			{				GPU_link(mat, "srgb_to_linearrgb", out[1].link, &out[1].link);			}			BKE_image_release_ibuf(tex->ima, ibuf, NULL);		}		return ret;	}	else		return 0;}
开发者ID:Andrewson3D,项目名称:blender-for-vray,代码行数:23,


示例6: BKE_image_acquire_ibuf

static void *init_heights_data(MultiresBakeRender *bkr, Image *ima){	MHeightBakeData *height_data;	ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);	DerivedMesh *lodm = bkr->lores_dm;	height_data = MEM_callocN(sizeof(MHeightBakeData), "MultiresBake heightData");	height_data->ima = ima;	height_data->heights = MEM_callocN(sizeof(float) * ibuf->x * ibuf->y, "MultiresBake heights");	height_data->height_max = -FLT_MAX;	height_data->height_min = FLT_MAX;	if (!bkr->use_lores_mesh) {		SubsurfModifierData smd = {{NULL}};		int ss_lvl = bkr->tot_lvl - bkr->lvl;		CLAMP(ss_lvl, 0, 6);		if (ss_lvl > 0) {			smd.levels = smd.renderLevels = ss_lvl;			smd.flags |= eSubsurfModifierFlag_SubsurfUv;			if (bkr->simple)				smd.subdivType = ME_SIMPLE_SUBSURF;			height_data->ssdm = subsurf_make_derived_from_derived(bkr->lores_dm, &smd, NULL, 0);		}	}	height_data->orig_index_mf_to_mpoly = lodm->getTessFaceDataArray(lodm, CD_ORIGINDEX);	height_data->orig_index_mp_to_orig = lodm->getPolyDataArray(lodm, CD_ORIGINDEX);	BKE_image_release_ibuf(ima, ibuf, NULL);	return (void *)height_data;}
开发者ID:danielmarg,项目名称:blender-main,代码行数:37,


示例7: node_shader_gpu_tex_environment

static int node_shader_gpu_tex_environment(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out){	Image *ima = (Image *)node->id;	ImageUser *iuser = NULL;	NodeTexImage *tex = node->storage;	int isdata = tex->color_space == SHD_COLORSPACE_NONE;	if (!ima)		return GPU_stack_link(mat, "node_tex_environment_empty", in, out);	if (!in[0].link) {		GPUMatType type = GPU_Material_get_type(mat);				if (type == GPU_MATERIAL_TYPE_MESH)			in[0].link = GPU_builtin(GPU_VIEW_POSITION);		else			GPU_link(mat, "background_transform_to_world", GPU_builtin(GPU_VIEW_POSITION), &in[0].link);	}		node_shader_gpu_tex_mapping(mat, node, in, out);	if (tex->projection == SHD_PROJ_EQUIRECTANGULAR)		GPU_stack_link(mat, "node_tex_environment_equirectangular", in, out, GPU_image(ima, iuser, isdata));	else		GPU_stack_link(mat, "node_tex_environment_mirror_ball", in, out, GPU_image(ima, iuser, isdata));			ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL);	if (ibuf && (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA) == 0 &&	    GPU_material_do_color_management(mat))	{		GPU_link(mat, "srgb_to_linearrgb", out[0].link, &out[0].link);	}	BKE_image_release_ibuf(ima, ibuf, NULL);	return true;}
开发者ID:mgschwan,项目名称:blensor,代码行数:36,


示例8: BKE_image_release_ibuf

// close added texturePyObject *Texture_close(Texture * self){	// restore texture	if (self->m_orgSaved)	{		self->m_orgSaved = false;		// restore original texture code		if (self->m_useMatTexture)			self->m_matTexture->swapTexture(self->m_orgTex);		else		{			self->m_imgTexture->bindcode[TEXTARGET_TEXTURE_2D] = self->m_orgTex;			BKE_image_release_ibuf(self->m_imgTexture, self->m_imgBuf, NULL);			self->m_imgBuf = NULL;		}		// drop actual texture		if (self->m_actTex != 0)		{			glDeleteTextures(1, (GLuint *)&self->m_actTex);			self->m_actTex = 0;		}	}	Py_RETURN_NONE;}
开发者ID:Ichthyostega,项目名称:blender,代码行数:25,


示例9: BIF_render_spare_imbuf

ImBuf *ED_space_image_acquire_buffer(SpaceImage *sima, void **r_lock){	ImBuf *ibuf;	if (sima && sima->image) {#if 0		if (sima->image->type == IMA_TYPE_R_RESULT && BIF_show_render_spare())			return BIF_render_spare_imbuf();		else#endif		ibuf = BKE_image_acquire_ibuf(sima->image, &sima->iuser, r_lock);		if (ibuf) {			if (ibuf->rect || ibuf->rect_float)				return ibuf;			BKE_image_release_ibuf(sima->image, ibuf, *r_lock);			*r_lock = NULL;		}	}	else		*r_lock = NULL;	return NULL;}
开发者ID:ChunHungLiu,项目名称:blender,代码行数:24,


示例10: write_internal_bake_pixels

static bool write_internal_bake_pixels(        Image *image, BakePixel pixel_array[], float *buffer,        const int width, const int height, const int margin,        const bool is_clear, const bool is_noncolor){	ImBuf *ibuf;	void *lock;	bool is_float;	char *mask_buffer = NULL;	const size_t num_pixels = (size_t)width * (size_t)height;	ibuf = BKE_image_acquire_ibuf(image, NULL, &lock);	if (!ibuf)		return false;	if (margin > 0 || !is_clear) {		mask_buffer = MEM_callocN(sizeof(char) * num_pixels, "Bake Mask");		RE_bake_mask_fill(pixel_array, num_pixels, mask_buffer);	}	is_float = (ibuf->flags & IB_rectfloat);	/* colormanagement conversions */	if (!is_noncolor) {		const char *from_colorspace;		const char *to_colorspace;		from_colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_SCENE_LINEAR);		if (is_float)			to_colorspace = IMB_colormanagement_get_float_colorspace(ibuf);		else			to_colorspace = IMB_colormanagement_get_rect_colorspace(ibuf);		if (from_colorspace != to_colorspace)			IMB_colormanagement_transform(buffer, ibuf->x, ibuf->y, ibuf->channels, from_colorspace, to_colorspace, false);	}	/* populates the ImBuf */	if (is_clear) {		if (is_float) {			IMB_buffer_float_from_float(			        ibuf->rect_float, buffer, ibuf->channels,			        IB_PROFILE_LINEAR_RGB, IB_PROFILE_LINEAR_RGB, false,			        ibuf->x, ibuf->y, ibuf->x, ibuf->x);		}		else {			IMB_buffer_byte_from_float(			        (unsigned char *) ibuf->rect, buffer, ibuf->channels, ibuf->dither,			        IB_PROFILE_SRGB, IB_PROFILE_SRGB,			        false, ibuf->x, ibuf->y, ibuf->x, ibuf->x);		}	}	else {		if (is_float) {			IMB_buffer_float_from_float_mask(			        ibuf->rect_float, buffer, ibuf->channels,			        ibuf->x, ibuf->y, ibuf->x, ibuf->x, mask_buffer);		}		else {			IMB_buffer_byte_from_float_mask(			        (unsigned char *) ibuf->rect, buffer, ibuf->channels, ibuf->dither,			        false, ibuf->x, ibuf->y, ibuf->x, ibuf->x, mask_buffer);		}	}	/* margins */	if (margin > 0)		RE_bake_margin(ibuf, mask_buffer, margin);	ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID | IB_BITMAPDIRTY;	if (ibuf->rect_float)		ibuf->userflags |= IB_RECT_INVALID;	/* force mipmap recalc */	if (ibuf->mipmap[0]) {		ibuf->userflags |= IB_MIPMAP_INVALID;		imb_freemipmapImBuf(ibuf);	}	BKE_image_release_ibuf(image, ibuf, NULL);	if (mask_buffer)		MEM_freeN(mask_buffer);	return true;}
开发者ID:Passtechsoft,项目名称:TPEAlpGen,代码行数:89,


示例11: draw_plane_marker_image

static void draw_plane_marker_image(Scene *scene,                                    MovieTrackingPlaneTrack *plane_track,                                    MovieTrackingPlaneMarker *plane_marker){	Image *image = plane_track->image;	ImBuf *ibuf;	void *lock;	if (image == NULL) {		return;	}	ibuf = BKE_image_acquire_ibuf(image, NULL, &lock);	if (ibuf) {		unsigned char *display_buffer;		void *cache_handle;		if (image->flag & IMA_VIEW_AS_RENDER) {			display_buffer = IMB_display_buffer_acquire(ibuf,			                                            &scene->view_settings,			                                            &scene->display_settings,			                                            &cache_handle);		}		else {			display_buffer = IMB_display_buffer_acquire(ibuf, NULL,			                                            &scene->display_settings,			                                            &cache_handle);		}		if (display_buffer) {			GLuint texid, last_texid;			float frame_corners[4][2] = {{0.0f, 0.0f},			                             {1.0f, 0.0f},			                             {1.0f, 1.0f},			                             {0.0f, 1.0f}};			float perspective_matrix[3][3];			float gl_matrix[4][4];			bool transparent = false;			BKE_tracking_homography_between_two_quads(frame_corners,			                                          plane_marker->corners,			                                          perspective_matrix);			homogeneous_2d_to_gl_matrix(perspective_matrix, gl_matrix);			if (plane_track->image_opacity != 1.0f || ibuf->planes == 32) {				transparent = true;				glEnable(GL_BLEND);				glBlendFunc(GL_SRC_ALPHA,  GL_ONE_MINUS_SRC_ALPHA);			}			glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);			glColor4f(1.0, 1.0, 1.0, plane_track->image_opacity);			last_texid = glaGetOneInteger(GL_TEXTURE_2D);			glEnable(GL_TEXTURE_2D);			glGenTextures(1, (GLuint *)&texid);			glBindTexture(GL_TEXTURE_2D, texid);			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, ibuf->x, ibuf->y, 0, GL_RGBA,			             GL_UNSIGNED_BYTE, display_buffer);			glPushMatrix();			glMultMatrixf(gl_matrix);			glBegin(GL_QUADS);			glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f);			glTexCoord2f(1.0f, 0.0f); glVertex2f(1.0f, 0.0f);			glTexCoord2f(1.0f, 1.0f); glVertex2f(1.0f, 1.0f);			glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, 1.0f);			glEnd();			glPopMatrix();			glBindTexture(GL_TEXTURE_2D, last_texid);			glDisable(GL_TEXTURE_2D);			if (transparent) {				glDisable(GL_BLEND);			}		}		IMB_display_buffer_release(cache_handle);	}	BKE_image_release_ibuf(image, ibuf, lock);}
开发者ID:manwapastorelli,项目名称:blender-git,代码行数:91,


示例12: ED_space_image_release_buffer

void ED_space_image_release_buffer(SpaceImage *sima, ImBuf *ibuf, void *lock){	if (sima && sima->image)		BKE_image_release_ibuf(sima->image, ibuf, lock);}
开发者ID:Moguri,项目名称:blender,代码行数:5,


示例13: ED_view3d_select_id_read_rect

//.........这里部分代码省略.........        }        if (clip == NULL) {          continue;        }        BKE_movieclip_user_set_frame(&bgpic->cuser, (int)DEG_get_ctime(depsgraph));        ibuf = BKE_movieclip_get_ibuf(clip, &bgpic->cuser);        image_aspect[0] = clip->aspx;        image_aspect[1] = clip->aspy;        /* working with ibuf from image and clip has got different workflow now.         * ibuf acquired from clip is referenced by cache system and should         * be dereferenced after usage. */        freeibuf = ibuf;      }      else {        /* perhaps when loading future files... */        BLI_assert(0);        copy_v2_fl(image_aspect, 1.0f);      }      if (ibuf == NULL) {        continue;      }      if ((ibuf->rect == NULL && ibuf->rect_float == NULL) || ibuf->channels != 4) {        /* invalid image format */        if (freeibuf) {          IMB_freeImBuf(freeibuf);        }        if (releaseibuf) {          BKE_image_release_ibuf(ima, releaseibuf, lock);        }        continue;      }      if (ibuf->rect == NULL) {        IMB_rect_from_float(ibuf);      }      BLI_assert(rv3d->persp == RV3D_CAMOB);      {        if (do_camera_frame) {          rctf vb;          ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &vb, false);          x1 = vb.xmin;          y1 = vb.ymin;          x2 = vb.xmax;          y2 = vb.ymax;        }        else {          x1 = ar->winrct.xmin;          y1 = ar->winrct.ymin;          x2 = ar->winrct.xmax;          y2 = ar->winrct.ymax;        }        /* apply offset last - camera offset is different to offset in blender units */        /* so this has some sane way of working - this matches camera's shift _exactly_ */        {          const float max_dim = max_ff(x2 - x1, y2 - y1);          const float xof_scale = bgpic->offset[0] * max_dim;          const float yof_scale = bgpic->offset[1] * max_dim;
开发者ID:dfelinto,项目名称:blender,代码行数:67,


示例14: BKE_image_user_frame_calc

void ImageNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context){	/// Image output	OutputSocket *outputImage = this->getOutputSocket(0);	bNode *editorNode = this->getbNode();	Image *image = (Image *)editorNode->id;	ImageUser *imageuser = (ImageUser *)editorNode->storage;	int framenumber = context->getFramenumber();	int numberOfOutputs = this->getNumberOfOutputSockets();	BKE_image_user_frame_calc(imageuser, context->getFramenumber(), 0);	/* force a load, we assume iuser index will be set OK anyway */	if (image && image->type == IMA_TYPE_MULTILAYER) {		bool is_multilayer_ok = false;		ImBuf *ibuf = BKE_image_acquire_ibuf(image, imageuser, NULL);		if (image->rr) {			RenderLayer *rl = (RenderLayer *)BLI_findlink(&image->rr->layers, imageuser->layer);			if (rl) {				OutputSocket *socket;				int index;				is_multilayer_ok = true;				for (index = 0; index < numberOfOutputs; index++) {					NodeOperation *operation = NULL;					socket = this->getOutputSocket(index);					if (socket->isConnected() || index == 0) {						bNodeSocket *bnodeSocket = socket->getbNodeSocket();						NodeImageLayer *storage = (NodeImageLayer *)bnodeSocket->storage;						int passindex = storage->pass_index;												RenderPass *rpass = (RenderPass *)BLI_findlink(&rl->passes, passindex);						if (rpass) {							imageuser->pass = passindex;							switch (rpass->channels) {								case 1:									operation = doMultilayerCheck(graph, rl, image, imageuser, framenumber, index, passindex, COM_DT_VALUE);									break;								/* using image operations for both 3 and 4 channels (RGB and RGBA respectively) */								/* XXX any way to detect actual vector images? */								case 3:									operation = doMultilayerCheck(graph, rl, image, imageuser, framenumber, index, passindex, COM_DT_VECTOR);									break;								case 4:									operation = doMultilayerCheck(graph, rl, image, imageuser, framenumber, index, passindex, COM_DT_COLOR);									break;								default:									/* dummy operation is added below */									break;							}							if (index == 0 && operation) {								addPreviewOperation(graph, context, operation->getOutputSocket());							}						}					}					/* incase we can't load the layer */					if (operation == NULL) {						convertToOperations_invalid_index(graph, index);					}				}			}		}		BKE_image_release_ibuf(image, ibuf, NULL);		/* without this, multilayer that fail to load will crash blender [#32490] */		if (is_multilayer_ok == false) {			convertToOperations_invalid(graph, context);		}	}	else {		if (numberOfOutputs >  0) {			ImageOperation *operation = new ImageOperation();			if (outputImage->isConnected()) {				outputImage->relinkConnections(operation->getOutputSocket());			}			operation->setImage(image);			operation->setImageUser(imageuser);			operation->setFramenumber(framenumber);			graph->addOperation(operation);			addPreviewOperation(graph, context, operation->getOutputSocket());		}				if (numberOfOutputs > 1) {			OutputSocket *alphaImage = this->getOutputSocket(1);			if (alphaImage->isConnected()) {				ImageAlphaOperation *alphaOperation = new ImageAlphaOperation();				alphaOperation->setImage(image);				alphaOperation->setImageUser(imageuser);				alphaOperation->setFramenumber(framenumber);				alphaImage->relinkConnections(alphaOperation->getOutputSocket());				graph->addOperation(alphaOperation);			}		}		if (numberOfOutputs > 2) {			OutputSocket *depthImage = this->getOutputSocket(2);			if (depthImage->isConnected()) {				ImageDepthOperation *depthOperation = new ImageDepthOperation();				depthOperation->setImage(image);//.........这里部分代码省略.........
开发者ID:danielmarg,项目名称:blender-main,代码行数:101,


示例15: render_endjob

static void render_endjob(void *rjv){	RenderJob *rj = rjv;	/* this render may be used again by the sequencer without the active 'Render' where the callbacks	 * would be re-assigned. assign dummy callbacks to avoid referencing freed renderjobs bug [#24508] */	RE_InitRenderCB(rj->re);	if (rj->main != G.main)		BKE_main_free(rj->main);	/* else the frame will not update for the original value */	if (rj->anim && !(rj->scene->r.scemode & R_NO_FRAME_UPDATE)) {		/* possible this fails of loading new file while rendering */		if (G.main->wm.first) {			ED_update_for_newframe(G.main, rj->scene, 1);		}	}		/* XXX above function sets all tags in nodes */	ntreeCompositClearTags(rj->scene->nodetree);		/* potentially set by caller */	rj->scene->r.scemode &= ~R_NO_FRAME_UPDATE;		if (rj->srl) {		nodeUpdateID(rj->scene->nodetree, &rj->scene->id);		WM_main_add_notifier(NC_NODE | NA_EDITED, rj->scene);	}	if (rj->sa) {		render_image_restore_layer(rj);	}	/* XXX render stability hack */	G.is_rendering = false;	WM_main_add_notifier(NC_SCENE | ND_RENDER_RESULT, NULL);	/* Partial render result will always update display buffer	 * for first render layer only. This is nice because you'll	 * see render progress during rendering, but it ends up in	 * wrong display buffer shown after rendering.	 *	 * The code below will mark display buffer as invalid after	 * rendering in case multiple layers were rendered, which	 * ensures display buffer matches render layer after	 * rendering.	 *	 * Perhaps proper way would be to toggle active render	 * layer in image editor and job, so we always display	 * layer being currently rendered. But this is not so much	 * trivial at this moment, especially because of external	 * engine API, so lets use simple and robust way for now	 *                                          - sergey -	 */	if (rj->scene->r.layers.first != rj->scene->r.layers.last ||	    rj->image_outdated)	{		void *lock;		Image *ima = rj->image;		ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &rj->iuser, &lock);		if (ibuf)			ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;		BKE_image_release_ibuf(ima, ibuf, lock);	}	/* Finally unlock the user interface (if it was locked). */	if (rj->interface_locked) {		Scene *scene;		/* Interface was locked, so window manager couldn't have been changed		 * and using one from Global will unlock exactly the same manager as		 * was locked before running the job.		 */		WM_set_locked_interface(G.main->wm.first, false);		/* We've freed all the derived caches before rendering, which is		 * effectively the same as if we re-loaded the file.		 *		 * So let's not try being smart here and just reset all updated		 * scene layers and use generic DAG_on_visible_update.		 */		for (scene = G.main->scene.first; scene; scene = scene->id.next) {			scene->lay_updated = 0;		}		DAG_on_visible_update(G.main, false);	}}
开发者ID:GeniaPenksik,项目名称:blender,代码行数:91,


示例16: uiTemplateImage

void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, PointerRNA *userptr, int compact){#define MAX_INFO_LEN  128	PropertyRNA *prop;	PointerRNA imaptr;	RNAUpdateCb *cb;	Image *ima;	ImageUser *iuser;	Scene *scene = CTX_data_scene(C);	uiLayout *row, *split, *col;	uiBlock *block;	char str[MAX_INFO_LEN];	void *lock;	if (!ptr->data)		return;	prop = RNA_struct_find_property(ptr, propname);	if (!prop) {		printf("%s: property not found: %s.%s/n",		       __func__, RNA_struct_identifier(ptr->type), propname);		return;	}	if (RNA_property_type(prop) != PROP_POINTER) {		printf("%s: expected pointer property for %s.%s/n",		       __func__, RNA_struct_identifier(ptr->type), propname);		return;	}	block = uiLayoutGetBlock(layout);	imaptr = RNA_property_pointer_get(ptr, prop);	ima = imaptr.data;	iuser = userptr->data;	BKE_image_user_check_frame_calc(iuser, (int)scene->r.cfra, 0);	cb = MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb");	cb->ptr = *ptr;	cb->prop = prop;	cb->iuser = iuser;	uiLayoutSetContextPointer(layout, "edit_image", &imaptr);	uiLayoutSetContextPointer(layout, "edit_image_user", userptr);	if (!compact)		uiTemplateID(layout, C, ptr, propname, "IMAGE_OT_new", "IMAGE_OT_open", NULL);	if (ima) {		uiBlockSetNFunc(block, rna_update_cb, MEM_dupallocN(cb), NULL);		if (ima->source == IMA_SRC_VIEWER) {			ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, &lock);			image_info(scene, iuser, ima, ibuf, str, MAX_INFO_LEN);			BKE_image_release_ibuf(ima, ibuf, lock);			uiItemL(layout, ima->id.name + 2, ICON_NONE);			uiItemL(layout, str, ICON_NONE);			if (ima->type == IMA_TYPE_COMPOSITE) {				// XXX not working yet#if 0				iuser = ntree_get_active_iuser(scene->nodetree);				if (iuser) {					uiBlockBeginAlign(block);					uiDefIconTextBut(block, BUT, B_SIMA_RECORD, ICON_REC, "Record", 10, 120, 100, 20, 0, 0, 0, 0, 0, "");					uiDefIconTextBut(block, BUT, B_SIMA_PLAY, ICON_PLAY, "Play",    110, 120, 100, 20, 0, 0, 0, 0, 0, "");					but = uiDefBut(block, BUT, B_NOP, "Free Cache", 210, 120, 100, 20, 0, 0, 0, 0, 0, "");					uiButSetFunc(but, image_freecache_cb, ima, NULL);										if (iuser->frames)						BLI_snprintf(str, sizeof(str), "(%d) Frames:", iuser->framenr);					else strcpy(str, "Frames:");					uiBlockBeginAlign(block);					uiDefButI(block, NUM, imagechanged, str,        10, 90, 150, 20, &iuser->frames, 0.0, MAXFRAMEF, 0, 0, "Number of images of a movie to use");					uiDefButI(block, NUM, imagechanged, "StartFr:", 160, 90, 150, 20, &iuser->sfra, 1.0, MAXFRAMEF, 0, 0, "Global starting frame of the movie");				}#endif			}			else if (ima->type == IMA_TYPE_R_RESULT) {				/* browse layer/passes */				RenderResult *rr;				/* use BKE_image_acquire_renderresult  so we get the correct slot in the menu */				rr = BKE_image_acquire_renderresult(scene, ima);				uiblock_layer_pass_arrow_buttons(layout, rr, iuser, &ima->render_slot);				BKE_image_release_renderresult(scene, ima);			}		}		else {			uiItemR(layout, &imaptr, "source", 0, NULL, ICON_NONE);			if (ima->source != IMA_SRC_GENERATED) {				row = uiLayoutRow(layout, TRUE);				if (ima->packedfile)					uiItemO(row, "", ICON_PACKAGE, "image.unpack");				else//.........这里部分代码省略.........
开发者ID:Eibriel,项目名称:kiriblender,代码行数:101,


示例17: paint_sample_color

/* used for both 3d view and image window */void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_proj, bool use_palette){	Scene *scene = CTX_data_scene(C);	Paint *paint = BKE_paint_get_active_from_context(C);	Palette *palette = BKE_paint_palette(paint);	PaletteColor *color;	Brush *br = BKE_paint_brush(BKE_paint_get_active_from_context(C));	unsigned int col;	const unsigned char *cp;	CLAMP(x, 0, ar->winx);	CLAMP(y, 0, ar->winy);		if (use_palette) {		if (!palette) {			palette = BKE_palette_add(CTX_data_main(C), "Palette");			BKE_paint_palette_set(paint, palette);		}		color = BKE_palette_color_add(palette);	}	if (CTX_wm_view3d(C) && texpaint_proj) {		/* first try getting a colour directly from the mesh faces if possible */		Object *ob = OBACT;		bool sample_success = false;		if (ob) {			DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);			ViewContext vc;			const int mval[2] = {x, y};			unsigned int faceindex;			unsigned int totface = dm->getNumTessFaces(dm);			MTFace *dm_mtface = dm->getTessFaceDataArray(dm, CD_MTFACE);			DM_update_materials(dm, ob);			if (dm_mtface) {				view3d_set_viewcontext(C, &vc);				view3d_operator_needs_opengl(C);				if (imapaint_pick_face(&vc, mval, &faceindex, totface)) {					Image *image = imapaint_face_image(dm, faceindex);					ImBuf *ibuf = BKE_image_acquire_ibuf(image, NULL, NULL);					if (ibuf && ibuf->rect) {						float uv[2];						float u, v;						imapaint_pick_uv(scene, ob, faceindex, mval, uv);						sample_success = true;						u = fmodf(uv[0], 1.0f);						v = fmodf(uv[1], 1.0f);						if (u < 0.0f) u += 1.0f;						if (v < 0.0f) v += 1.0f;						u = u * ibuf->x - 0.5f;						v = v * ibuf->y - 0.5f;						if (ibuf->rect_float) {							float rgba_f[4];							bilinear_interpolation_color_wrap(ibuf, NULL, rgba_f, u, v);							straight_to_premul_v4(rgba_f);							if (use_palette) {								linearrgb_to_srgb_v3_v3(color->rgb, rgba_f);							}							else {								linearrgb_to_srgb_v3_v3(rgba_f, rgba_f);								BKE_brush_color_set(scene, br, rgba_f);							}						}						else {							unsigned char rgba[4];							bilinear_interpolation_color_wrap(ibuf, rgba, NULL, u, v);							if (use_palette) {								rgb_uchar_to_float(color->rgb, rgba);							}							else {								float rgba_f[3];								rgb_uchar_to_float(rgba_f, rgba);								BKE_brush_color_set(scene, br, rgba_f);							}						}					}					BKE_image_release_ibuf(image, ibuf, NULL);				}			}			dm->release(dm);		}		if (!sample_success) {			glReadBuffer(GL_FRONT);			glReadPixels(x + ar->winrct.xmin, y + ar->winrct.ymin, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &col);			glReadBuffer(GL_BACK);//.........这里部分代码省略.........
开发者ID:sftd,项目名称:blender,代码行数:101,


示例18: icon_preview_startjob

static void icon_preview_startjob(void *customdata, short *stop, short *do_update){	ShaderPreview *sp = customdata;	if (sp->pr_method == PR_ICON_DEFERRED) {		PreviewImage *prv = sp->owner;		ImBuf *thumb;		char *deferred_data = PRV_DEFERRED_DATA(prv);		int source =  deferred_data[0];		char *path = &deferred_data[1];//		printf("generating deferred %d×%d preview for %s/n", sp->sizex, sp->sizey, path);		thumb = IMB_thumb_manage(path, THB_LARGE, source);		if (thumb) {			/* PreviewImage assumes premultiplied alhpa... */			IMB_premultiply_alpha(thumb);			icon_copy_rect(thumb, sp->sizex, sp->sizey, sp->pr_rect);			IMB_freeImBuf(thumb);		}	}	else {		ID *id = sp->id;		short idtype = GS(id->name);		if (idtype == ID_IM) {			Image *ima = (Image *)id;			ImBuf *ibuf = NULL;			ImageUser iuser = {NULL};			/* ima->ok is zero when Image cannot load */			if (ima == NULL || ima->ok == 0)				return;			/* setup dummy image user */			iuser.ok = iuser.framenr = 1;			iuser.scene = sp->scene;			/* elubie: this needs to be changed: here image is always loaded if not			 * already there. Very expensive for large images. Need to find a way to			 * only get existing ibuf */			ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL);			if (ibuf == NULL || ibuf->rect == NULL) {				BKE_image_release_ibuf(ima, ibuf, NULL);				return;			}			icon_copy_rect(ibuf, sp->sizex, sp->sizey, sp->pr_rect);			*do_update = true;			BKE_image_release_ibuf(ima, ibuf, NULL);		}		else if (idtype == ID_BR) {			Brush *br = (Brush *)id;			br->icon_imbuf = get_brush_icon(br);			memset(sp->pr_rect, 0x88, sp->sizex * sp->sizey * sizeof(unsigned int));			if (!(br->icon_imbuf) || !(br->icon_imbuf->rect))				return;			icon_copy_rect(br->icon_imbuf, sp->sizex, sp->sizey, sp->pr_rect);			*do_update = true;		}		else {			/* re-use shader job */			shader_preview_startjob(customdata, stop, do_update);			/* world is rendered with alpha=0, so it wasn't displayed			 * this could be render option for sky to, for later */			if (idtype == ID_WO) {				set_alpha((char *)sp->pr_rect, sp->sizex, sp->sizey, 255);			}			else if (idtype == ID_MA) {				Material *ma = (Material *)id;				if (ma->material_type == MA_TYPE_HALO)					set_alpha((char *)sp->pr_rect, sp->sizex, sp->sizey, 255);			}		}	}}
开发者ID:flair2005,项目名称:mechanical-blender,代码行数:87,


示例19: node_composit_exec_splitviewer

static void node_composit_exec_splitviewer(void *data, bNode *node, bNodeStack **in, bNodeStack **UNUSED(out)){	/* image assigned to output */	/* stack order input sockets: image image */		if(in[0]->data==NULL || in[1]->data==NULL)		return;		if(node->id && (node->flag & NODE_DO_OUTPUT)) {	/* only one works on out */		Image *ima= (Image *)node->id;		RenderData *rd= data;		ImBuf *ibuf;		CompBuf *cbuf, *buf1, *buf2, *mask;		int x, y;		float offset;		void *lock;				buf1= typecheck_compbuf(in[0]->data, CB_RGBA);		buf2= typecheck_compbuf(in[1]->data, CB_RGBA);				BKE_image_user_calc_frame(node->storage, rd->cfra, 0);				/* always returns for viewer image, but we check nevertheless */		ibuf= BKE_image_acquire_ibuf(ima, node->storage, &lock);		if(ibuf==NULL) {			printf("node_composit_exec_viewer error/n");			BKE_image_release_ibuf(ima, lock);			return;		}				/* free all in ibuf */		imb_freerectImBuf(ibuf);		imb_freerectfloatImBuf(ibuf);		IMB_freezbuffloatImBuf(ibuf);				/* make ibuf, and connect to ima */		ibuf->x= buf1->x;		ibuf->y= buf1->y;		imb_addrectfloatImBuf(ibuf);				ima->ok= IMA_OK_LOADED;		/* output buf */		cbuf= alloc_compbuf(buf1->x, buf1->y, CB_RGBA, 0);	/* no alloc*/		cbuf->rect= ibuf->rect_float;				/* mask buf */		mask= alloc_compbuf(buf1->x, buf1->y, CB_VAL, 1);						/* Check which offset mode is selected and limit offset if needed */		if(node->custom2 == 0) {			offset = buf1->x / 100.0f * node->custom1;			CLAMP(offset, 0, buf1->x);		}		else {			offset = buf1->y / 100.0f * node->custom1;			CLAMP(offset, 0, buf1->y);		}				if(node->custom2 == 0) {			for(y=0; y<buf1->y; y++) {				float *fac= mask->rect + y*buf1->x;				for(x=offset; x>0; x--, fac++)					*fac= 1.0f;			}		}		else {			for(y=0; y<offset; y++) {				float *fac= mask->rect + y*buf1->x;				for(x=buf1->x; x>0; x--, fac++)					*fac= 1.0f;			}		}				composit3_pixel_processor(node, cbuf, buf1, in[0]->vec, buf2, in[1]->vec, mask, NULL, do_copy_split_rgba, CB_RGBA, CB_RGBA, CB_VAL);				BKE_image_release_ibuf(ima, lock);				generate_preview(data, node, cbuf);		free_compbuf(cbuf);		free_compbuf(mask);				if(in[0]->data != buf1) 			free_compbuf(buf1);		if(in[1]->data != buf2) 			free_compbuf(buf2);	}}
开发者ID:mik0001,项目名称:Blender,代码行数:89,


示例20: BKE_image_release_ibuf

void BaseImageOperation::deinitExecution(){	this->m_imageFloatBuffer = NULL;	this->m_imageByteBuffer = NULL;	BKE_image_release_ibuf(this->m_image, this->m_buffer, NULL);}
开发者ID:Eibriel,项目名称:kiriblender,代码行数:6,


示例21: do_multires_bake

static void do_multires_bake(MultiresBakeRender *bkr, Image *ima, int require_tangent, MPassKnownData passKnownData,                             MInitBakeData initBakeData, MApplyBakeData applyBakeData, MFreeBakeData freeBakeData){	DerivedMesh *dm = bkr->lores_dm;	const int lvl = bkr->lvl;	const int tot_face = dm->getNumTessFaces(dm);	if (tot_face > 0) {		MultiresBakeThread *handles;		MultiresBakeQueue queue;		ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);		MVert *mvert = dm->getVertArray(dm);		MFace *mface = dm->getTessFaceArray(dm);		MTFace *mtface = dm->getTessFaceDataArray(dm, CD_MTFACE);		float *precomputed_normals = dm->getTessFaceDataArray(dm, CD_NORMAL);		float *pvtangent = NULL;		ListBase threads;		int i, tot_thread = bkr->threads > 0 ? bkr->threads : BLI_system_thread_count();		void *bake_data = NULL;		if (require_tangent) {			if (CustomData_get_layer_index(&dm->faceData, CD_TANGENT) == -1)				DM_add_tangent_layer(dm);			pvtangent = DM_get_tessface_data_layer(dm, CD_TANGENT);		}		/* all threads shares the same custom bake data */		if (initBakeData)			bake_data = initBakeData(bkr, ima);		if (tot_thread > 1)			BLI_init_threads(&threads, do_multires_bake_thread, tot_thread);		handles = MEM_callocN(tot_thread * sizeof(MultiresBakeThread), "do_multires_bake handles");		/* faces queue */		queue.cur_face = 0;		queue.tot_face = tot_face;		BLI_spin_init(&queue.spin);		/* fill in threads handles */		for (i = 0; i < tot_thread; i++) {			MultiresBakeThread *handle = &handles[i];			handle->bkr = bkr;			handle->image = ima;			handle->queue = &queue;			handle->data.mface = mface;			handle->data.mvert = mvert;			handle->data.mtface = mtface;			handle->data.pvtangent = pvtangent;			handle->data.precomputed_normals = precomputed_normals;  /* don't strictly need this */			handle->data.w = ibuf->x;			handle->data.h = ibuf->y;			handle->data.lores_dm = dm;			handle->data.hires_dm = bkr->hires_dm;			handle->data.lvl = lvl;			handle->data.pass_data = passKnownData;			handle->data.bake_data = bake_data;			handle->data.ibuf = ibuf;			init_bake_rast(&handle->bake_rast, ibuf, &handle->data, flush_pixel);			if (tot_thread > 1)				BLI_insert_thread(&threads, handle);		}		/* run threads */		if (tot_thread > 1)			BLI_end_threads(&threads);		else			do_multires_bake_thread(&handles[0]);		BLI_spin_end(&queue.spin);		/* finalize baking */		if (applyBakeData)			applyBakeData(bake_data);		if (freeBakeData)			freeBakeData(bake_data);		BKE_image_release_ibuf(ima, ibuf, NULL);	}}
开发者ID:danielmarg,项目名称:blender-main,代码行数:90,


示例22: render_endjob

static void render_endjob(void *rjv){	RenderJob *rj = rjv;	/* this render may be used again by the sequencer without the active 'Render' where the callbacks	 * would be re-assigned. assign dummy callbacks to avoid referencing freed renderjobs bug [#24508] */	RE_InitRenderCB(rj->re);	if (rj->main != G.main)		free_main(rj->main);	/* else the frame will not update for the original value */	if (rj->anim && !(rj->scene->r.scemode & R_NO_FRAME_UPDATE)) {		/* possible this fails of loading new file while rendering */		if (G.main->wm.first) {			ED_update_for_newframe(G.main, rj->scene, 1);		}	}		/* XXX above function sets all tags in nodes */	ntreeCompositClearTags(rj->scene->nodetree);		/* potentially set by caller */	rj->scene->r.scemode &= ~R_NO_FRAME_UPDATE;		if (rj->srl) {		nodeUpdateID(rj->scene->nodetree, &rj->scene->id);		WM_main_add_notifier(NC_NODE | NA_EDITED, rj->scene);	}	/* XXX render stability hack */	G.is_rendering = FALSE;	WM_main_add_notifier(NC_SCENE | ND_RENDER_RESULT, NULL);	/* Partial render result will always update display buffer	 * for first render layer only. This is nice because you'll	 * see render progress during rendering, but it ends up in	 * wrong display buffer shown after rendering.	 *	 * The code below will mark display buffer as invalid after	 * rendering in case multiple layers were rendered, which	 * ensures display buffer matches render layer after	 * rendering.	 *	 * Perhaps proper way would be to toggle active render	 * layer in image editor and job, so we always display	 * layer being currently rendered. But this is not so much	 * trivial at this moment, especially because of external	 * engine API, so lets use simple and robust way for now	 *                                          - sergey -	 */	if (rj->scene->r.layers.first != rj->scene->r.layers.last) {		void *lock;		Image *ima = rj->image;		ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &rj->iuser, &lock);		if (ibuf)			ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;		BKE_image_release_ibuf(ima, ibuf, lock);	}}
开发者ID:JasonWilkins,项目名称:blender-wayland,代码行数:62,


示例23: bake_object_check

/* if all is good tag image and return true */static bool bake_object_check(Object *ob, ReportList *reports){	Image *image;	void *lock;	int i;	if (ob->type != OB_MESH) {		BKE_reportf(reports, RPT_ERROR, "Object /"%s/" is not a mesh", ob->id.name + 2);		return false;	}	else {		Mesh *me = (Mesh *)ob->data;		if (CustomData_get_active_layer_index(&me->ldata, CD_MLOOPUV) == -1) {			BKE_reportf(reports, RPT_ERROR,			            "No active UV layer found in the object /"%s/"", ob->id.name + 2);			return false;		}	}	for (i = 0; i < ob->totcol; i++) {		bNodeTree *ntree = NULL;		bNode *node = NULL;		ED_object_get_active_image(ob, i + 1, &image, NULL, &node, &ntree);		if (image) {			ImBuf *ibuf;			if (node) {				if (BKE_node_is_connected_to_output(ntree, node)) {					/* we don't return false since this may be a false positive					 * this can't be RPT_ERROR though, otherwise it prevents					 * multiple highpoly objects to be baked at once */					BKE_reportf(reports, RPT_INFO,					            "Circular dependency for image /"%s/" from object /"%s/"",					            image->id.name + 2, ob->id.name + 2);				}			}			ibuf = BKE_image_acquire_ibuf(image, NULL, &lock);			if (ibuf) {				BKE_image_release_ibuf(image, ibuf, lock);			}			else {				BKE_reportf(reports, RPT_ERROR,				            "Uninitialized image /"%s/" from object /"%s/"",				            image->id.name + 2, ob->id.name + 2);				BKE_image_release_ibuf(image, ibuf, lock);				return false;			}		}		else {			if (ob->mat[i]) {				BKE_reportf(reports, RPT_ERROR,				            "No active image found in material /"%s/" (%d) for object /"%s/"",				            ob->mat[i]->id.name + 2, i, ob->id.name + 2);			}			else if (((Mesh *) ob->data)->mat[i]) {				BKE_reportf(reports, RPT_ERROR,				            "No active image found in material /"%s/" (%d) for object /"%s/"",				            ((Mesh *) ob->data)->mat[i]->id.name + 2, i, ob->id.name + 2);			}			else {				BKE_reportf(reports, RPT_ERROR,				            "No active image found in material (%d) for object /"%s/"",				            i, ob->id.name + 2);			}			return false;		}		image->id.tag |= LIB_TAG_DOIT;	}	return true;}
开发者ID:Passtechsoft,项目名称:TPEAlpGen,代码行数:77,



注:本文中的BKE_image_release_ibuf函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ BKE_image_signal函数代码示例
C++ BJAM_FREE函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。