Пример #1
0
static void icon_draw_rect(float x, float y, int w, int h, float UNUSED(aspect), int rw, int rh, unsigned int *rect, float alpha, float *rgb, short is_preview)
{
	ImBuf *ima= NULL;

	/* sanity check */
	if(w<=0 || h<=0 || w>2000 || h>2000) {
		printf("%s: icons are %i x %i pixels?\n", __func__, w, h);
		BLI_assert(!"invalid icon size");
		return;
	}

	/* modulate color */
	if(alpha != 1.0f)
		glPixelTransferf(GL_ALPHA_SCALE, alpha);

	if(rgb) {
		glPixelTransferf(GL_RED_SCALE, rgb[0]);
		glPixelTransferf(GL_GREEN_SCALE, rgb[1]);
		glPixelTransferf(GL_BLUE_SCALE, rgb[2]);
	}

	/* rect contains image in 'rendersize', we only scale if needed */
	if(rw!=w && rh!=h) {
		/* first allocate imbuf for scaling and copy preview into it */
		ima = IMB_allocImBuf(rw, rh, 32, IB_rect);
		memcpy(ima->rect, rect, rw*rh*sizeof(unsigned int));	
		IMB_scaleImBuf(ima, w, h); /* scale it */
		rect= ima->rect;
	}

	/* draw */
	if(is_preview) {
		glaDrawPixelsSafe(x, y, w, h, w, GL_RGBA, GL_UNSIGNED_BYTE, rect);
	}
	else {
		glRasterPos2f(x, y);
		glDrawPixels(w, h, GL_RGBA, GL_UNSIGNED_BYTE, rect);
	}

	if(ima)
		IMB_freeImBuf(ima);

	/* restore color */
	if(alpha != 0.0f)
		glPixelTransferf(GL_ALPHA_SCALE, 1.0f);
	
	if(rgb) {
		glPixelTransferf(GL_RED_SCALE, 1.0f);
		glPixelTransferf(GL_GREEN_SCALE, 1.0f);
		glPixelTransferf(GL_BLUE_SCALE, 1.0f);
	}
}
Пример #2
0
ImBuf *BKE_sequence_modifier_apply_stack(const SeqRenderData *context, Sequence *seq, ImBuf *ibuf, int cfra)
{
	SequenceModifierData *smd;
	ImBuf *processed_ibuf = ibuf;

	if (seq->modifiers.first && (seq->flag & SEQ_USE_LINEAR_MODIFIERS)) {
		processed_ibuf = IMB_dupImBuf(ibuf);
		BKE_sequencer_imbuf_from_sequencer_space(context->scene, processed_ibuf);
	}

	for (smd = seq->modifiers.first; smd; smd = smd->next) {
		const SequenceModifierTypeInfo *smti = BKE_sequence_modifier_type_info_get(smd->type);

		/* could happen if modifier is being removed or not exists in current version of blender */
		if (!smti)
			continue;

		/* modifier is muted, do nothing */
		if (smd->flag & SEQUENCE_MODIFIER_MUTE)
			continue;

		if (smti->apply) {
			int frame_offset;
			if (smd->mask_time == SEQUENCE_MASK_TIME_RELATIVE) {
				frame_offset = seq->start;
			}
			else /*if (smd->mask_time == SEQUENCE_MASK_TIME_ABSOLUTE)*/ {
				frame_offset = 0;
			}

			ImBuf *mask = modifier_mask_get(smd,
			                                context,
			                                cfra,
			                                frame_offset,
			                                ibuf->rect_float != NULL);

			if (processed_ibuf == ibuf)
				processed_ibuf = IMB_dupImBuf(ibuf);

			smti->apply(smd, processed_ibuf, mask);

			if (mask)
				IMB_freeImBuf(mask);
		}
	}

	if (seq->modifiers.first && (seq->flag & SEQ_USE_LINEAR_MODIFIERS)) {
		BKE_sequencer_imbuf_to_sequencer_space(context->scene, processed_ibuf, false);
	}

	return processed_ibuf;
}
Пример #3
0
void BKE_brush_painter_require_imbuf(BrushPainter *painter, short flt, short texonly, int size)
{
	if ((painter->cache.flt != flt) || (painter->cache.size != size) ||
	    ((painter->cache.texonly != texonly) && texonly))
	{
		if (painter->cache.ibuf) IMB_freeImBuf(painter->cache.ibuf);
		if (painter->cache.maskibuf) IMB_freeImBuf(painter->cache.maskibuf);
		painter->cache.ibuf = painter->cache.maskibuf = NULL;
		painter->cache.lastsize = -1; /* force ibuf create in refresh */
	}

	if (painter->cache.flt != flt) {
		if (painter->cache.texibuf) IMB_freeImBuf(painter->cache.texibuf);
		painter->cache.texibuf = NULL;
		painter->cache.lastsize = -1; /* force ibuf create in refresh */
	}

	painter->cache.size = size;
	painter->cache.flt = flt;
	painter->cache.texonly = texonly;
	painter->cache.enabled = 1;
}
Пример #4
0
    void my_free_envmapdata(EnvMap *env)
    {
        unsigned int part;

        for(part=0; part<6; part++) {
            ImBuf *ibuf= env->cube[part];
            if(ibuf) {
                IMB_freeImBuf(ibuf);
                env->cube[part]= NULL;
            }
        }
        env->ok= 0;
    }
Пример #5
0
struct ImBuf * IMB_anim_previewframe(struct anim * anim) {
	struct ImBuf * ibuf = NULL;
	int position = 0;
	
	ibuf = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE);
	if (ibuf) {
		IMB_freeImBuf(ibuf);
		position = anim->duration / 2;
		ibuf = IMB_anim_absolute(anim, position, IMB_TC_NONE,
					 IMB_PROXY_NONE);
	}
	return ibuf;
}
Пример #6
0
static void free_buffers(MovieClip *clip)
{
	if (clip->cache) {
		IMB_moviecache_free(clip->cache->moviecache);

		if (clip->cache->postprocessed.ibuf)
			IMB_freeImBuf(clip->cache->postprocessed.ibuf);

		if (clip->cache->stabilized.ibuf)
			IMB_freeImBuf(clip->cache->stabilized.ibuf);

		MEM_freeN(clip->cache);
		clip->cache = NULL;
	}

	if (clip->anim) {
		IMB_free_anim(clip->anim);
		clip->anim = NULL;
	}

	BKE_free_animdata((ID *) clip);
}
Пример #7
0
static ImBuf *put_postprocessed_frame_to_cache(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf,
                                               int flag, int postprocess_flag)
{
	MovieClipCache *cache = clip->cache;
	MovieTrackingCamera *camera = &clip->tracking.camera;
	ImBuf *postproc_ibuf = NULL;

	cache->postprocessed.framenr = user->framenr;
	cache->postprocessed.flag = postprocess_flag;

	if (flag & MCLIP_USE_PROXY) {
		cache->postprocessed.proxy = rendersize_to_proxy(user, flag);
		cache->postprocessed.render_flag = user->render_flag;
	}
	else {
		cache->postprocessed.proxy = IMB_PROXY_NONE;
		cache->postprocessed.render_flag = 0;
	}

	if (need_undistortion_postprocess(user)) {
		copy_v2_v2(cache->postprocessed.principal, camera->principal);
		copy_v3_v3(&cache->postprocessed.k1, &camera->k1);
		cache->postprocessed.undistortion_used = TRUE;
		postproc_ibuf = get_undistorted_ibuf(clip, NULL, ibuf);
	}
	else {
		cache->postprocessed.undistortion_used = FALSE;
	}

	if (postprocess_flag) {
		int disable_red   = postprocess_flag & MOVIECLIP_DISABLE_RED,
		    disable_green = postprocess_flag & MOVIECLIP_DISABLE_GREEN,
		    disable_blue  = postprocess_flag & MOVIECLIP_DISABLE_BLUE,
		    grayscale     = postprocess_flag & MOVIECLIP_PREVIEW_GRAYSCALE;

		if (!postproc_ibuf)
			postproc_ibuf = IMB_dupImBuf(ibuf);

		if (disable_red || disable_green || disable_blue || grayscale)
			BKE_tracking_disable_channels(postproc_ibuf, disable_red, disable_green, disable_blue, 1);
	}

	IMB_refImBuf(postproc_ibuf);

	if (cache->postprocessed.ibuf)
		IMB_freeImBuf(cache->postprocessed.ibuf);

	cache->postprocessed.ibuf = postproc_ibuf;

	return postproc_ibuf;
}
Пример #8
0
ImBuf *IMB_makeSingleUser(ImBuf *ibuf)
{
    ImBuf *rval;

    if (!ibuf || ibuf->refcounter == 0) {
        return ibuf;
    }

    rval = IMB_dupImBuf(ibuf);

    IMB_freeImBuf(ibuf);

    return rval;
}
Пример #9
0
void BKE_sequencer_preprocessed_cache_cleanup(void)
{
	SeqPreprocessCacheElem *elem;

	if (!preprocess_cache)
		return;

	for (elem = preprocess_cache->elems.first; elem; elem = elem->next) {
		IMB_freeImBuf(elem->ibuf);
	}
	BLI_freelistN(&preprocess_cache->elems);

	BLI_listbase_clear(&preprocess_cache->elems);
}
Пример #10
0
static ImBuf *sequencer_make_scope(Scene *scene, ImBuf *ibuf, ImBuf *(*make_scope_cb) (ImBuf *ibuf))
{
	ImBuf *display_ibuf = IMB_dupImBuf(ibuf);
	ImBuf *scope;
	
	IMB_colormanagement_imbuf_make_display_space(display_ibuf, &scene->view_settings,
		                                             &scene->display_settings);

	scope = make_scope_cb(display_ibuf);

	IMB_freeImBuf(display_ibuf);

	return scope;
}
Пример #11
0
static void IMB_seq_cache_destructor(void * p)
{
	seqCacheEntry* e = (seqCacheEntry*) p;
	
	if (e && e->ibuf) {
		/* fprintf(stderr, "Removing: %p, cnt: %d\n", e->ibuf,
		   e->ibuf->refcounter); */
		IMB_freeImBuf(e->ibuf);
		ibufs_rem++;

		e->ibuf = NULL;
		e->c_handle = NULL;
	}
}
Пример #12
0
static void icon_copy_rect(ImBuf *ibuf, unsigned int w, unsigned int h, unsigned int *rect)
{
	struct ImBuf *ima;
	unsigned int *drect, *srect;
	float scaledx, scaledy;
	short ex, ey, dx, dy;

	/* paranoia test */
	if(ibuf==NULL || (ibuf->rect==NULL && ibuf->rect_float==NULL))
		return;
	
	/* waste of cpu cyles... but the imbuf API has no other way to scale fast (ton) */
	ima = IMB_dupImBuf(ibuf);
	
	if (!ima) 
		return;
	
	if (ima->x > ima->y) {
		scaledx = (float)w;
		scaledy =  ( (float)ima->y/(float)ima->x )*(float)w;
	}
	else {			
		scaledx =  ( (float)ima->x/(float)ima->y )*(float)h;
		scaledy = (float)h;
	}
	
	ex = (short)scaledx;
	ey = (short)scaledy;
	
	dx = (w - ex) / 2;
	dy = (h - ey) / 2;
	
	IMB_scalefastImBuf(ima, ex, ey);
	
	/* if needed, convert to 32 bits */
	if(ima->rect==NULL)
		IMB_rect_from_float(ima);

	srect = ima->rect;
	drect = rect;

	drect+= dy*w+dx;
	for (;ey > 0; ey--){		
		memcpy(drect,srect, ex * sizeof(int));
		drect += w;
		srect += ima->x;
	}

	IMB_freeImBuf(ima);
}
Пример #13
0
void BKE_free_ocean_cache(struct OceanCache *och)
{
	int i, f = 0;

	if (!och) return;

	if (och->ibufs_disp) {
		for (i = och->start, f = 0; i <= och->end; i++, f++) {
			if (och->ibufs_disp[f]) {
				IMB_freeImBuf(och->ibufs_disp[f]);
			}
		}
		MEM_freeN(och->ibufs_disp);
	}

	if (och->ibufs_foam) {
		for (i = och->start, f = 0; i <= och->end; i++, f++) {
			if (och->ibufs_foam[f]) {
				IMB_freeImBuf(och->ibufs_foam[f]);
			}
		}
		MEM_freeN(och->ibufs_foam);
	}

	if (och->ibufs_norm) {
		for (i = och->start, f = 0; i <= och->end; i++, f++) {
			if (och->ibufs_norm[f]) {
				IMB_freeImBuf(och->ibufs_norm[f]);
			}
		}
		MEM_freeN(och->ibufs_norm);
	}

	if (och->time)
		MEM_freeN(och->time);
	MEM_freeN(och);
}
Пример #14
0
ImBuf *BKE_movieclip_get_stable_ibuf(MovieClip *clip, MovieClipUser *user, float loc[2], float *scale, float *angle,
                                     int postprocess_flag)
{
	ImBuf *ibuf, *stableibuf = NULL;
	int framenr = user->framenr;

	ibuf = BKE_movieclip_get_postprocessed_ibuf(clip, user, postprocess_flag);

	if (!ibuf)
		return NULL;

	if (clip->tracking.stabilization.flag & TRACKING_2D_STABILIZATION) {
		MovieClipCache *cache = clip->cache;

		stableibuf = get_stable_cached_frame(clip, user, ibuf, framenr, postprocess_flag);

		if (!stableibuf)
			stableibuf = put_stabilized_frame_to_cache(clip, user, ibuf, framenr, postprocess_flag);

		if (loc)
			copy_v2_v2(loc, cache->stabilized.loc);

		if (scale)
			*scale = cache->stabilized.scale;

		if (angle)
			*angle = cache->stabilized.angle;
	}
	else {
		if (loc)
			zero_v2(loc);

		if (scale)
			*scale = 1.0f;

		if (angle)
			*angle = 0.0f;

		stableibuf = ibuf;
	}

	if (stableibuf != ibuf) {
		IMB_freeImBuf(ibuf);
		ibuf = stableibuf;
	}

	return ibuf;

}
Пример #15
0
/** Handle deferred (lazy) loading/generation of preview image, if needed.
 * For now, only used with file thumbnails. */
void BKE_previewimg_ensure(PreviewImage *prv, const int size)
{
	if (prv->use_deferred) {
		const bool do_icon = ((size == ICON_SIZE_ICON) && !prv->rect[ICON_SIZE_ICON]);
		const bool do_preview = ((size == ICON_SIZE_PREVIEW) && !prv->rect[ICON_SIZE_PREVIEW]);

		if (do_icon || do_preview) {
			ImBuf *thumb;
			char *prv_deferred_data = PRV_DEFERRED_DATA(prv);
			int source =  prv_deferred_data[0];
			char *path = &prv_deferred_data[1];
			int icon_w, icon_h;

			thumb = IMB_thumb_manage(path, THB_LARGE, source);

			if (thumb) {
				/* PreviewImage assumes premultiplied alhpa... */
				IMB_premultiply_alpha(thumb);

				if (do_preview) {
					prv->w[ICON_SIZE_PREVIEW] = thumb->x;
					prv->h[ICON_SIZE_PREVIEW] = thumb->y;
					prv->rect[ICON_SIZE_PREVIEW] = MEM_dupallocN(thumb->rect);
					prv->flag[ICON_SIZE_PREVIEW] &= ~(PRV_CHANGED | PRV_USER_EDITED);
				}
				if (do_icon) {
					if (thumb->x > thumb->y) {
						icon_w = ICON_RENDER_DEFAULT_HEIGHT;
						icon_h = (thumb->y * icon_w) / thumb->x + 1;
					}
					else if (thumb->x < thumb->y) {
						icon_h = ICON_RENDER_DEFAULT_HEIGHT;
						icon_w = (thumb->x * icon_h) / thumb->y + 1;
					}
					else {
						icon_w = icon_h = ICON_RENDER_DEFAULT_HEIGHT;
					}

					IMB_scaleImBuf(thumb, icon_w, icon_h);
					prv->w[ICON_SIZE_ICON] = icon_w;
					prv->h[ICON_SIZE_ICON] = icon_h;
					prv->rect[ICON_SIZE_ICON] = MEM_dupallocN(thumb->rect);
					prv->flag[ICON_SIZE_ICON] &= ~(PRV_CHANGED | PRV_USER_EDITED);
				}
				IMB_freeImBuf(thumb);
			}
		}
	}
}
Пример #16
0
/* not brush itself */
void BKE_brush_free(Brush *brush)
{
	if (brush->mtex.tex)
		brush->mtex.tex->id.us--;

	if (brush->mask_mtex.tex)
		brush->mask_mtex.tex->id.us--;

	if (brush->icon_imbuf)
		IMB_freeImBuf(brush->icon_imbuf);

	BKE_previewimg_free(&(brush->preview));

	curvemapping_free(brush->curve);
}
Пример #17
0
ImBuf *IMB_allocImBuf(unsigned int x, unsigned int y, uchar planes, unsigned int flags)
{
	ImBuf *ibuf;

	ibuf = MEM_mallocN(sizeof(ImBuf), "ImBuf_struct");

	if (ibuf) {
		if (!IMB_initImBuf(ibuf, x, y, planes, flags)) {
			IMB_freeImBuf(ibuf);
			return NULL;
		}
	}

	return (ibuf);
}
Пример #18
0
void imb_freemipmapImBuf(ImBuf *ibuf)
{
	int a;

	/* Do not trust ibuf->miptot, in some cases IMB_remakemipmap can leave unfreed unused levels,
	 * leading to memory leaks... */
	for (a = 0; a < IMB_MIPMAP_LEVELS; a++) {
		if (ibuf->mipmap[a] != NULL) {
			IMB_freeImBuf(ibuf->mipmap[a]);
			ibuf->mipmap[a] = NULL;
		}
	}

	ibuf->miptot = 0;
}
Пример #19
0
static void brush_painter_2d_require_imbuf(BrushPainter *painter, bool use_float, bool use_color_correction, bool use_masking)
{
    Brush *brush = painter->brush;

    if ((painter->cache.use_float != use_float)) {
        if (painter->cache.ibuf) IMB_freeImBuf(painter->cache.ibuf);
        if (painter->cache.mask) MEM_freeN(painter->cache.mask);
        painter->cache.ibuf = NULL;
        painter->cache.mask = NULL;
        painter->cache.lastsize = -1; /* force ibuf create in refresh */
    }

    if (painter->cache.use_float != use_float) {
        if (painter->cache.texibuf) IMB_freeImBuf(painter->cache.texibuf);
        painter->cache.texibuf = NULL;
        painter->cache.lastsize = -1; /* force ibuf create in refresh */
    }

    painter->cache.use_float = use_float;
    painter->cache.use_color_correction = use_float && use_color_correction;
    painter->cache.use_masking = use_masking;
    painter->cache.is_texbrush = (brush->mtex.tex && brush->imagepaint_tool == PAINT_TOOL_DRAW) ? true : false;
    painter->cache.is_maskbrush = (brush->mask_mtex.tex) ? true : false;
}
Пример #20
0
/* Returns color in the display space, matching ED_space_image_color_sample(). */
bool ED_space_clip_color_sample(Scene *scene, SpaceClip *sc, ARegion *ar, int mval[2], float r_col[3])
{
	const char *display_device = scene->display_settings.display_device;
	struct ColorManagedDisplay *display = IMB_colormanagement_display_get_named(display_device);
	ImBuf *ibuf;
	float fx, fy, co[2];
	bool ret = false;

	ibuf = ED_space_clip_get_buffer(sc);
	if (!ibuf) {
		return false;
	}

	/* map the mouse coords to the backdrop image space */
	ED_clip_mouse_pos(sc, ar, mval, co);

	fx = co[0];
	fy = co[1];

	if (fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) {
		const float *fp;
		unsigned char *cp;
		int x = (int)(fx * ibuf->x), y = (int)(fy * ibuf->y);

		CLAMP(x, 0, ibuf->x - 1);
		CLAMP(y, 0, ibuf->y - 1);

		if (ibuf->rect_float) {
			fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x));
			copy_v3_v3(r_col, fp);
			ret = true;
		}
		else if (ibuf->rect) {
			cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x);
			rgb_uchar_to_float(r_col, cp);
			IMB_colormanagement_colorspace_to_scene_linear_v3(r_col, ibuf->rect_colorspace);
			ret = true;
		}
	}

	if (ret) {
		IMB_colormanagement_scene_linear_to_display_v3(r_col, display);
	}

	IMB_freeImBuf(ibuf);

	return ret;
}
Пример #21
0
static ImBuf *avi_fetchibuf(struct anim *anim, int position)
{
	ImBuf *ibuf = NULL;
	int *tmp;
	int y;
	
	if (anim == NULL) {
		return NULL;
	}

#if defined(_WIN32) && !defined(FREE_WINDOWS)
	if (anim->avistreams) {
		LPBITMAPINFOHEADER lpbi;

		if (anim->pgf) {
			lpbi = AVIStreamGetFrame(anim->pgf, position + AVIStreamStart(anim->pavi[anim->firstvideo]));
			if (lpbi) {
				ibuf = IMB_ibImageFromMemory((unsigned char *) lpbi, 100, IB_rect, anim->colorspace, "<avi_fetchibuf>");
//Oh brother...
			}
		}
	}
	else
#endif
	{
		ibuf = IMB_allocImBuf(anim->x, anim->y, 24, IB_rect);

		tmp = AVI_read_frame(anim->avi, AVI_FORMAT_RGB32, position,
		                     AVI_get_stream(anim->avi, AVIST_VIDEO, 0));
		
		if (tmp == NULL) {
			printf("Error reading frame from AVI: '%s'\n", anim->name);
			IMB_freeImBuf(ibuf);
			return NULL;
		}

		for (y = 0; y < anim->y; y++) {
			memcpy(&(ibuf->rect)[((anim->y - y) - 1) * anim->x],  &tmp[y * anim->x],
			       anim->x * 4);
		}
		
		MEM_freeN(tmp);
	}
	
	ibuf->rect_colorspace = colormanage_colorspace_get_named(anim->colorspace);

	return ibuf;
}
Пример #22
0
/* not brush itself */
void BKE_brush_free(Brush *brush)
{
	id_us_min((ID *)brush->mtex.tex);
	id_us_min((ID *)brush->mask_mtex.tex);
	id_us_min((ID *)brush->paint_curve);

	if (brush->icon_imbuf)
		IMB_freeImBuf(brush->icon_imbuf);

	BKE_previewimg_free(&(brush->preview));

	curvemapping_free(brush->curve);

	if (brush->gradient)
		MEM_freeN(brush->gradient);
}
Пример #23
0
ImBuf *ED_space_clip_get_stable_buffer(SpaceClip *sc, float loc[2], float *scale, float *angle)
{
	if (sc->clip) {
		ImBuf *ibuf;

		ibuf = BKE_movieclip_get_stable_ibuf(sc->clip, &sc->user, loc, scale, angle, sc->postproc_flag);

		if (ibuf && (ibuf->rect || ibuf->rect_float))
			return ibuf;

		if (ibuf)
			IMB_freeImBuf(ibuf);
	}

	return NULL;
}
Пример #24
0
ImBuf *ED_space_clip_get_buffer(SpaceClip *sc)
{
	if (sc->clip) {
		ImBuf *ibuf;

		ibuf = BKE_movieclip_get_postprocessed_ibuf(sc->clip, &sc->user, sc->postproc_flag);

		if (ibuf && (ibuf->rect || ibuf->rect_float))
			return ibuf;

		if (ibuf)
			IMB_freeImBuf(ibuf);
	}

	return NULL;
}
Пример #25
0
static int screenshot_exec(bContext *C, wmOperator *op)
{
  ScreenshotData *scd = op->customdata;
  bool ok = false;

  if (scd == NULL) {
    /* when running exec directly */
    screenshot_data_create(C, op);
    scd = op->customdata;
  }

  if (scd) {
    if (scd->dumprect) {
      ImBuf *ibuf;
      char path[FILE_MAX];

      RNA_string_get(op->ptr, "filepath", path);
      BLI_path_abs(path, BKE_main_blendfile_path_from_global());

      /* operator ensures the extension */
      ibuf = IMB_allocImBuf(scd->dumpsx, scd->dumpsy, 24, 0);
      ibuf->rect = scd->dumprect;

      /* crop to show only single editor */
      if (!RNA_boolean_get(op->ptr, "full")) {
        screenshot_crop(ibuf, scd->crop);
      }

      if (scd->im_format.planes == R_IMF_PLANES_BW) {
        /* bw screenshot? - users will notice if it fails! */
        IMB_color_to_bw(ibuf);
      }
      if (BKE_imbuf_write(ibuf, path, &scd->im_format)) {
        ok = true;
      }
      else {
        BKE_reportf(op->reports, RPT_ERROR, "Could not write image: %s", strerror(errno));
      }

      IMB_freeImBuf(ibuf);
    }
  }

  screenshot_data_free(op);

  return ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
Пример #26
0
static void thumbnails_update(void *tjv)
{
	ThumbnailJob *tj = tjv;

	if (tj->filelist && tj->filelist->filelist) {
		FileImage *limg = tj->loadimages.first;
		while (limg) {
			if (!limg->done && limg->img) {
				tj->filelist->filelist[limg->index].image = IMB_dupImBuf(limg->img);
				limg->done = true;
				IMB_freeImBuf(limg->img);
				limg->img = NULL;
			}
			limg = limg->next;
		}
	}
}
Пример #27
0
void BKE_sequencer_preprocessed_cache_cleanup_sequence(Sequence *seq)
{
	SeqPreprocessCacheElem *elem, *elem_next;

	if (!preprocess_cache)
		return;

	for (elem = preprocess_cache->elems.first; elem; elem = elem_next) {
		elem_next = elem->next;

		if (elem->seq == seq) {
			IMB_freeImBuf(elem->ibuf);

			BLI_freelinkN(&preprocess_cache->elems, elem);
		}
	}
}
Пример #28
0
/* frees storage for an array of direntries, including the array itself. */
void BLI_free_filelist(struct direntry *filelist, unsigned int nrentries)
{
	unsigned int i;
	for (i = 0; i < nrentries; ++i) {
		struct direntry * const entry = filelist + i;
		if (entry->image) {
			IMB_freeImBuf(entry->image);
		}
		if (entry->relname)
			MEM_freeN(entry->relname);
		if (entry->path)
			MEM_freeN(entry->path);
		/* entry->poin assumed not to point to anything needing freeing here */
	}

	free(filelist);
}
Пример #29
0
static void detect_clip_source(MovieClip *clip)
{
	ImBuf *ibuf;
	char name[FILE_MAX];

	BLI_strncpy(name, clip->name, sizeof(name));
	BLI_path_abs(name, G.main->name);

	ibuf = IMB_testiffname(name, IB_rect | IB_multilayer);
	if (ibuf) {
		clip->source = MCLIP_SRC_SEQUENCE;
		IMB_freeImBuf(ibuf);
	}
	else {
		clip->source = MCLIP_SRC_MOVIE;
	}
}
Пример #30
0
static void HashValFree(void *val)
{
	seqCacheEntry* e = (seqCacheEntry*) val;

	if (e->ibuf) {
		/* fprintf(stderr, "Removing: %p, cnt: %d\n", e->ibuf, 
		   e->ibuf->refcounter); */
		IMB_freeImBuf(e->ibuf);
		MEM_CacheLimiter_unmanage(e->c_handle);
		ibufs_rem++;
	}

	e->ibuf = NULL;
	e->c_handle = NULL;

	BLI_mempool_free(entrypool, e);
}