本文整理汇总了C++中BMP::SetSize方法的典型用法代码示例。如果您正苦于以下问题:C++ BMP::SetSize方法的具体用法?C++ BMP::SetSize怎么用?C++ BMP::SetSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BMP
的用法示例。
在下文中一共展示了BMP::SetSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PadBMP
void PadBMP( BMP& Input , int NewWidth , int NewHeight )
{
// if the NewWidth and NewHight are unchanged, exit
if( NewWidth == Input.TellWidth() &&
NewHeight == Input.TellHeight() )
{
return;
}
// find max range for the copy, so that cropping occurs
// if necessary
int MaxWidth = Input.TellWidth();
if( MaxWidth > NewWidth )
{
MaxWidth = NewWidth;
}
int MaxHeight = Input.TellHeight();
if( MaxHeight > NewHeight )
{
MaxHeight = NewHeight;
}
// create a temporary image to hold the original pixels
BMP Temp;
Temp.SetSize(NewWidth,NewHeight);
Temp.SetBitDepth( Input.TellBitDepth() );
int i,j;
int Difference = Temp.TellHeight() - MaxHeight;
for( i=0 ; i < MaxWidth ; i++ )
{
for( j=0 ; j < MaxHeight ; j++ )
{
*Temp(i,j+Difference) = *Input(i,j);
}
}
// resize the original image, and recopy the pixels
Input.SetSize(NewWidth,NewHeight);
for( i=0 ; i < Input.TellWidth() ; i++ )
{
for( j=0 ; j < Input.TellHeight() ; j++ )
{
*Input(i,j) = *Temp(i,j);
}
}
Temp.SetSize(1,1);
Temp.SetBitDepth(24);
return;
}
示例2:
static cell AMX_NATIVE_CALL n_FSetImageSize( AMX* amx, cell* params ){
posx = params[1];
posy = params[2];
GlobalImage.CreateStandardColorTable();
GlobalImage.SetSize(posx,posy);
return 1;
}
示例3: buildImage
// Utility function which rebuilds an image from a list of pixels
void buildImage(BMP & image, List<RGBApixel> theList, int width, int height)
{
if (width * height != theList.length()) {
cout << "Error: invalid parameters to buildImage.\n";
return;
}
image.SetSize(width, height);
int x = 0, y = 0;
theList.front();
for (int pos = 0; pos < theList.length(); pos++) {
*image(x,y) = theList.retrieve();
// move to next pixel position
x++;
if (x >= width) {
x = 0;
y++;
}
// avoid spurious warning message
if (pos != theList.length() - 1)
theList.forwardOne();
}
}
示例4: BMP
// creates a BMP from a CImage
// assumes all float values have already been scaled to [0.0, 255.0]
BMP * CImage::toBmp()
{
BMP * bmp = new BMP();
bmp->SetSize(m_width, m_height);
// for smaller output file size
bmp->SetBitDepth(8);
// 8-bit bitmaps need a color table
CreateGrayscaleColorTable(*bmp);
for (int col = 0; col < m_width; col++)
{
for (int row = 0; row < m_height; row++)
{
// Output is grayscale, so R, G, and B components are equal.
// ScaleAndDisplayDisparityValues() et. al. in stereo.cpp have already
// scaled all float pixel values to [0, 255].
ebmpBYTE byteVal = (ebmpBYTE) getValue(row, col, 0);
(* bmp)(col, row)->Red = byteVal;
(* bmp)(col, row)->Green = byteVal;
(* bmp)(col, row)->Blue = byteVal;
}
}
return bmp;
}
示例5: array2bmp
//数组转图像
void array2bmp()
{
int i,j;
BMP bmp;
RGBApixel pix_black={0};//R=0 G=0 B=0为黑色
RGBApixel pix_white={255,255,255,0};//白色
bmp.SetSize(3,3);
bmp.SetBitDepth(1);
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
if(array[i][j]==1)
{
bmp.SetPixel( i, j,pix_black);
}
else
{
bmp.SetPixel( i, j,pix_white);
}
}
}
bmp.WriteToFile("examp_array2bmp.bmp");
printf("array2bmp suc...\n");
}
示例6: EasyBMP_Screenshot
bool EasyBMP_Screenshot( const char* FileName )
{
BMP Output;
GLsizei viewport[4];
glGetIntegerv( GL_VIEWPORT , viewport );
int width = viewport[2] - viewport[0];
int height = viewport[3] - viewport[1];
Output.SetSize(width,height);
GLint swapbytes, lsbfirst, rowlength, skiprows, skippixels, alignment;
/* Save current pixel store state. */
glGetIntegerv(GL_UNPACK_SWAP_BYTES, &swapbytes);
glGetIntegerv(GL_UNPACK_LSB_FIRST, &lsbfirst);
glGetIntegerv(GL_UNPACK_ROW_LENGTH, &rowlength);
glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skiprows);
glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &skippixels);
glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
/* Set desired pixel store state. */
glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE);
glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
RGBApixel* pixels;
pixels = new RGBApixel [ Output.TellWidth() * Output.TellHeight() ];
glReadPixels( viewport[0],viewport[1], width,height, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
int n=0;
for( int j=Output.TellHeight()-1 ; j >= 0 ; j-- )
{
for( int i=0; i < Output.TellWidth() ; i++ )
{
Output(i,j)->Red = (pixels[n]).Blue;
Output(i,j)->Green = (pixels[n]).Green;
Output(i,j)->Blue = (pixels[n]).Red;
n++;
}
}
/* Restore current pixel store state. */
glPixelStorei(GL_UNPACK_SWAP_BYTES, swapbytes);
glPixelStorei(GL_UNPACK_LSB_FIRST, lsbfirst);
glPixelStorei(GL_UNPACK_ROW_LENGTH, rowlength);
glPixelStorei(GL_UNPACK_SKIP_ROWS, skiprows);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, skippixels);
glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
Output.WriteToFile( FileName );
return true;
}
示例7: raytrace
void Camera::raytrace(Node *node, const std::vector<Light*>& lights) {
BMP output;
output.SetSize(width,height);
output.SetBitDepth(24);
for(int i = 0; i < width; i++) {
for(int j = 0; j < height; j++) {
output(i,j)->Red = 0;
output(i,j)->Green = 0;
output(i,j)->Blue = 0;
}
}
float aRatio = (float)width/height;
glm::vec3 xAxis = glm::cross(fwd, up);
glm::vec3 yAxis = glm::cross(xAxis, fwd);
float xFov = std::atan(std::tan(yFov) * aRatio);
xAxis *= std::tan(xFov/2) * glm::length(fwd) / glm::length(xAxis);
yAxis *= std::tan(yFov/2) * glm::length(fwd) / glm::length(yAxis);
for(unsigned int j = 0; j < height; j++) {
std::cout << "\rline " << j << std::flush;
#pragma omp parallel for
for(unsigned int i = 0; i < width; i++) {
// indirect illumination
glm::vec3 color(0);
for(int d = 0; d < density; d++) {
float x = (float(i) + float(rand())/RAND_MAX) / width;
float y = (float(j) + float(rand())/RAND_MAX) / height;
std::cout << "dbg " << fwd << " " << xAxis << " " << yAxis << "\n";
glm::vec3 dir = glm::normalize(fwd + (2*x-1)*xAxis + (1-2*y)*yAxis);
Ray ray(pos, dir, rayCount, true);
glm::vec4 dirCol = rayIter(ray, node, lights);
glm::vec3 mcCol;
if(dirCol[3] < 1 && mcIter > 0) {
for(int w = 0; w < mcIter; w++)
mcCol += rayIter(ray,node);
mcCol /= float(mcIter);
} else {
dirCol[3] = 1;
}
color += (1.f - dirCol[3])*mcCol + dirCol[3]*glm::vec3(dirCol);
}
color /= float(density);
output(i,j)->Red = 255.0*glm::clamp(color[0],0.f,1.f);
output(i,j)->Green = 255.0*glm::clamp(color[1],0.f,1.f);
output(i,j)->Blue = 255.0*glm::clamp(color[2],0.f,1.f);
}
}
output.WriteToFile(outFile.c_str());
exit(0);
}
示例8: main
int main( int argc, char *argv[] )
{
cout << endl
<< "Using EasyBMP Version " << _EasyBMP_Version_ << endl << endl
<< "Copyright (c) by the EasyBMP Project 2005-6" << endl
<< "WWW: http://easybmp.sourceforge.net" << endl << endl;
BMP Text;
Text.ReadFromFile("EasyBMPtext.bmp");
BMP Background;
Background.ReadFromFile("EasyBMPbackground.bmp");
BMP Output;
Output.SetSize( Background.TellWidth() , Background.TellHeight() );
Output.SetBitDepth( 24 );
RangedPixelToPixelCopy( Background, 0, Output.TellWidth() - 1,
Output.TellHeight() - 1 , 0,
Output, 0, 0 );
RangedPixelToPixelCopyTransparent( Text, 0, 380,
43, 0,
Output, 110, 5,
*Text(0, 0) );
RangedPixelToPixelCopyTransparent( Text, 0, Text.TellWidth() - 1,
Text.TellWidth() - 1, 50,
Output, 100, 442,
*Text(0, 49) );
Output.SetBitDepth( 32 );
cout << "writing 32bpp ... " << endl;
Output.WriteToFile( "EasyBMPoutput32bpp.bmp" );
Output.SetBitDepth( 24 );
cout << "writing 24bpp ... " << endl;
Output.WriteToFile( "EasyBMPoutput24bpp.bmp" );
Output.SetBitDepth( 8 );
cout << "writing 8bpp ... " << endl;
Output.WriteToFile( "EasyBMPoutput8bpp.bmp" );
Output.SetBitDepth( 4 );
cout << "writing 4bpp ... " << endl;
Output.WriteToFile( "EasyBMPoutput4bpp.bmp" );
Output.SetBitDepth( 1 );
cout << "writing 1bpp ... " << endl;
Output.WriteToFile( "EasyBMPoutput1bpp.bmp" );
Output.SetBitDepth( 24 );
Rescale( Output, 'p' , 50 );
cout << "writing 24bpp scaled image ..." << endl;
Output.WriteToFile( "EasyBMPoutput24bpp_rescaled.bmp" );
return 0;
}
示例9: writeToBMPFile
bool Image::writeToBMPFile(const std::string & outputFileName)
{
bool success = true;
if( m_pixels != NULL )
{
// create bitmap image
BMP outputImage;
outputImage.SetSize(m_numCols, m_numRows);
outputImage.SetBitDepth( 24 );
double maxVal = m_pixels[0];
double minVal = m_pixels[0];
// Maximum and minimum values
for( int i = 1; i < m_numRows * m_numCols; ++i )
{
if( m_pixels[i] > maxVal )
{
maxVal = m_pixels[i];
}
if( m_pixels[i] <= minVal )
{
minVal = m_pixels[i];
}
}
for( int r = 0; r < m_numRows; ++r )
{
for( int c = 0; c < m_numCols; ++c )
{
// get pixel value and clamp between 0 and 255
double val = 255.0 * (m_pixels[r * m_numCols + c] - minVal) / (maxVal - minVal);
if( val < 0 )
{
val = 0;
}
if( val > 255 )
{
val = 255;
}
// set output color based on mapping
RGBApixel pixelVal;
pixelVal.Blue = (int)val; pixelVal.Green = (int)val; pixelVal.Red = (int)val;
outputImage.SetPixel(c, r, pixelVal);
}
}
// write to file
success = outputImage.WriteToFile( outputFileName.c_str() );
}
else
{
success = false;
}
return success;
}
示例10: HBITMAPtoBMP
bool HBITMAPtoBMP(HDC hDC,HBITMAP hBitmap,BMP& OutputImage)
{
using namespace std;
bool output = false;
BITMAPINFO BitInfo;
ZeroMemory(&BitInfo, sizeof(BITMAPINFO));
BitInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
// get all manner of information from the incoming bitmap
if(!::GetDIBits(hDC, hBitmap, 0, 0, NULL, &BitInfo, DIB_RGB_COLORS))
{ return false; }
// Set the size and bit depth of the BMP object
OutputImage.SetSize( BitInfo.bmiHeader.biWidth ,BitInfo.bmiHeader.biHeight );
OutputImage.SetBitDepth(32);
// reconfigure BitInfo.bmiHeader such that the resulting bitmap will be
// 32 bits per pixel. This is _MUCH_ simpler
BitInfo.bmiHeader.biBitCount = 32;
BitInfo.bmiHeader.biCompression = 0;
BitInfo.bmiHeader.biSizeImage = OutputImage.TellHeight()*OutputImage.TellWidth()*4;
// I don't understand the +5 part here. -- Paul
// BYTE *pData = new BYTE[BitInfo.bmiHeader.biSizeImage + 5];
// BYTE *pData = new BYTE[Output.TellHeight()*Output.TellWidth()*4+5];
BYTE *pData = new BYTE [BitInfo.bmiHeader.biSizeImage];
// now get the actual data
if(!::GetDIBits(hDC, hBitmap, 0, BitInfo.bmiHeader.biHeight, pData, &BitInfo, DIB_RGB_COLORS))
{ return false; }
// transfer that data into the BMP object
int i,j;
int k=0;
for( j=OutputImage.TellHeight()-1 ; j >= 0 ; j-- )
{
for( i=0; i < OutputImage.TellWidth() ; i++ )
{
OutputImage(i,j)->Blue = *(pData+k); k++;
OutputImage(i,j)->Green = *(pData+k); k++;
OutputImage(i,j)->Red = *(pData+k); k++;
OutputImage(i,j)->Alpha = *(pData+k); k++;
}
}
delete (pData);
return true;
}
示例11: w2f
void w2f(GlobalMap &globalMap, int i, int j, int size=1025)
{
char fileName[6] = {'0','0','.','b','m','p'};
fileName[0]=i+48;
fileName[1]=j+48;
short z;
RGBApixel color;
BMP image;
image.SetSize(size,size);
image.SetBitDepth(16);
for(int y=0; y<size; y++)
{
for(int x=0; x<size; x++)
{
z= globalMap.getLocalMap(i,j)->getHeight(x,y);
if(z<0)
{
color.Red=0;
color.Green=0;
color.Blue=(z+32768)/129;
color.Alpha=0;
}
if(z>=0 && z<20000)
{
color.Red=0;
color.Green=z/134+100;
color.Blue=0;
color.Alpha=0;
}
if(z>=20000 && z<25000)
{
color.Red=(z-20000)/500+200;
color.Green=(z-20000)/500+200;
color.Blue=(z-20000)/500+200;
color.Alpha=0;
}
if(z>=25000)
{
color.Red=255;
color.Green=255;
color.Blue=255;
color.Alpha=0;
}
image.SetPixel(x,y, color);
}
}
image.WriteToFile(fileName);
}
示例12: pixelsToBitmap
void BitmapRawConverter::pixelsToBitmap(char *outFilename) {
BMP out;
out.SetSize(width, height);
out.SetBitDepth(24);
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
out.SetPixel(i, j, getPixel(i,j));
}
}
out.WriteToFile(outFilename);
}
示例13: CopyBMP
void CopyBMP( BMP& Input , BMP& Output )
{
Output.SetSize( Input.TellWidth() , Input.TellHeight() );
for( int j=0 ; j < Input.TellHeight() ; j++ )
{
for( int i=0 ; i < Input.TellWidth() ; i++ )
{
*Output(i,j) = *Input(i,j);
}
}
return;
}
示例14: main
int main(int argc, char** argv) {
if (argc != 2) {
cout << "Incorrect input. Please enter the name of the configuration file." << endl;
return -1;
}
Reader * config = new Reader(argv[1]);
int width = config->getWIDTH();
int height = config->getHEIGHT();
int x = config->getX();
int y = config->getY();
int z = config->getZ();
Camera * rayGenerator = new Camera(config->getEYEP(), config->getVDIR(),
config->getUVEC(), config->getFOVY(), width, height);
BMP output;
output.SetSize(width, height);
output.SetBitDepth(24);
Raymarch * raymarch = new Raymarch(config->getVB(), rayGenerator, config->getEYEP(),
config->getMRGB(), config->getBRGB(),
config->getLCOL(), config->getLPOS(), config->getOFST());
for (int w = 0; w < width; w++) {
cout << "Rendering: " << (float) w/width << endl;
for (int h = 0; h < height; h++) {
/*
// Ray direction color test
output(w,h)->Red = abs(rayGenerator->getRayDirection(w,h).x) *255;
output(w,h)->Green = abs(rayGenerator->getRayDirection(w,h).y) *255;
output(w,h)->Blue = abs(rayGenerator->getRayDirection(w,h).z) *255;
*/
glm::vec3 colors = raymarch->getColor(w,h, config->getSTEP(), glm::vec3(x, y, z));
colors*=255.0;
if (colors.x > 255)
colors.x = 255;
if (colors.y > 255)
colors.y = 255;
if (colors.z > 255)
colors.z = 255;
output(w,h)->Red =colors.x;
output(w,h)->Green = colors.y;
output(w,h)->Blue = colors.z;
}
}
output.WriteToFile(config->getFILE());
cout << "File has been finished rendering." <<endl;
return 0;
}
示例15: printImage
void Camera::printImage(char* outputName) {
BMP output;
output.SetSize(imgWidth, imgHeight);
output.SetBitDepth(24);
glm::vec3 outR;
for (int i = 0; i < imgWidth; i++) {
for (int j = 0; j < imgHeight; j++) {
outR = glm::abs(glm::normalize(getDirectionFromCoordinate(i,j)-eye));
output(i,j)->Red = outR.x * 255;
output(i,j)->Green = outR.y * 255;
output(i,j)->Blue = outR.z * 255;
}
}
output.WriteToFile(outputName);
}