• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ IMB_allocImBuf函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: IMB_allocImBuf

static ImBuf *float_image_to_ibuf(libmv_FloatImage *float_image)
{
	ImBuf *ibuf = IMB_allocImBuf(float_image->width, float_image->height, 32, 0);
	size_t size = (size_t)ibuf->x * (size_t)ibuf->y *
	              float_image->channels * sizeof(float);
	ibuf->channels = float_image->channels;
	if ((ibuf->rect_float = MEM_mapallocN(size, "tracking grayscale image"))) {
		ibuf->mall |= IB_rectfloat;
		ibuf->flags |= IB_rectfloat;
	}
	memcpy(ibuf->rect_float, float_image->buffer, size);
	return ibuf;
}
开发者ID:Andrewson3D,项目名称:blender-for-vray,代码行数:13,代码来源:tracking_util.c


示例2: IMB_allocImBuf

// img must point to a array of RGBA data of size width*height
void ImageBuff::plot(unsigned char *img, short width, short height, short x, short y, short mode)
{
	struct ImBuf *tmpbuf;

	if (m_size[0] == 0 || m_size[1] == 0 || width <= 0 || height <= 0)
		return;

	if (!m_imbuf) {
		// allocate most basic imbuf, we will assign the rect buffer on the fly
		m_imbuf = IMB_allocImBuf(m_size[0], m_size[1], 0, 0);
	}

	tmpbuf = IMB_allocImBuf(width, height, 0, 0);

	// assign temporarily our buffer to the ImBuf buffer, we use the same format
	tmpbuf->rect = (unsigned int*)img;
	m_imbuf->rect = m_image;
	IMB_rectblend(m_imbuf, m_imbuf, tmpbuf, NULL, NULL, NULL, 0, x, y, x, y, 0, 0, width, height, (IMB_BlendMode)mode, false);
	// remove so that MB_freeImBuf will free our buffer
	m_imbuf->rect = NULL;
	tmpbuf->rect = NULL;
	IMB_freeImBuf(tmpbuf);
}
开发者ID:Andrewson3D,项目名称:blender-for-vray,代码行数:24,代码来源:ImageBuff.cpp


示例3: colorspace_set_default_role

static struct ImBuf *imb_load_dpx_cineon(unsigned char *mem, size_t size, int use_cineon, int flags,
                                         char colorspace[IM_MAX_SPACE])
{
	ImBuf *ibuf;
	LogImageFile *image;
	int width, height, depth;

	colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_FLOAT);

	logImageSetVerbose((G.f & G_DEBUG) ? 1 : 0);

	image = logImageOpenFromMemory(mem, size);

	if (image == 0) {
		printf("DPX/Cineon: error opening image.\n");
		return 0;
	}

	logImageGetSize(image, &width, &height, &depth);

	if (width == 0 || height == 0) {
		logImageClose(image);
		return 0;
	}

	ibuf = IMB_allocImBuf(width, height, 32, IB_rectfloat | flags);
	if (ibuf == 0) {
		logImageClose(image);
		return 0;
	}

	if (logImageGetDataRGBA(image, ibuf->rect_float, 1) != 0) {
		/* Conversion not possible (probably because the format is unsupported) */
		logImageClose(image);
		MEM_freeN(ibuf);
		return 0;
	}

	logImageClose(image);
	ibuf->ftype = use_cineon ? CINEON : DPX;
	IMB_flipy(ibuf);

	if (flags & IB_rect)
		IMB_rect_from_float(ibuf);

	if (flags & IB_alphamode_detect)
		ibuf->flags |= IB_alphamode_premul;

	return ibuf;
}
开发者ID:danielmarg,项目名称:blender-main,代码行数:50,代码来源:cineon_dpx.c


示例4: IMB_allocImBuf

static struct ImBuf *make_vectorscope_view_from_ibuf_float(struct ImBuf * ibuf)
{
	struct ImBuf * rval = IMB_allocImBuf(515, 515, 32, IB_rect);
	int x,y;
	float* src = ibuf->rect_float;
	char* tgt = (char*) rval->rect;
	float rgb[3], yuv[3];
	int w = 515;
	int h = 515;
	float scope_gamma = 0.2;
	unsigned char wtable[256];

	for (x = 0; x < 256; x++) {
		wtable[x] = (unsigned char) (pow(((float) x + 1)/256, 
						 scope_gamma)*255);
	}

	for (x = 0; x <= 255; x++) {
		vectorscope_put_cross(255   ,     0,255 - x, tgt, w, h, 1);
		vectorscope_put_cross(255   ,     x,      0, tgt, w, h, 1);
		vectorscope_put_cross(255- x,   255,      0, tgt, w, h, 1);
		vectorscope_put_cross(0,        255,      x, tgt, w, h, 1);
		vectorscope_put_cross(0,    255 - x,    255, tgt, w, h, 1);
		vectorscope_put_cross(x,          0,    255, tgt, w, h, 1);
	}

	for (y = 0; y < ibuf->y; y++) {
		for (x = 0; x < ibuf->x; x++) {
			float * src1 = src + 4 * (ibuf->x * y + x);
			char * p;
			
			memcpy(rgb, src1, 3 * sizeof(float));

			CLAMP(rgb[0], 0.0f, 1.0f);
			CLAMP(rgb[1], 0.0f, 1.0f);
			CLAMP(rgb[2], 0.0f, 1.0f);

			rgb_to_yuv(rgb, yuv);
			
			p = tgt + 4 * (w * (int) ((yuv[2] * (h - 3) + 1)) 
					   + (int) ((yuv[1] * (w - 3) + 1)));
			scope_put_pixel(wtable, (unsigned char*)p);
		}
	}

	vectorscope_put_cross(0, 0, 0, tgt, w, h, 3);

	return rval;
}
开发者ID:OldBrunet,项目名称:BGERTPS,代码行数:49,代码来源:sequencer_scopes.c


示例5: defined

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;
}
开发者ID:Eibriel,项目名称:kiriblender,代码行数:48,代码来源:anim_movie.c


示例6: screenshot_exec

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;
}
开发者ID:dfelinto,项目名称:blender,代码行数:47,代码来源:screendump.c


示例7: IMB_allocImBuf

ImBuf *render_result_rect_to_ibuf(RenderResult *rr, RenderData *rd, const int view_id)
{
	ImBuf *ibuf = IMB_allocImBuf(rr->rectx, rr->recty, rd->im_format.planes, 0);
	RenderView *rv = RE_RenderViewGetById(rr, view_id);

	/* if not exists, BKE_imbuf_write makes one */
	ibuf->rect = (unsigned int *) rv->rect32;
	ibuf->rect_float = rv->rectf;
	ibuf->zbuf_float = rv->rectz;

	/* float factor for random dither, imbuf takes care of it */
	ibuf->dither = rd->dither_intensity;
	
	/* prepare to gamma correct to sRGB color space
	 * note that sequence editor can generate 8bpc render buffers
	 */
	if (ibuf->rect) {
		if (BKE_imtype_valid_depths(rd->im_format.imtype) & (R_IMF_CHAN_DEPTH_12 | R_IMF_CHAN_DEPTH_16 | R_IMF_CHAN_DEPTH_24 | R_IMF_CHAN_DEPTH_32)) {
			if (rd->im_format.depth == R_IMF_CHAN_DEPTH_8) {
				/* Higher depth bits are supported but not needed for current file output. */
				ibuf->rect_float = NULL;
			}
			else {
				IMB_float_from_rect(ibuf);
			}
		}
		else {
			/* ensure no float buffer remained from previous frame */
			ibuf->rect_float = NULL;
		}
	}

	/* color -> grayscale */
	/* editing directly would alter the render view */
	if (rd->im_format.planes == R_IMF_PLANES_BW) {
		ImBuf *ibuf_bw = IMB_dupImBuf(ibuf);
		IMB_color_to_bw(ibuf_bw);
		IMB_freeImBuf(ibuf);
		ibuf = ibuf_bw;
	}

	return ibuf;
}
开发者ID:sntulix,项目名称:blender-api-javascript,代码行数:43,代码来源:render_result.c


示例8: screenshot_exec

static int screenshot_exec(bContext *C, wmOperator *op)
{
    ScreenshotData *scd = op->customdata;

    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, G.main->name);

            /* 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);
            }
            BKE_imbuf_write(ibuf, path, &scd->im_format);

            IMB_freeImBuf(ibuf);
        }
    }

    screenshot_data_free(op);
    return OPERATOR_FINISHED;
}
开发者ID:caomw,项目名称:blender-ui,代码行数:39,代码来源:screendump.c


示例9: MakeScreenShot

	void
GPC_Canvas::
MakeScreenShot(
	const char* filename
) {
	// copy image data
	unsigned char *pixels = new unsigned char[GetWidth() * GetHeight() * 4];

	if (!pixels) {
		std::cout << "Cannot allocate pixels array" << std::endl;
		return;
	}

	glReadPixels(0, 0, GetWidth(), GetHeight(), GL_RGBA, GL_UNSIGNED_BYTE, pixels);

	// initialize image file format data
	ImageFormatData im_format;
	BKE_imformat_defaults(&im_format);

	// create file path 
	char path[FILE_MAX];
	BLI_strncpy(path, filename, sizeof(path));
	BLI_path_abs(path, G.main->name);
	BLI_path_frame(path, m_frame, 0);
	m_frame++;
	BKE_image_path_ensure_ext_from_imtype(path, im_format.imtype);

	// create and save imbuf 
	ImBuf *ibuf = IMB_allocImBuf(GetWidth(), GetHeight(), 24, 0);
	ibuf->rect = (unsigned int*)pixels;

	BKE_imbuf_write_as(ibuf, path, &im_format, false);

	ibuf->rect = NULL;
	IMB_freeImBuf(ibuf);

	// clean up
	delete [] (pixels);
}
开发者ID:Andrewson3D,项目名称:blender-for-vray,代码行数:39,代码来源:GPC_Canvas.cpp


示例10: IMB_allocImBuf

struct ImBuf *IMB_allocFromBuffer(const unsigned int *rect, const float *rectf,
                                  unsigned int w, unsigned int h)
{
    ImBuf *ibuf = NULL;

    if (!(rect || rectf))
        return NULL;

    ibuf = IMB_allocImBuf(w, h, 32, 0);

    if (rectf) {
        ibuf->rect_float = MEM_dupallocN(rectf);
        ibuf->flags |= IB_rectfloat;
        ibuf->mall |= IB_rectfloat;
    }
    if (rect) {
        ibuf->rect = MEM_dupallocN(rect);
        ibuf->flags |= IB_rect;
        ibuf->mall |= IB_rect;
    }

    return ibuf;
}
开发者ID:mcgrathd,项目名称:blender,代码行数:23,代码来源:allocimbuf.c


示例11: imb_stereo3d_squeeze_rect

static void imb_stereo3d_squeeze_rect(int *rect, Stereo3dFormat *s3d, const size_t x, const size_t y, const size_t channels)
{
	ImBuf *ibuf;
	size_t width, height;

	if (ELEM(s3d->display_mode, S3D_DISPLAY_SIDEBYSIDE, S3D_DISPLAY_TOPBOTTOM) == false)
		return;

	if ((s3d->flag & S3D_SQUEEZED_FRAME) == 0)
		return;

	/* creates temporary imbuf to store the rectf */
	IMB_stereo3d_write_dimensions(s3d->display_mode, false, x, y, &width, &height);
	ibuf = IMB_allocImBuf(width, height, channels, IB_rect);

	IMB_buffer_byte_from_byte(
	        (unsigned char *)ibuf->rect, (unsigned char *)rect,
	        IB_PROFILE_SRGB, IB_PROFILE_SRGB, false,
	        width, height, width, width);

	IMB_scaleImBuf_threaded(ibuf, x, y);
	memcpy(rect, ibuf->rect, x * y * sizeof(unsigned int));
	IMB_freeImBuf(ibuf);
}
开发者ID:Ichthyostega,项目名称:blender,代码行数:24,代码来源:stereoimbuf.c


示例12: write_external_bake_pixels

static bool write_external_bake_pixels(
        const char *filepath, BakePixel pixel_array[], float *buffer,
        const int width, const int height, const int margin,
        ImageFormatData *im_format, const bool is_noncolor)
{
	ImBuf *ibuf = NULL;
	bool ok = false;
	bool is_float;

	is_float = im_format->depth > 8;

	/* create a new ImBuf */
	ibuf = IMB_allocImBuf(width, height, im_format->planes, (is_float ? IB_rectfloat : IB_rect));

	if (!ibuf)
		return false;

	/* populates the ImBuf */
	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 {
		if (!is_noncolor) {
			const char *from_colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_SCENE_LINEAR);
			const char *to_colorspace = IMB_colormanagement_get_rect_colorspace(ibuf);
			IMB_colormanagement_transform(buffer, ibuf->x, ibuf->y, ibuf->channels, from_colorspace, to_colorspace, false);
		}

		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);
	}

	/* margins */
	if (margin > 0) {
		char *mask_buffer = NULL;
		const size_t num_pixels = (size_t)width * (size_t)height;

		mask_buffer = MEM_callocN(sizeof(char) * num_pixels, "Bake Mask");
		RE_bake_mask_fill(pixel_array, num_pixels, mask_buffer);
		RE_bake_margin(ibuf, mask_buffer, margin);

		if (mask_buffer)
			MEM_freeN(mask_buffer);
	}

	if ((ok = BKE_imbuf_write(ibuf, filepath, im_format))) {
#ifndef WIN32
		chmod(filepath, S_IRUSR | S_IWUSR);
#endif
		//printf("%s saving bake map: '%s'\n", __func__, filepath);
	}

	/* garbage collection */
	IMB_freeImBuf(ibuf);

	return ok;
}
开发者ID:Passtechsoft,项目名称:TPEAlpGen,代码行数:62,代码来源:object_bake_api.c


示例13: colorspace_set_default_role

ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
{
	struct ImBuf *ibuf = NULL;
	png_structp png_ptr;
	png_infop info_ptr;
	unsigned char *pixels = NULL;
	unsigned short *pixels16 = NULL;
	png_bytepp row_pointers = NULL;
	png_uint_32 width, height;
	int bit_depth, color_type;
	PNGReadStruct ps;

	unsigned char *from, *to;
	unsigned short *from16;
	float *to_float;
	int i, bytesperpixel;

	if (imb_is_a_png(mem) == 0) return(NULL);

	/* both 8 and 16 bit PNGs are default to standard byte colorspace */
	colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE);

	png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
	                                 NULL, NULL, NULL);
	if (png_ptr == NULL) {
		printf("Cannot png_create_read_struct\n");
		return NULL;
	}

	info_ptr = png_create_info_struct(png_ptr);
	if (info_ptr == NULL) {
		png_destroy_read_struct(&png_ptr, (png_infopp)NULL, 
		                        (png_infopp)NULL);
		printf("Cannot png_create_info_struct\n");
		return NULL;
	}

	ps.size = size; /* XXX, 4gig limit! */
	ps.data = mem;
	ps.seek = 0;

	png_set_read_fn(png_ptr, (void *) &ps, ReadData);

	if (setjmp(png_jmpbuf(png_ptr))) {
		png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
		if (pixels) MEM_freeN(pixels);
		if (pixels16) MEM_freeN(pixels16);
		if (row_pointers) MEM_freeN(row_pointers);
		if (ibuf) IMB_freeImBuf(ibuf);
		return NULL;
	}

	// png_set_sig_bytes(png_ptr, 8);

	png_read_info(png_ptr, info_ptr);
	png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, 
	             &color_type, NULL, NULL, NULL);

	bytesperpixel = png_get_channels(png_ptr, info_ptr);

	switch (color_type) {
		case PNG_COLOR_TYPE_RGB:
		case PNG_COLOR_TYPE_RGB_ALPHA:
			break;
		case PNG_COLOR_TYPE_PALETTE:
			png_set_palette_to_rgb(png_ptr);
			if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
				bytesperpixel = 4;
			}
			else {
				bytesperpixel = 3;
			}
			break;
		case PNG_COLOR_TYPE_GRAY:
		case PNG_COLOR_TYPE_GRAY_ALPHA:
			if (bit_depth < 8) {
				png_set_expand(png_ptr);
				bit_depth = 8;
			}
			break;
		default:
			printf("PNG format not supported\n");
			longjmp(png_jmpbuf(png_ptr), 1);
	}
	
	ibuf = IMB_allocImBuf(width, height, 8 * bytesperpixel, 0);

	if (ibuf) {
		ibuf->ftype = PNG;
		if (bit_depth == 16)
			ibuf->ftype |= PNG_16BIT;

		if (png_get_valid(png_ptr, info_ptr, PNG_INFO_pHYs)) {
			int unit_type;
			png_uint_32 xres, yres;

			if (png_get_pHYs(png_ptr, info_ptr, &xres, &yres, &unit_type))
				if (unit_type == PNG_RESOLUTION_METER) {
					ibuf->ppm[0] = xres;
					ibuf->ppm[1] = yres;
//.........这里部分代码省略.........
开发者ID:scorpion81,项目名称:blender-voro,代码行数:101,代码来源:png.c


示例14: IMB_allocImBuf

struct ImBuf *imb_loadhdr(unsigned char *mem, size_t size, int flags)
{
	struct ImBuf* ibuf;
	RGBE* sline;
	fCOLOR fcol;
	float* rect_float;
	int found=0;
	int width=0, height=0;
	int x, y;
	unsigned char* ptr;
	char oriY[80], oriX[80];

	if (imb_is_a_hdr((void*)mem))
	{
		/* find empty line, next line is resolution info */
		for (x=1;x<size;x++) {
			if ((mem[x-1]=='\n') && (mem[x]=='\n')) {
				found = 1;
				break;
			}
		}
		if (found && (x<(size + 2))) {
			if (sscanf((char *)&mem[x+1], "%79s %d %79s %d", (char*)&oriY, &height, 
				(char*)&oriX, &width) != 4) return NULL;

			/* find end of this line, data right behind it */
			ptr = (unsigned char *)strchr((char*)&mem[x+1], '\n');
			ptr++;

			if (flags & IB_test) ibuf = IMB_allocImBuf(width, height, 32, 0);
			else ibuf = IMB_allocImBuf(width, height, 32, (flags & IB_rect)|IB_rectfloat);

			if (ibuf==NULL) return NULL;
			ibuf->ftype = RADHDR;
			ibuf->profile = IB_PROFILE_LINEAR_RGB;

			if (flags & IB_test) return ibuf;

			/* read in and decode the actual data */
			sline = (RGBE*)MEM_mallocN(sizeof(RGBE)*width, "radhdr_read_tmpscan");
			rect_float = (float *)ibuf->rect_float;
			
			for (y=0;y<height;y++) {
				ptr = freadcolrs(sline, ptr, width);
				if (ptr==NULL) {
					printf("HDR decode error\n");
					MEM_freeN(sline);
					return ibuf;
				}
				for (x=0;x<width;x++) {
					/* convert to ldr */
					RGBE2FLOAT(sline[x], fcol);
					*rect_float++ = fcol[RED];
					*rect_float++ = fcol[GRN];
					*rect_float++ = fcol[BLU];
					*rect_float++ = 1.0f;
				}
			}
			MEM_freeN(sline);
			if (oriY[0]=='-') IMB_flipy(ibuf);
			
			if (flags & IB_rect) {
				IMB_rect_from_float(ibuf);
			}
			
			return ibuf;
		}
		//else printf("Data not found!\n");
	}
	//else printf("Not a valid radiance HDR file!\n");

	return NULL;
}
开发者ID:mik0001,项目名称:Blender,代码行数:73,代码来源:radiance_hdr.c


示例15: png_create_read_struct

struct ImBuf *imb_loadpng(unsigned char *mem, int size, int flags)
{
    struct ImBuf *ibuf = 0;
    png_structp png_ptr;
    png_infop info_ptr;
    unsigned char *pixels = 0;
    png_bytepp row_pointers = 0;
    png_uint_32 width, height;
    int bit_depth, color_type;
    PNGReadStruct ps;

    unsigned char *from, *to;
    int i, bytesperpixel;

    if (imb_is_a_png(mem) == 0) return(0);

    png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
                                     NULL, NULL, NULL);
    if (png_ptr == NULL) {
        printf("Cannot png_create_read_struct\n");
        return 0;
    }

    info_ptr = png_create_info_struct(png_ptr);
    if (info_ptr == NULL) {
        png_destroy_read_struct(&png_ptr, (png_infopp)NULL,
                                (png_infopp)NULL);
        printf("Cannot png_create_info_struct\n");
        return 0;
    }

    ps.size = size;
    ps.data = mem;
    ps.seek = 0;

    png_set_read_fn(png_ptr, (void *) &ps, ReadData);

    if (setjmp(png_jmpbuf(png_ptr))) {
        png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
        if (pixels) MEM_freeN(pixels);
        if (row_pointers) MEM_freeN(row_pointers);
        if (ibuf) IMB_freeImBuf(ibuf);
        return 0;
    }

    // png_set_sig_bytes(png_ptr, 8);

    png_read_info(png_ptr, info_ptr);
    png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth,
                 &color_type, NULL, NULL, NULL);

    if (bit_depth == 16) {
        png_set_strip_16(png_ptr);
        bit_depth = 8;
    }

    bytesperpixel = png_get_channels(png_ptr, info_ptr);

    switch(color_type) {
    case PNG_COLOR_TYPE_RGB:
    case PNG_COLOR_TYPE_RGB_ALPHA:
        break;
    case PNG_COLOR_TYPE_PALETTE:
        png_set_palette_to_rgb(png_ptr);
        if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
            bytesperpixel = 4;
        } else {
            bytesperpixel = 3;
        }
        break;
    case PNG_COLOR_TYPE_GRAY:
    case PNG_COLOR_TYPE_GRAY_ALPHA:
        if (bit_depth < 8) {
            png_set_expand(png_ptr);
            bit_depth = 8;
        }
        break;
    default:
        printf("PNG format not supported\n");
        longjmp(png_jmpbuf(png_ptr), 1);
    }

    ibuf = IMB_allocImBuf(width, height, 8 * bytesperpixel, 0, 0);

    if (ibuf) {
        ibuf->ftype = PNG;
    } else {
        printf("Couldn't allocate memory for PNG image\n");
    }

    if (ibuf && ((flags & IB_test) == 0)) {
        imb_addrectImBuf(ibuf);

        pixels = MEM_mallocN(ibuf->x * ibuf->y * bytesperpixel * sizeof(unsigned char), "pixels");
        if (pixels == NULL) {
            printf("Cannot allocate pixels array\n");
            longjmp(png_jmpbuf(png_ptr), 1);
        }

        // allocate memory for an array of row-pointers
//.........这里部分代码省略.........
开发者ID:jinjoh,项目名称:NOOR,代码行数:101,代码来源:png.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ IMB_freeImBuf函数代码示例发布时间:2022-05-30
下一篇:
C++ IMAX函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap