当前位置: 首页>>代码示例>>C++>>正文


C++ FreeImage_GetScanLine函数代码示例

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


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

示例1: FIA_ComplexImageToRealValued

FIBITMAP* DLL_CALLCONV
FIA_ComplexImageToRealValued(FIBITMAP *src)
{
	FIBITMAP *dst = NULL;
	unsigned x, y;
						
	unsigned width	= FreeImage_GetWidth(src);
	unsigned height = FreeImage_GetHeight(src);

	// allocate a 8-bit dib
	dst = FreeImage_AllocateT(FIT_DOUBLE, width, height, 32, 0, 0, 0);
	
	if(!dst)
		return NULL;

	FICOMPLEX *src_bits; 	
	double	  *dst_bits; 

	for(y = 0; y < height; y++) { 
		
		src_bits = (FICOMPLEX *) FreeImage_GetScanLine(src, y);
		dst_bits = (double *) FreeImage_GetScanLine(dst, y);

		for(x=0; x < width; x++) {
			dst_bits[x] = (double) src_bits[x].r;
		}
	}

	return dst;
}
开发者ID:atdgroup,项目名称:FreeImageAlgorithms,代码行数:30,代码来源:FreeImageAlgorithms_FFT.cpp

示例2: FreeImage_GetWidth

template<class Tsrc> FIBITMAP* 
CONVERT_TO_COMPLEX<Tsrc>::convert(FIBITMAP *src) {
	FIBITMAP *dst = NULL;

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

	// allocate dst image

	dst = FreeImage_AllocateT(FIT_COMPLEX, width, height);
	if(!dst) return NULL;

	// convert from src_type to FIT_COMPLEX
	
	for(unsigned y = 0; y < height; y++) {
		const Tsrc *src_bits = reinterpret_cast<Tsrc*>(FreeImage_GetScanLine(src, y));
		FICOMPLEX *dst_bits = (FICOMPLEX *)FreeImage_GetScanLine(dst, y);

		for(unsigned x = 0; x < width; x++) {
			dst_bits[x].r = (double)src_bits[x];
			dst_bits[x].i = 0;
		}
	}

	return dst;
}
开发者ID:12019,项目名称:svn.gov.pt,代码行数:26,代码来源:ConversionType.cpp

示例3: FreeImage_Invert

/** @brief Inverts each pixel data.

@param src Input image to be processed.
@return Returns TRUE if successful, FALSE otherwise.
*/
BOOL DLL_CALLCONV 
FreeImage_Invert(FIBITMAP *src) {
	unsigned i, x, y, k;
	BYTE *bits;

	if (!src) return FALSE;

	int bpp = FreeImage_GetBPP(src);
	
	switch(bpp) {
        case 1 :
		case 4 :
		case 8 :
		{
			// if the dib has a colormap, just invert it
			// else, keep the linear grayscale

			if (FreeImage_GetColorType(src) == FIC_PALETTE) {
				RGBQUAD *pal = FreeImage_GetPalette(src);

				for(i = 0; i < FreeImage_GetColorsUsed(src); i++) {
					pal[i].rgbRed	= 255 - pal[i].rgbRed;
					pal[i].rgbGreen = 255 - pal[i].rgbGreen;
					pal[i].rgbBlue	= 255 - pal[i].rgbBlue;
				}
			} else {
				for(y = 0; y < FreeImage_GetHeight(src); y++) {
					bits = FreeImage_GetScanLine(src, y);

					for (x = 0; x < FreeImage_GetLine(src); x++) {
						bits[x] = ~bits[x];
					}
				}
			}

			break;
		}		

		case 24 :
		case 32 :
		{
			unsigned bytespp = FreeImage_GetLine(src) / FreeImage_GetWidth(src);

			for(y = 0; y < FreeImage_GetHeight(src); y++) {
				bits =  FreeImage_GetScanLine(src, y);
				for(x = 0; x < FreeImage_GetWidth(src); x++) {
					for(k = 0; k < bytespp; k++) {
						bits[k] = ~bits[k];
					}
					bits += bytespp;
				}
			}

			break;
		}

	}
	return TRUE;
}
开发者ID:Ali-il,项目名称:gamekit,代码行数:64,代码来源:Colors.cpp

示例4: fmg_solve

/**
Solution of the model problem on the coarsest grid, where h = 1/2 . 
The right-hand side is input
in rhs[0..2][0..2] and the solution is returned in u[0..2][0..2].
*/
static void fmg_solve(FIBITMAP *U, FIBITMAP *RHS) {
	// fill U with zeros
	fmg_fillArrayWithZeros(U);
	// calculate U(1, 1) = -h*h*RHS(1, 1)/4.0 where h = 1/2
	float *u_scan = (float*)FreeImage_GetScanLine(U, 1);
	const float *rhs_scan = (float*)FreeImage_GetScanLine(RHS, 1);
	u_scan[1] = -rhs_scan[1] / 16;
}
开发者ID:Ayane,项目名称:BLPConverter,代码行数:13,代码来源:MultigridPoissonSolver.cpp

示例5: FreeImage_GetChannel

/** @brief Retrieves the red, green, blue or alpha channel of a 24- or 32-bit BGR[A] image. 
@param src Input image to be processed.
@param channel Color channel to extract
@return Returns the extracted channel if successful, returns NULL otherwise.
*/
FIBITMAP * DLL_CALLCONV 
FreeImage_GetChannel(FIBITMAP *src, FREE_IMAGE_COLOR_CHANNEL channel) {
	int c;

	if(!src) return NULL;

	unsigned bpp = FreeImage_GetBPP(src);
	if((bpp == 24) || (bpp == 32)) {
		// select the channel to extract
		switch(channel) {
			case FICC_BLUE:
				c = FI_RGBA_BLUE;
				break;
			case FICC_GREEN:
				c = FI_RGBA_GREEN;
				break;
			case FICC_RED: 
				c = FI_RGBA_RED;
				break;
			case FICC_ALPHA:
				if(bpp != 32) return NULL;
				c = FI_RGBA_ALPHA;
				break;
			default:
				return NULL;
		}

		// allocate a 8-bit dib
		unsigned width  = FreeImage_GetWidth(src);
		unsigned height = FreeImage_GetHeight(src);
		FIBITMAP *dst = FreeImage_Allocate(width, height, 8) ;
		if(!dst) return NULL;
		// build a greyscale palette
		RGBQUAD *pal = FreeImage_GetPalette(dst);
		for(int i = 0; i < 256; i++) {
			pal[i].rgbBlue = pal[i].rgbGreen = pal[i].rgbRed = i;
		}

		// perform extraction

		int bytespp = bpp / 8;	// bytes / pixel

		for(unsigned y = 0; y < height; y++) {
			BYTE *src_bits = FreeImage_GetScanLine(src, y);
			BYTE *dst_bits = FreeImage_GetScanLine(dst, y);
			for(unsigned x = 0; x < width; x++) {
				dst_bits[x] = src_bits[c];
				src_bits += bytespp;
			}
		}

		return dst;
	}

	return NULL;
}
开发者ID:BackupTheBerlios,项目名称:tap-svn,代码行数:61,代码来源:Channels.cpp

示例6: compression

/**
Save using EXR_LC compression (works only with RGB[A]F images)
*/
static BOOL
SaveAsEXR_LC(C_OStream& ostream, FIBITMAP *dib, Imf::Header& header, int width, int height) {
    int x, y;
    Imf::RgbaChannels rgbaChannels;

    try {

        FREE_IMAGE_TYPE image_type = FreeImage_GetImageType(dib);

        // convert from float to half
        Imf::Array2D<Imf::Rgba> pixels(height, width);
        switch(image_type) {
        case FIT_RGBF:
            rgbaChannels = Imf::WRITE_YC;
            for(y = 0; y < height; y++) {
                FIRGBF *src_bits = (FIRGBF*)FreeImage_GetScanLine(dib, height - 1 - y);
                for(x = 0; x < width; x++) {
                    Imf::Rgba &dst_bits = pixels[y][x];
                    dst_bits.r = src_bits[x].red;
                    dst_bits.g = src_bits[x].green;
                    dst_bits.b = src_bits[x].blue;
                }
            }
            break;
        case FIT_RGBAF:
            rgbaChannels = Imf::WRITE_YCA;
            for(y = 0; y < height; y++) {
                FIRGBAF *src_bits = (FIRGBAF*)FreeImage_GetScanLine(dib, height - 1 - y);
                for(x = 0; x < width; x++) {
                    Imf::Rgba &dst_bits = pixels[y][x];
                    dst_bits.r = src_bits[x].red;
                    dst_bits.g = src_bits[x].green;
                    dst_bits.b = src_bits[x].blue;
                    dst_bits.a = src_bits[x].alpha;
                }
            }
            break;
        default:
            THROW (Iex::IoExc, "Bad image type");
            break;
        }

        // write the data
        Imf::RgbaOutputFile file(ostream, header, rgbaChannels);
        file.setFrameBuffer (&pixels[0][0], 1, width);
        file.writePixels (height);

        return TRUE;

    } catch(Iex::BaseExc & e) {
        FreeImage_OutputMessageProc(s_format_id, e.what());

        return FALSE;
    }

}
开发者ID:respu,项目名称:xsilium-engine,代码行数:59,代码来源:PluginEXR.cpp

示例7: dt2d

/* dt of 2d function using squared distance */
static void
dt2d (FIBITMAP * src)
{
    int width = FreeImage_GetWidth (src);
    int height = FreeImage_GetHeight (src);
    float *f = new float[MAX (width, height)];
    register int x, y;

    register float *src_ptr;

    // transform along columns
    for(x = 0; x < width; x++)
    {
        for(y = 0; y < height; y++)
        {

            src_ptr = (float *) FreeImage_GetScanLine (src, y);
            f[y] = src_ptr[x];
        }

        float *d = dt (f, height);

        for(y = 0; y < height; y++)
        {

            src_ptr = (float *) FreeImage_GetScanLine (src, y);
            src_ptr[x] = d[y];
        }

        delete[]d;
    }

    // transform along rows
    for(y = 0; y < height; y++)
    {
        src_ptr = (float *) FreeImage_GetScanLine (src, y);

        for(x = 0; x < width; x++)
        {
            f[x] = src_ptr[x];
        }

        float *d = dt (f, width);

        for(x = 0; x < width; x++)
        {
            src_ptr[x] = d[x];
        }

        delete[]d;
    }

    delete f;
}
开发者ID:atdgroup,项目名称:FreeImageAlgorithms,代码行数:55,代码来源:FreeImageAlgorithms_DistanceTransform.cpp

示例8: modify

/** @brief Insert a 8-bit dib into a 24- or 32-bit image. 
Both src and dst must have the same width and height.
@param dst Image to modify (24- or 32-bit)
@param src Input 8-bit image to insert
@param channel Color channel to modify
@return Returns TRUE if successful, FALSE otherwise.
*/
BOOL DLL_CALLCONV 
FreeImage_SetChannel(FIBITMAP *dst, FIBITMAP *src, FREE_IMAGE_COLOR_CHANNEL channel) {
	int c;

	if(!src || !dst) return FALSE;

	// src image should be grayscale, dst image should be 24- or 32-bit
	unsigned src_bpp = FreeImage_GetBPP(src);
	unsigned dst_bpp = FreeImage_GetBPP(dst);
	if((src_bpp != 8) || (dst_bpp != 24) && (dst_bpp != 32))
		return FALSE;

	// src and dst images should have the same width and height
	unsigned src_width  = FreeImage_GetWidth(src);
	unsigned src_height = FreeImage_GetHeight(src);
	unsigned dst_width  = FreeImage_GetWidth(dst);
	unsigned dst_height = FreeImage_GetHeight(dst);
	if((src_width != dst_width) || (src_height != dst_height))
		return FALSE;

	// select the channel to modify
	switch(channel) {
		case FICC_BLUE:
			c = FI_RGBA_BLUE;
			break;
		case FICC_GREEN:
			c = FI_RGBA_GREEN;
			break;
		case FICC_RED: 
			c = FI_RGBA_RED;
			break;
		case FICC_ALPHA:
			if(dst_bpp != 32) return FALSE;
			c = FI_RGBA_ALPHA;
			break;
		default:
			return FALSE;
	}

	// perform insertion

	int bytespp = dst_bpp / 8;	// bytes / pixel

	for(unsigned y = 0; y < dst_height; y++) {
		BYTE *src_bits = FreeImage_GetScanLine(src, y);
		BYTE *dst_bits = FreeImage_GetScanLine(dst, y);
		for(unsigned x = 0; x < dst_width; x++) {
			dst_bits[c] = src_bits[x];
			dst_bits += bytespp;
		}
	}

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

示例9: libraw_ConvertProcessedImageToDib

/**
Convert a processed raw image to a FIBITMAP
@param image Processed raw image
@return Returns the converted dib if successfull, returns NULL otherwise
@see libraw_LoadEmbeddedPreview
*/
static FIBITMAP * 
libraw_ConvertProcessedImageToDib(libraw_processed_image_t *image) {
	FIBITMAP *dib = NULL;

	try {
		unsigned width = image->width;
		unsigned height = image->height;
		unsigned bpp = image->bits;
		if(bpp == 16) {
			// allocate output dib
			dib = FreeImage_AllocateT(FIT_RGB16, width, height);
			if(!dib) {
				throw FI_MSG_ERROR_DIB_MEMORY;
			}
			// write data
			WORD *raw_data = (WORD*)image->data;
			for(unsigned y = 0; y < height; y++) {
				FIRGB16 *output = (FIRGB16*)FreeImage_GetScanLine(dib, height - 1 - y);
				for(unsigned x = 0; x < width; x++) {
					output[x].red   = raw_data[0];
					output[x].green = raw_data[1];
					output[x].blue  = raw_data[2];
					raw_data += 3;
				}
			}
		} else if(bpp == 8) {
			// allocate output dib
			dib = FreeImage_AllocateT(FIT_BITMAP, width, height, 24);
			if(!dib) {
				throw FI_MSG_ERROR_DIB_MEMORY;
			}
			// write data
			BYTE *raw_data = (BYTE*)image->data;
			for(unsigned y = 0; y < height; y++) {
				RGBTRIPLE *output = (RGBTRIPLE*)FreeImage_GetScanLine(dib, height - 1 - y);
				for(unsigned x = 0; x < width; x++) {
					output[x].rgbtRed   = raw_data[0];
					output[x].rgbtGreen = raw_data[1];
					output[x].rgbtBlue  = raw_data[2];
					raw_data += 3;
				}
			}
		}
		
		return dib;

	} catch(const char *text) {
		FreeImage_Unload(dib);
		FreeImage_OutputMessageProc(s_format_id, text);
		return NULL;
	}
}
开发者ID:TLeonardUK,项目名称:MicroBuild,代码行数:58,代码来源:PluginRAW.cpp

示例10: ConvertComplexImageToAbsoluteValued

static FIBITMAP*
ConvertComplexImageToAbsoluteValued(FIBITMAP *src, bool squared)
{
	FIBITMAP *dst = NULL;
	unsigned x, y;
						
	unsigned width	= FreeImage_GetWidth(src);
	unsigned height = FreeImage_GetHeight(src);

	// Allocate a double bit dib
	dst = FreeImage_AllocateT(FIT_DOUBLE, width, height, 32, 0, 0, 0);
	
	if(!dst)
		return NULL;

	FICOMPLEX *src_bits, *src_bit; 	
	double	  *dst_bits; 

	if(squared) {

		for(y = 0; y < height; y++) { 
		
			src_bits = (FICOMPLEX *) FreeImage_GetScanLine(src, y);
			dst_bits = (double *) FreeImage_GetScanLine(dst, y);

			for(x=0; x < width; x++) {
				
                src_bit = src_bits + x;

				*(dst_bits + x) = (double) ((src_bit->r * src_bit->r) + (src_bit->i * src_bit->i));
			}
		}
	}
	else {

		for(y = 0; y < height; y++) { 
		
			src_bits = (FICOMPLEX *) FreeImage_GetScanLine(src, y);
			dst_bits = (double *) FreeImage_GetScanLine(dst, y);

			for(x=0; x < width; x++) {
				
                src_bit = src_bits + x;

				*(dst_bits + x) = sqrt((double) ((src_bit->r * src_bit->r) + (src_bit->i * src_bit->i)));
			}
		}
	}

	return dst;
}
开发者ID:atdgroup,项目名称:FreeImageAlgorithms,代码行数:51,代码来源:FreeImageAlgorithms_FFT.cpp

示例11: 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

示例12: CopyImageRow

static inline void
CopyImageRow (FIBITMAP * src, int src_row, int row_start, int count)
{
    int pitch = FreeImage_GetPitch (src);

    BYTE *src_bits, *dst_bits;

    src_bits = FreeImage_GetScanLine (src, src_row);

    for(int y = row_start; y < (row_start + count); y++)
    {
        dst_bits = FreeImage_GetScanLine (src, y);
        memcpy (dst_bits, src_bits, pitch);
    }
}
开发者ID:glennpierce,项目名称:Fia,代码行数:15,代码来源:FreeImageAlgorithms_Border.cpp

示例13: FIA_DistanceTransform

/* dt of binary image using squared distance */
FIBITMAP *DLL_CALLCONV
FIA_DistanceTransform (FIBITMAP * src)
{
    int width = FreeImage_GetWidth (src);
    int height = FreeImage_GetHeight (src);
    float *out_ptr;
    unsigned char *src_ptr;

    FIBITMAP *out = FIA_ConvertToGreyscaleFloatType (src, FIT_FLOAT);

    for(register int y = 0; y < height; y++)
    {
        src_ptr = (unsigned char *) FreeImage_GetScanLine (src, y);
        out_ptr = (float *) FreeImage_GetScanLine (out, y);

        for(register int x = 0; x < width; x++)
        {

            if (src_ptr[x] == 0)
            {
                out_ptr[x] = 0.0f;
            }
            else
            {
                out_ptr[x] = INF;
            }
        }
    }

    dt2d (out);

    // take square roots
    for(register int y = 0; y < height; y++)
    {
        out_ptr = (float *) FreeImage_GetScanLine (out, y);

        for(register int x = 0; x < width; x++)
        {
            out_ptr[x] = sqrt (out_ptr[x]);
        }
    }

    FIBITMAP *ret = FreeImage_ConvertToStandardType (out, 1);

    FreeImage_Unload (out);

    return ret;
}
开发者ID:atdgroup,项目名称:FreeImageAlgorithms,代码行数:49,代码来源:FreeImageAlgorithms_DistanceTransform.cpp

示例14: LoadImage

bool LoadImage(FIBITMAP* image, Graphics::TBitmap* picture)
{
	picture->FreeImage();
	picture->PixelFormat = pf32bit;
	picture->Width = FreeImage_GetWidth(image);
	picture->Height = FreeImage_GetHeight(image);

	RGBQUAD *row1, *row2;

	for(int i(0); i < picture->Height; ++i)
	{
		row1 = (RGBQUAD *)FreeImage_GetScanLine(image,i);
		row2 = (RGBQUAD *)picture->ScanLine[picture->Height-1-i];		
		
		if(!row1 || !row2) return false;
		
		for(int j(0); j < picture->Width; ++j)
		{
			row2[j].rgbRed = row1[j].rgbRed;
			row2[j].rgbGreen = row1[j].rgbGreen;
			row2[j].rgbBlue = row1[j].rgbBlue;
		}
	}
	
	return true;
}
开发者ID:ClockMan,项目名称:edytorgraficzny,代码行数:26,代码来源:OpenImage.cpp

示例15: write_image

  void write_image(const string& file, const SampleBuffer& buffer)
  {
    const float samples = static_cast<float>(buffer.samples());
    FIBITMAP* dib = FreeImage_Allocate(buffer.width(), buffer.height(),
        32, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK);

    const unsigned int BYTESPP =
      FreeImage_GetLine(dib) / FreeImage_GetWidth(dib);
    for (unsigned int y = 0; y < FreeImage_GetHeight(dib); ++y) {
      BYTE* bits = FreeImage_GetScanLine(dib, y);

      for (unsigned int x = 0; x < FreeImage_GetWidth(dib); ++x) {
        vec3 c = gamma_correct(buffer.get(x, y) / samples) * 255.0f;
        bits[FI_RGBA_RED]   = static_cast<BYTE>(c.r);
        bits[FI_RGBA_GREEN] = static_cast<BYTE>(c.g);
        bits[FI_RGBA_BLUE]  = static_cast<BYTE>(c.b);
        bits[FI_RGBA_ALPHA] = 255;

        bits += BYTESPP;
      }
    }

    if (!FreeImage_Save(FIF_PNG, dib, file.c_str(), 0)) {
      string err = "Failed to save screenshot to file '";
      err += file;
      err += '\'';
      throw err;
    }

    FreeImage_Unload(dib);
  }
开发者ID:skyrpex,项目名称:pathtracer,代码行数:31,代码来源:samplebuffer.cpp


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