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

C++ FreeImage_GetPitch函数代码示例

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

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



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

示例1: model

/**
Extract the luminance channel L from a RGBF image. 
Luminance is calculated from the sRGB model (RGB2XYZ matrix) 
using a D65 white point : 
L = ( 0.2126 * r ) + ( 0.7152 * g ) + ( 0.0722 * b )
Reference : 
A Standard Default Color Space for the Internet - sRGB. 
[online] http://www.w3.org/Graphics/Color/sRGB
*/
FIBITMAP*  
ConvertRGBFToY(FIBITMAP *src) {
	if(FreeImage_GetImageType(src) != FIT_RGBF)
		return FALSE;

	unsigned width  = FreeImage_GetWidth(src);
	unsigned height = FreeImage_GetHeight(src);

	FIBITMAP *dst = FreeImage_AllocateT(FIT_FLOAT, width, height);
	if(!dst) return NULL;

	unsigned src_pitch  = FreeImage_GetPitch(src);
	unsigned dst_pitch  = FreeImage_GetPitch(dst);

	
	BYTE *src_bits = (BYTE*)FreeImage_GetBits(src);
	BYTE *dst_bits = (BYTE*)FreeImage_GetBits(dst);

	for(unsigned y = 0; y < height; y++) {
		const FIRGBF *src_pixel = (FIRGBF*)src_bits;
		float  *dst_pixel = (float*)dst_bits;
		for(unsigned x = 0; x < width; x++) {
			float L = 0.2126F * src_pixel[x].red + 0.7152F * src_pixel[x].green + 0.0722F * src_pixel[x].blue;
			dst_pixel[x] = (L > 0) ? L : 0;
		}
		// next line
		src_bits += src_pitch;
		dst_bits += dst_pitch;
	}

	return dst;
}
开发者ID:BackupTheBerlios,项目名称:mimplugins-svn,代码行数:41,代码来源:tmoColorConvert.cpp


示例2: fmg_relaxation

/**
Red-black Gauss-Seidel relaxation for model problem. Updates the current value of the solution
u[0..n-1][0..n-1], using the right-hand side function rhs[0..n-1][0..n-1].
*/
static void fmg_relaxation(FIBITMAP *U, FIBITMAP *RHS, int n) {
	int row, col, ipass, isw, jsw;
	const float h = 1.0F / (n - 1);
	const float h2 = h*h;

	const int u_pitch  = FreeImage_GetPitch(U) / sizeof(float);
	const int rhs_pitch  = FreeImage_GetPitch(RHS) / sizeof(float);
	
	float *u_bits = (float*)FreeImage_GetBits(U);
	const float *rhs_bits = (float*)FreeImage_GetBits(RHS);

	for (ipass = 0, jsw = 1; ipass < 2; ipass++, jsw = 3-jsw) { // Red and black sweeps
		float *u_scan = u_bits + u_pitch;
		const float *rhs_scan = rhs_bits + rhs_pitch;
		for (row = 1, isw = jsw; row < n-1; row++, isw = 3-isw) {
			for (col = isw; col < n-1; col += 2) { 
				// Gauss-Seidel formula
				// calculate U(row, col) = 
				// 0.25 * [ U(row+1, col) + U(row-1, col) + U(row, col+1) + U(row, col-1) - h2 * RHS(row, col) ]		 
				float *u_center = u_scan + col;
				const float *rhs_center = rhs_scan + col;
				*u_center = *(u_center + u_pitch) + *(u_center - u_pitch) + *(u_center + 1) + *(u_center - 1);
				*u_center -= h2 * *rhs_center;
				*u_center *= 0.25F;
			}
			u_scan += u_pitch;
			rhs_scan += rhs_pitch;
		}
	}
}
开发者ID:Ayane,项目名称:BLPConverter,代码行数:34,代码来源:MultigridPoissonSolver.cpp


示例3: glLoadTexture

	///////////////////////////////////////////////////////////////////////////
	///
	/// @fn bool glLoadTexture(const std::string& nomFichier, unsigned int& idTexture,
	///                        bool genererTexture)
	///
	/// Cette fonction crée une texture OpenGL à partir d'une image contenu
	/// dans un fichier.  FreeImage est utilisée pour lire l'image, donc tous
	/// les formats reconnues par cette librairie devraient être supportés.
	///
	/// @param[in]  nomFichier     : Le nom du fichier image à charger.
	/// @param[out] idTexture      : L'identificateur de la texture créée.
	/// @param[in]  genererTexture : Doit-on demander à OpenGL de générer un numéro
	///										de texture au préalable?
	///
	/// @return Vrai si le chargement a réussi, faux autrement.
	///
	///////////////////////////////////////////////////////////////////////////
	bool glLoadTexture(const std::string& nomFichier, unsigned int& idTexture, bool genererTexture)
	{
		// Ce code de lecture générique d'un fichier provient de la
		// documentation de FreeImage
		FREE_IMAGE_FORMAT format = FIF_UNKNOWN;
		// check the file signature and deduce its format
		// (the second argument is currently not used by FreeImage)
		format = FreeImage_GetFileType(nomFichier.c_str(), 0);
		if(format == FIF_UNKNOWN) {
			// no signature ?
			// try to guess the file format from the file extension
			format = FreeImage_GetFIFFromFilename(nomFichier.c_str());
		}
		// check that the plugin has reading capabilities ...
		if((format == FIF_UNKNOWN) || !FreeImage_FIFSupportsReading(format)) {
			utilitaire::afficherErreur(
				std::string("Format du fichier image \"") +
				std::string(nomFichier.c_str()) + std::string("\" non supporté")
				);
			return false;
		}
		// ok, let's load the file
		FIBITMAP* dib = FreeImage_Load(format, nomFichier.c_str(), 0);

		if (dib == 0) {
			utilitaire::afficherErreur(
				std::string("Erreur à la lecture du fichier \"") +
				std::string(nomFichier.c_str()) + std::string("\"")
				);
			return false;
		}

		FIBITMAP* dib32 = FreeImage_ConvertTo32Bits(dib);
		if (dib32 == 0) {
			utilitaire::afficherErreur(
				std::string("Incapable de convertir le fichier \"") +
				std::string(nomFichier.c_str()) + std::string("\" en 32 bpp.")
				);
			FreeImage_Unload(dib);
			return false;
		}

		int pitch = FreeImage_GetPitch(dib32);

		glCreateTexture(
			FreeImage_GetBits(dib32),
			FreeImage_GetWidth(dib32),
			FreeImage_GetHeight(dib32),
			FreeImage_GetBPP(dib32),
			FreeImage_GetPitch(dib32),
			idTexture,
			genererTexture
			);

		FreeImage_Unload(dib32);
		FreeImage_Unload(dib);

		return true;
	}
开发者ID:gravufo,项目名称:MLGHockey,代码行数:76,代码来源:AideGL.cpp


示例4: ApplyCurve

double ApplyCurve(FIBITMAP *src, FIBITMAP *dst, std::vector<cp> ctpts, int threadcount)
{
    _mark();
    unsigned spitch = FreeImage_GetPitch(src);
    unsigned dpitch = FreeImage_GetPitch(dst);
    unsigned w = FreeImage_GetWidth(src);
    unsigned h = FreeImage_GetHeight(src);
    BYTE * srcbits = FreeImage_GetBits(src);
    BYTE * dstbits = FreeImage_GetBits(dst);

    Curve c;
    BYTE LUT8[256];
    WORD LUT16[65536];
    c.setControlPoints(ctpts);
    int bpp = FreeImage_GetBPP(src);
    if (bpp == 24) {
        c.clampto(0.0,255.0);
        for (int x=0; x<256; x++) {
            LUT8[x] = (BYTE)floor(c.getpoint(x) + 0.5);
        }
        #pragma omp parallel for num_threads(threadcount)
        for(unsigned y = 0; y < h; y++) {
            for(unsigned x = 0; x < w; x++) {
                BYTE * bdstpix = (BYTE *) dstbits + dpitch*y + 3*x;
                BYTE *pixel = (BYTE *) (srcbits + spitch*y + 3*x);
                bdstpix[FI_RGBA_RED]   = LUT8[pixel[FI_RGBA_RED]];
                bdstpix[FI_RGBA_GREEN] = LUT8[pixel[FI_RGBA_GREEN]];
                bdstpix[FI_RGBA_BLUE]  = LUT8[pixel[FI_RGBA_BLUE]];

                //bdstpix[FI_RGBA_RED]   = ((BYTE *) LUT8)[pixel[FI_RGBA_RED]];
                //bdstpix[FI_RGBA_GREEN] = ((BYTE *) LUT8)[pixel[FI_RGBA_GREEN]];
                //bdstpix[FI_RGBA_BLUE]  = ((BYTE *) LUT8)[pixel[FI_RGBA_BLUE]];
            }
        }
    }
    if (bpp == 48) {
        c.scalepoints(256.0);
        c.clampto(0.0,65535.0);
        for (int x=0; x<65536; x++) {
            LUT16[x] = (WORD)floor(c.getpoint(x) + 0.5);
        }
        #pragma omp parallel for num_threads(threadcount)
        for(unsigned y = 0; y < h; y++) {
            for(unsigned x = 0; x < w; x++) {
                FIRGB16 * wdstpix = (FIRGB16 *) (dstbits + dpitch*y + 6*x);
                FIRGB16 * pixel   = (FIRGB16 *) (srcbits + spitch*y + 6*x);
                wdstpix->red   = LUT16[pixel->red];
                wdstpix->green = LUT16[pixel->green];
                wdstpix->blue  = LUT16[pixel->blue];

                //wdstpix->red   = ((WORD *) LUT16)[pixel->red];
                //wdstpix->green = ((WORD *) LUT16)[pixel->green];
                //wdstpix->blue  = ((WORD *) LUT16)[pixel->blue];
            }
        }
    }
    return _duration();
}
开发者ID:butcherg,项目名称:rawproc,代码行数:58,代码来源:FreeImage_Threaded.cpp


示例5: ApplyLUT

double ApplyLUT(FIBITMAP *src, FIBITMAP *dst, char * LUT, int threadcount)
{
    _mark();
    unsigned spitch = FreeImage_GetPitch(src);
    unsigned dpitch = FreeImage_GetPitch(dst);
    unsigned w = FreeImage_GetWidth(src);
    unsigned h = FreeImage_GetHeight(src);
    BYTE * srcbits = FreeImage_GetBits(src);
    BYTE * dstbits = FreeImage_GetBits(dst);

    BYTE LUT8[256];
    WORD LUT16[65536];
    int bpp = FreeImage_GetBPP(src);
    if (bpp == 24) {
        for (int x=0; x<256; x++) {
            LUT8[x] = ((BYTE *) LUT)[x];;
        }
        #pragma omp parallel for num_threads(threadcount)
        for(unsigned y = 0; y < h; y++) {
            for(unsigned x = 0; x < w; x++) {
                BYTE * bdstpix = (BYTE *) (dstbits + dpitch*y + 3*x);
                BYTE * pixel   = (BYTE *) (srcbits + spitch*y + 3*x);
                bdstpix[FI_RGBA_RED]   = LUT8[pixel[FI_RGBA_RED]];
                bdstpix[FI_RGBA_GREEN] = LUT8[pixel[FI_RGBA_GREEN]];
                bdstpix[FI_RGBA_BLUE]  = LUT8[pixel[FI_RGBA_BLUE]];

                //bdstpix[FI_RGBA_RED]   = ((BYTE *) LUT8)[pixel[FI_RGBA_RED]];
                //bdstpix[FI_RGBA_GREEN] = ((BYTE *) LUT8)[pixel[FI_RGBA_GREEN]];
                //bdstpix[FI_RGBA_BLUE]  = ((BYTE *) LUT8)[pixel[FI_RGBA_BLUE]];


            }
        }
    }
    if (bpp == 48) {
        for (int x=0; x<65536; x++) {
            LUT16[x] = ((WORD *)LUT)[x];
        }
        #pragma omp parallel for num_threads(threadcount)
        for(unsigned y = 0; y < h-1; y++) {
            for(unsigned x = 0; x < w-1; x++) {
                FIRGB16 * wdstpix = (FIRGB16 *) (dstbits + dpitch*y + 6*x);
                FIRGB16 * pixel   = (FIRGB16 *) (srcbits + spitch*y + 6*x);
                wdstpix->red   = LUT16[pixel->red];
                wdstpix->green = LUT16[pixel->green];
                wdstpix->blue  = LUT16[pixel->blue];

                //wdstpix->red   = ((WORD *) LUT16)[pixel->red];
                //wdstpix->green = ((WORD *) LUT16)[pixel->green];
                //wdstpix->blue  = ((WORD *) LUT16)[pixel->blue];


            }
        }
    }
    return _duration();
}
开发者ID:butcherg,项目名称:rawproc,代码行数:57,代码来源:FreeImage_Threaded.cpp


示例6: ApplyLUT2LUMA

double ApplyLUT2LUMA(FIBITMAP *src, FIBITMAP *dst, char * LUT, int threadcount)
{
    _mark();
    unsigned spitch = FreeImage_GetPitch(src);
    unsigned dpitch = FreeImage_GetPitch(dst);
    unsigned w = FreeImage_GetWidth(src);
    unsigned h = FreeImage_GetHeight(src);
    BYTE * srcbits = FreeImage_GetBits(src);
    BYTE * dstbits = FreeImage_GetBits(dst);

    BYTE LUT8[256];
    WORD LUT16[65536];
    int bpp = FreeImage_GetBPP(src);
    if (bpp == 24) {
        for (int x=0; x<256; x++) {
            LUT8[x] = ((BYTE *) LUT)[x];
        }
        #pragma omp parallel for num_threads(threadcount)
        for(unsigned y = 0; y < h; y++) {
            for(unsigned x = 0; x < w; x++) {
                BYTE * bdstpix = (BYTE *) (dstbits + dpitch*y + 3*x);
                BYTE * pixel   = (BYTE *) (srcbits + spitch*y + 3*x);

                int lumaorig = (int) LUMA(pixel[FI_RGBA_RED],pixel[FI_RGBA_GREEN],pixel[FI_RGBA_BLUE]);
                int diff = lumaorig - LUT8[lumaorig];

                bdstpix[FI_RGBA_RED]   = std::min(std::max(bdstpix[FI_RGBA_RED] + diff,0),255);
                bdstpix[FI_RGBA_GREEN] = std::min(std::max(bdstpix[FI_RGBA_GREEN] + diff,0),255);
                bdstpix[FI_RGBA_BLUE]  = std::min(std::max(bdstpix[FI_RGBA_BLUE]  + diff,0),255);

            }
        }
    }
    if (bpp == 48) {
        for (int x=0; x<65536; x++) {
            LUT16[x] = ((WORD *)LUT)[x];
        }
        #pragma omp parallel for num_threads(threadcount)
        for(unsigned y = 0; y < h-1; y++) {
            for(unsigned x = 0; x < w-1; x++) {
                FIRGB16 * wdstpix = (FIRGB16 *) (dstbits + dpitch*y + 6*x);
                FIRGB16 * pixel   = (FIRGB16 *) (srcbits + spitch*y + 6*x);

                int lumaorig = (int) LUMA(pixel->red,pixel->green,pixel->blue);
                int diff = lumaorig - LUT16[lumaorig];

                wdstpix->red   = std::min(std::max(pixel->red + diff,0),65535);
                wdstpix->green = std::min(std::max(pixel->green + diff,0),65535);
                wdstpix->blue  = std::min(std::max(pixel->blue + diff,0),65535);

            }
        }
    }
    return _duration();
}
开发者ID:butcherg,项目名称:rawproc,代码行数:55,代码来源:FreeImage_Threaded.cpp


示例7: ApplyGray

double ApplyGray(FIBITMAP *src, FIBITMAP *dst, double redpct, double greenpct, double bluepct, int threadcount)
{
    _mark();

    int bpp = FreeImage_GetBPP(src);

    unsigned spitch = FreeImage_GetPitch(src);
    unsigned dpitch = FreeImage_GetPitch(dst);
    BYTE * srcbits = FreeImage_GetBits(src);
    BYTE * dstbits = FreeImage_GetBits(dst);


    switch(bpp) {
    case 48:
        #pragma omp parallel for num_threads(threadcount)
        for(unsigned y = 0; y < FreeImage_GetHeight(src); y++) {
            for(unsigned x = 0; x < FreeImage_GetWidth(src); x++) {
                FIRGB16 * wdstpix = (FIRGB16 *) (dstbits + dpitch*y + 6*x);
                FIRGB16 * pixel   = (FIRGB16 *) (srcbits + spitch*y + 6*x);

                double G = floor((double) pixel->red*redpct + (double) pixel->green*greenpct + (double) pixel->blue*bluepct)+0.5;
                if (G>65535.0) G=65535.0;
                if (G<0.0) G=0.0;

                wdstpix->red = int(G);
                wdstpix->green = int(G);
                wdstpix->blue = int(G);
            }
        }
        break;
    case 24 :
        #pragma omp parallel for num_threads(threadcount)
        for(unsigned y = 0; y < FreeImage_GetHeight(src); y++) {
            for(unsigned x = 0; x < FreeImage_GetWidth(src); x++) {
                BYTE * bdstpix = (BYTE *) dstbits + dpitch*y + 3*x;
                BYTE *pixel = (BYTE *) (srcbits + spitch*y + 3*x);

                double G = floor((double) pixel[FI_RGBA_RED]*redpct + (double) pixel[FI_RGBA_GREEN]*greenpct + (double) pixel[FI_RGBA_BLUE]*bluepct)+0.5;
                if (G>255.0) G=255.0;
                if (G<0.0) G=0.0;

                bdstpix[FI_RGBA_RED] = int(G);
                bdstpix[FI_RGBA_GREEN] = int(G);
                bdstpix[FI_RGBA_BLUE]= int(G);

            }
        }
        break;
    }
    return _duration();

}
开发者ID:butcherg,项目名称:rawproc,代码行数:52,代码来源:FreeImage_Threaded.cpp


示例8: FreeImage_GetWidth

std::ostream &
operator <<(std::ostream &rOutputStream, const FIBITMAP &rBitmap)
{
    unsigned int nImageWidth    = FreeImage_GetWidth(const_cast<FIBITMAP *>(&rBitmap));
    unsigned int nImageHeight   = FreeImage_GetHeight(const_cast<FIBITMAP *>(&rBitmap));
    unsigned int nPitch         = FreeImage_GetPitch(const_cast<FIBITMAP *>(&rBitmap));
    unsigned int nBPP           = FreeImage_GetBPP(const_cast<FIBITMAP *>(&rBitmap));

    FREE_IMAGE_COLOR_TYPE eType = FreeImage_GetColorType(const_cast<FIBITMAP *>(&rBitmap));
    BITMAPINFO *pInfo          = FreeImage_GetInfo(const_cast<FIBITMAP *>(&rBitmap));

    rOutputStream << "Size  (" << FreeImage_GetWidth(const_cast<FIBITMAP *>(&rBitmap)) << ", "
                  << FreeImage_GetHeight(const_cast<FIBITMAP *>(&rBitmap)) << ")\n";
    rOutputStream << "Pitch "  << FreeImage_GetPitch(const_cast<FIBITMAP *>(&rBitmap)) << "\n";
    rOutputStream << "Type  ";

    switch (eType)
    {
        case FIC_MINISWHITE:
            rOutputStream << "FIC_MINISWHITE\n";
            break;

        case FIC_MINISBLACK:
            rOutputStream << "FIC_MINISBLACK\n";
            break;

        case FIC_RGB:
            rOutputStream << "FIC_RGB\n";
            break;

        case FIC_PALETTE:
            rOutputStream << "FIC_PALETTE\n";
            break;

        case FIC_RGBALPHA:
            rOutputStream << "FIC_RGBALPHA\n";
            break;

        case FIC_CMYK:
            rOutputStream << "FIC_CMYK\n";
            break;

        default:
            rOutputStream << "Unknown pixel format.\n";
    }

    rOutputStream << "BPP   " << nBPP << std::endl;

    return rOutputStream;
}
开发者ID:chengli1986,项目名称:571e,代码行数:50,代码来源:freeImageInteropNPP.cpp


示例9: fmg_residual

/**
Returns minus the residual for the model problem. Input quantities are u[0..n-1][0..n-1] and
rhs[0..n-1][0..n-1], while res[0..n-1][0..n-1] is returned.
*/
static void fmg_residual(FIBITMAP *RES, FIBITMAP *U, FIBITMAP *RHS, int n) {
	int row, col;

	const float h = 1.0F / (n-1);	
	const float h2i = 1.0F / (h*h);

	const int res_pitch  = FreeImage_GetPitch(RES) / sizeof(float);
	const int u_pitch  = FreeImage_GetPitch(U) / sizeof(float);
	const int rhs_pitch  = FreeImage_GetPitch(RHS) / sizeof(float);
	
	float *res_bits = (float*)FreeImage_GetBits(RES);
	const float *u_bits = (float*)FreeImage_GetBits(U);
	const float *rhs_bits = (float*)FreeImage_GetBits(RHS);

	// interior points
	{
		float *res_scan = res_bits + res_pitch;
		const float *u_scan = u_bits + u_pitch;
		const float *rhs_scan = rhs_bits + rhs_pitch;
		for (row = 1; row < n-1; row++) {
			for (col = 1; col < n-1; col++) {
				// calculate RES(row, col) = 
				// -h2i * [ U(row+1, col) + U(row-1, col) + U(row, col+1) + U(row, col-1) - 4 * U(row, col) ] + RHS(row, col);
				float *res_center = res_scan + col;
				const float *u_center = u_scan + col;
				const float *rhs_center = rhs_scan + col;
				*res_center = *(u_center + u_pitch) + *(u_center - u_pitch) + *(u_center + 1) + *(u_center - 1) - 4 * *u_center;
				*res_center *= -h2i;
				*res_center += *rhs_center;
			}
			res_scan += res_pitch;
			u_scan += u_pitch;
			rhs_scan += rhs_pitch;
		}
	}

	// boundary points
	{
		memset(FreeImage_GetScanLine(RES, 0), 0, FreeImage_GetPitch(RES));
		memset(FreeImage_GetScanLine(RES, n-1), 0, FreeImage_GetPitch(RES));
		float *left = res_bits;
		float *right = res_bits + (n-1);
		for(int k = 0; k < n; k++) {
			*left = 0;
			*right = 0;
			left += res_pitch;
			right += res_pitch;
		}
	}
}
开发者ID:Ayane,项目名称:BLPConverter,代码行数:54,代码来源:MultigridPoissonSolver.cpp


示例10: compatible

void ImageLoader::
compatible()
{
	// BITMAP数据是从下往上的, 需要翻转
	FreeImage_FlipVertical(mDIB);

	// FreeImage是BGR顺序, 与NVTT要求的一致, 而PVRT需要RGB顺序, 两者都需要32bits数据
	if (config.imageCompressionType != CT_DXTC)
	{
		// 将BGR改为RGB, 交换R channel和B channel
		const unsigned bytesperpixel = FreeImage_GetBPP(mDIB) / 8;
		const unsigned height = FreeImage_GetHeight(mDIB);
		const unsigned pitch = FreeImage_GetPitch(mDIB);
		const unsigned lineSize = FreeImage_GetLine(mDIB);

		BYTE* line = FreeImage_GetBits(mDIB);
		for (unsigned y = 0; y < height; ++y, line += pitch) {
			for (BYTE* pixel = line; pixel < line + lineSize; pixel += bytesperpixel) {
				INPLACESWAP(pixel[0], pixel[2]);
			}
		}
	}

	if (FreeImage_GetBPP(mDIB) != 32)
	{
		FIBITMAP* convertDIB = FreeImage_ConvertTo32Bits(mDIB);
		FreeImage_Unload(mDIB);
		mDIB = convertDIB;
	}
}
开发者ID:Napoleon314,项目名称:oiramExporter,代码行数:30,代码来源:ImageLoader.cpp


示例11: CreateTemplete

FIBITMAP * CreateTemplete(FIBITMAP * hImage, unsigned ScreenWidth, unsigned ScreenHeight) // 创建空白PNG模版
{
	FIBITMAP * hPicTemplete;
	RGBQUAD * palMain ;
	RGBQUAD * palTemplete ;
	unsigned ImgPitchLocal ;
	BYTE * pBitLocal;
	unsigned x, y, n;

	hPicTemplete = FreeImage_Allocate(ScreenWidth, ScreenHeight, 8, 0, 0, 0);  //创建目标图像
	palMain = FreeImage_GetPalette(hImage);
	palTemplete = FreeImage_GetPalette(hPicTemplete);
	for (n = 0 ; n < 256 ; n++) {
		palTemplete[n].rgbRed = palMain[n].rgbRed ;
		palTemplete[n].rgbGreen = palMain[n].rgbGreen ;
		palTemplete[n].rgbBlue = palMain[n].rgbBlue ;
	}
	palTemplete[70].rgbRed = 255   ;
	palTemplete[70].rgbGreen = 255 ;
	palTemplete[70].rgbBlue = 255  ;
//	FreeImage_SetTransparent(hPicTemplete, false);
	// 所有像素颜色填充为 70 号索引
	ImgPitchLocal = FreeImage_GetPitch(hPicTemplete) ;
	pBitLocal = FreeImage_GetBits(hPicTemplete);
	for (y = 0 ; y < ScreenHeight; y++) {
		for (x = 0; x < ScreenWidth ; x++)
			pBitLocal[x] = 70 ;
		pBitLocal += ImgPitchLocal ; // 下一行
	}
	return hPicTemplete;
}
开发者ID:linpinger,项目名称:foxbook-ahk,代码行数:31,代码来源:imgsplit_V1.8.3.cpp


示例12: NanScope

Image *Image::New(FIBITMAP* dib) {
  NanScope();

  Local<Value> arg = NanNew<Integer>(0);
  Local<Object> obj = NanNew<FunctionTemplate>(constructor_template)->GetFunction()->NewInstance(1, &arg);

  Image *image = ObjectWrap::Unwrap<Image>(obj);

  int w,h,pitch;
  FREE_IMAGE_TYPE type = FreeImage_GetImageType(dib);

  obj->SetInternalField(0, NanNew<External>(dib));
  obj->Set(NanNew<String>("width"), NanNew<Integer>(w=FreeImage_GetWidth(dib)));
  obj->Set(NanNew<String>("height"), NanNew<Integer>(h=FreeImage_GetHeight(dib)));
  obj->Set(NanNew<String>("bpp"), NanNew<Integer>((int)FreeImage_GetBPP(dib)));
  obj->Set(NanNew<String>("pitch"), NanNew<Integer>(pitch=FreeImage_GetPitch(dib)));
  obj->Set(NanNew<String>("type"), NanNew<Integer>(type));
  obj->Set(NanNew<String>("redMask"), NanNew<Integer>((int)FreeImage_GetRedMask(dib)));
  obj->Set(NanNew<String>("greenMask"), NanNew<Integer>((int)FreeImage_GetGreenMask(dib)));
  obj->Set(NanNew<String>("blueMask"), NanNew<Integer>((int)FreeImage_GetBlueMask(dib)));

  BYTE *bits = FreeImage_GetBits(dib);
  obj->Set(NanNew<String>("buffer"), NanNewBufferHandle((char*) bits, h * pitch));

  return image;
}
开发者ID:luismreis,项目名称:node-image,代码行数:26,代码来源:Image.cpp


示例13: NPP_ASSERT_MSG

void
FreeImageStack::loadImage(unsigned int iSlice, npp::ImageNPP_8u_C1 & rImage)
const
{
    NPP_ASSERT_MSG(iSlice < slices(), "Slice index exceeded number of slices in stack.");
    FIBITMAP * pBitmap = FreeImage_LockPage(pImageStack_, iSlice);
    NPP_ASSERT_NOT_NULL(pBitmap);
            // make sure this is an 8-bit single channel image
    NPP_DEBUG_ASSERT(FreeImage_GetColorType(pBitmap) == FIC_MINISBLACK);
    NPP_DEBUG_ASSERT(FreeImage_GetBPP(pBitmap) == 8);
    
    NPP_DEBUG_ASSERT(FreeImage_GetWidth(pBitmap) == nWidth_);
    NPP_DEBUG_ASSERT(FreeImage_GetHeight(pBitmap) == nHeight_);
    unsigned int    nSrcPitch = FreeImage_GetPitch(pBitmap);
    unsigned char * pSrcData  = FreeImage_GetBits(pBitmap);
    
    if (rImage.width() == nWidth_ && rImage.height() == nHeight_)
    {
        NPP_CHECK_CUDA(cudaMemcpy2D(rImage.data(), rImage.pitch(), pSrcData, nSrcPitch, 
                                    nWidth_, nHeight_, cudaMemcpyHostToDevice));
    }
    else
    {
                // create new NPP image
        npp::ImageNPP_8u_C1 oImage(nWidth_, nHeight_);
                // transfer slice data into new device image
        NPP_CHECK_CUDA(cudaMemcpy2D(oImage.data(), oImage.pitch(), pSrcData, nSrcPitch, 
                                    nWidth_, nHeight_, cudaMemcpyHostToDevice));
                // swap the result image with the reference passed into this method
        rImage.swap(oImage);
    }
                // release locked slice
    FreeImage_UnlockPage(pImageStack_, pBitmap, FALSE);
}
开发者ID:peterlu,项目名称:ConDDM,代码行数:34,代码来源:FreeImageStack.cpp


示例14: BasicLoadable

	FreeImage::FreeImage( const FreeImage & freeImage, const Math::Vec2<Size> & newSize, Filter resampleFilter ) :
		BasicLoadable( freeImage ),
		fileName( freeImage.fileName ),
		#ifdef WIN32
		fileNameW( freeImage.fileNameW ),
		#endif
		size( newSize ),
		invertY( freeImage.invertY ),
		loadingType( freeImage.loadingType ),
		BPP( freeImage.BPP ),
		loadingFormat( freeImage.loadingFormat ),
		resampleFilter( resampleFilter ) {
		if ( freeImage.isLoaded() ) {
			Math::Vec2<Size> toCopySize = freeImage.getSize();

			if ( this -> size != toCopySize )
				this -> freeImage = FreeImage_Rescale( freeImage.freeImage, this -> size.x, this -> size.y, ( FREE_IMAGE_FILTER ) this -> resampleFilter );
			else
				this -> freeImage = FreeImage_Clone( freeImage.freeImage );
		} else {
			this -> freeImage = freeImage.freeImage;	//Probably NULL
		}
		if ( this -> freeImage )
			this -> stride = FreeImage_GetPitch( this -> freeImage );
		else
			this -> stride = 0;
	}
开发者ID:Oriode,项目名称:Simplepp,代码行数:27,代码来源:FreeImage.cpp


示例15: invertColor

/**
Invert only color components, skipping Alpha/Black
(Can be useful as public/utility function)
*/
static
BOOL invertColor(FIBITMAP* dib) {
	FREE_IMAGE_TYPE type = FreeImage_GetImageType(dib);
	const unsigned Bpp = FreeImage_GetBPP(dib)/8;
	
	if((type == FIT_BITMAP && Bpp == 4) || type == FIT_RGBA16) {
		const unsigned width = FreeImage_GetWidth(dib);
		const unsigned height = FreeImage_GetHeight(dib);
		BYTE *line_start = FreeImage_GetScanLine(dib, 0);
		const unsigned pitch = FreeImage_GetPitch(dib);
		const unsigned triBpp = Bpp - (Bpp == 4 ? 1 : 2);
				
		for(unsigned y = 0; y < height; y++) {
			BYTE *line = line_start;

			for(unsigned x = 0; x < width; x++) {
				for(unsigned b=0; b < triBpp; ++b) {
					line[b] = ~line[b];
				}
					
				line += Bpp;
			}
			line_start += pitch;
		}
		
		return TRUE;
	}
	else {
		return FreeImage_Invert(dib);
	}
}
开发者ID:mdecicco,项目名称:HelloWorld,代码行数:35,代码来源:PSDParser.cpp


示例16: luminance

/**
Get the maximum, minimum and average luminance
@param dib Source Y image to analyze
@param maxLum Maximum luminance
@param minLum Minimum luminance
@param worldLum Average luminance (world adaptation luminance)
@return Returns TRUE if successful, returns FALSE otherwise
@see ConvertRGBFToY
*/
BOOL 
LuminanceFromY(FIBITMAP *dib, float *maxLum, float *minLum, float *worldLum) {
	if(FreeImage_GetImageType(dib) != FIT_FLOAT)
		return FALSE;

	unsigned width  = FreeImage_GetWidth(dib);
	unsigned height = FreeImage_GetHeight(dib);
	unsigned pitch  = FreeImage_GetPitch(dib);

	float max_lum = -1e20F, min_lum = 1e20F;
	double sum = 0;

	BYTE *bits = (BYTE*)FreeImage_GetBits(dib);
	for(unsigned y = 0; y < height; y++) {
		const float *pixel = (float*)bits;
		for(unsigned x = 0; x < width; x++) {
			const float Y = pixel[x];
			max_lum = (max_lum < Y) ? Y : max_lum;				// max Luminance in the scene
			min_lum = ((Y > 0) && (min_lum < Y)) ? min_lum : Y;	// min Luminance in the scene
			sum += log(2.3e-5 + Y);								// contrast constant in Tumblin paper
		}
		// next line
		bits += pitch;
	}
	// maximum luminance
	*maxLum = max_lum;
	// minimum luminance
	*minLum = min_lum;
	// average log luminance
	double avgLogLum = (sum / (width * height));
	// world adaptation luminance
	*worldLum = (float)exp(avgLogLum);

	return TRUE;
}
开发者ID:BackupTheBerlios,项目名称:mimplugins-svn,代码行数:44,代码来源:tmoColorConvert.cpp


示例17: getBmpFromPixels

FIBITMAP* getBmpFromPixels(ofPixels_<PixelType> &pix){
	PixelType* pixels = pix.getPixels();
	unsigned int width = pix.getWidth();
	unsigned int height = pix.getHeight();
	unsigned int bpp = pix.getBitsPerPixel();
	
	FREE_IMAGE_TYPE freeImageType = getFreeImageType(pix);
	FIBITMAP* bmp = FreeImage_AllocateT(freeImageType, width, height, bpp);
	unsigned char* bmpBits = FreeImage_GetBits(bmp);
	if(bmpBits != NULL) {
		int srcStride = width * pix.getBytesPerPixel();
		int dstStride = FreeImage_GetPitch(bmp);
		unsigned char* src = (unsigned char*) pixels;
		unsigned char* dst = bmpBits;
		for(int i = 0; i < (int)height; i++) {
			memcpy(dst, src, dstStride);
			src += srcStride;
			dst += dstStride;
		}
	} else {
		ofLogError() << "ofImage::getBmpFromPixels() unable to get FIBITMAP from ofPixels";
	}
	
	// ofPixels are top left, FIBITMAP is bottom left
	FreeImage_FlipVertical(bmp);
	
	return bmp;
}
开发者ID:prettyextreme,项目名称:openFrameworks-0.7,代码行数:28,代码来源:ofImage.cpp


示例18: FreeImage_GetImageType

Image *Image::New(FIBITMAP* dib) {

  HandleScope scope;

  Local<Value> arg = Integer::NewFromUnsigned(0);
  Local<Object> obj = constructor_template->GetFunction()->NewInstance(1, &arg);

  Image *image = ObjectWrap::Unwrap<Image>(obj);
  image->dib = dib;

  int w,h,pitch;
  FREE_IMAGE_TYPE type = FreeImage_GetImageType(dib);

  obj->SetInternalField(0, External::New(dib));
  obj->Set(JS_STR("width"), JS_INT(w=FreeImage_GetWidth(dib)));
  obj->Set(JS_STR("height"), JS_INT(h=FreeImage_GetHeight(dib)));
  obj->Set(JS_STR("bpp"), JS_INT((int)FreeImage_GetBPP(dib)));
  obj->Set(JS_STR("pitch"), JS_INT(pitch=FreeImage_GetPitch(dib)));
  obj->Set(JS_STR("type"), JS_INT(type));
  obj->Set(JS_STR("redMask"), JS_INT((int)FreeImage_GetRedMask(dib)));
  obj->Set(JS_STR("greenMask"), JS_INT((int)FreeImage_GetGreenMask(dib)));
  obj->Set(JS_STR("blueMask"), JS_INT((int)FreeImage_GetBlueMask(dib)));

  BYTE *bits=FreeImage_GetBits(dib);
  node::Buffer *buf = node::Buffer::New((char*)bits,h*pitch);
  obj->Set(JS_STR("buffer"), buf->handle_);

  return image;
}
开发者ID:davidlehn,项目名称:node-image,代码行数:29,代码来源:Image.cpp


示例19: luminance

/**
Get the maximum, minimum and average luminance.<br>
On input, pixel->red == Y, pixel->green == x, pixel->blue == y
@param Yxy Source Yxy image to analyze
@param maxLum Maximum luminance
@param minLum Minimum luminance
@param worldLum Average luminance (world adaptation luminance)
@return Returns TRUE if successful, returns FALSE otherwise
*/
BOOL 
LuminanceFromYxy(FIBITMAP *Yxy, float *maxLum, float *minLum, float *worldLum) {
	if(FreeImage_GetImageType(Yxy) != FIT_RGBF)
		return FALSE;

	const unsigned width  = FreeImage_GetWidth(Yxy);
	const unsigned height = FreeImage_GetHeight(Yxy);
	const unsigned pitch  = FreeImage_GetPitch(Yxy);

	float max_lum = 0, min_lum = 0;
	double sum = 0;

	BYTE *bits = (BYTE*)FreeImage_GetBits(Yxy);
	for(unsigned y = 0; y < height; y++) {
		const FIRGBF *pixel = (FIRGBF*)bits;
		for(unsigned x = 0; x < width; x++) {
			const float Y = MAX(0.0F, pixel[x].red);// avoid negative values
			max_lum = (max_lum < Y) ? Y : max_lum;	// max Luminance in the scene
			min_lum = (min_lum < Y) ? min_lum : Y;	// min Luminance in the scene
			sum += log(2.3e-5F + Y);				// contrast constant in Tumblin paper
		}
		// next line
		bits += pitch;
	}
	// maximum luminance
	*maxLum = max_lum;
	// minimum luminance
	*minLum = min_lum;
	// average log luminance
	double avgLogLum = (sum / (width * height));
	// world adaptation luminance
	*worldLum = (float)exp(avgLogLum);

	return TRUE;
}
开发者ID:Antranilan,项目名称:Sparky,代码行数:44,代码来源:tmoColorConvert.cpp


示例20: value

/**
Custom gamma correction based on the ITU-R BT.709 standard
@param dib RGBF image to be corrected
@param gammaval Gamma value (2.2 is a good default value)
@return Returns TRUE if successful, returns FALSE otherwise
*/
static BOOL 
REC709GammaCorrection(FIBITMAP *dib, const float gammaval) {
	if(FreeImage_GetImageType(dib) != FIT_RGBF)
		return FALSE;

	float slope = 4.5F;
	float start = 0.018F;
	
	const float fgamma = (float)((0.45 / gammaval) * 2);
	if(gammaval >= 2.1F) {
		start = (float)(0.018 / ((gammaval - 2) * 7.5));
		slope = (float)(4.5 * ((gammaval - 2) * 7.5));
	} else if (gammaval <= 1.9F) {
		start = (float)(0.018 * ((2 - gammaval) * 7.5));
		slope = (float)(4.5 / ((2 - gammaval) * 7.5));
	}

	const unsigned width  = FreeImage_GetWidth(dib);
	const unsigned height = FreeImage_GetHeight(dib);
	const unsigned pitch  = FreeImage_GetPitch(dib);

	BYTE *bits = (BYTE*)FreeImage_GetBits(dib);
	for(unsigned y = 0; y < height; y++) {
		float *pixel = (float*)bits;
		for(unsigned x = 0; x < width; x++) {
			for(int i = 0; i < 3; i++) {
				*pixel = (*pixel <= start) ? *pixel * slope : (1.099F * pow(*pixel, fgamma) - 0.099F);
				pixel++;
			}
		}
		bits += pitch;
	}

	return TRUE;
}
开发者ID:baiyunping333,项目名称:freeimagerip,代码行数:41,代码来源:tmoDrago03.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ FreeImage_GetScanLine函数代码示例发布时间:2022-05-30
下一篇:
C++ FreeImage_GetPalette函数代码示例发布时间: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