本文整理汇总了C++中FreeImage_GetPitch函数的典型用法代码示例。如果您正苦于以下问题:C++ FreeImage_GetPitch函数的具体用法?C++ FreeImage_GetPitch怎么用?C++ FreeImage_GetPitch使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FreeImage_GetPitch函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
}
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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;
}
示例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;
}
}
}
示例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;
}
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
}