本文整理汇总了C++中magick::Image::flip方法的典型用法代码示例。如果您正苦于以下问题:C++ Image::flip方法的具体用法?C++ Image::flip怎么用?C++ Image::flip使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类magick::Image
的用法示例。
在下文中一共展示了Image::flip方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: save_rgb_float_image_to_file
void save_rgb_float_image_to_file(const char* file_name, float*& rgb_image, int width, int height)
{
Magick::Image image;
image.read(width, height, "RGB", Magick::FloatPixel, rgb_image);
image.flip();
image.write(file_name);
}
示例2: load
//----------------------------------------------------------------------------------------------------------------------
// Image Magick Image loading routines
//----------------------------------------------------------------------------------------------------------------------
bool Image::load( const std::string &_fname ) noexcept
{
#ifdef IMAGE_DEBUG_ON
std::cerr<<"loading with ImageMagick"<<std::endl;
#endif
Magick::Image image;
Magick::Blob blob;
try
{
image.read(_fname);
// need to flip image as OpenGL uses textures starting the other way round.
image.flip();
image.write(&blob, "RGBA");
}
catch (Magick::Error& Error)
{
std::cout << "Error loading texture '" << _fname << "': " << Error.what() << std::endl;
return false;
}
m_width=image.columns();
m_height=image.rows();
m_channels=4;
m_format=GL_RGBA;
m_data.reset(new unsigned char[ m_width*m_height*m_channels]);
// simple memcpy of the blob data to our internal data, not worrying about RGB/RGBA
// here (as OpenGL doesn't really either).
memcpy(m_data.get(),blob.data(),blob.length());
return true;
}
示例3: load_cube_map
void texture_t::load_cube_map( vector<string> const & files_names )
{
Magick::Image img;
for (int i = 0; i < files_names.size(); ++i)
{
img.read(files_names[i]);
int res_x = img.rows()
,res_y = img.columns();
scoped_array<unsigned char> data(new unsigned char[res_x * res_y * 3]);
if (i == 2 || i == 3)
img.flip();
else
img.flop();
img.write(0, 0, res_x, res_y, "RGB", CharPixel, data.get());
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB16, res_x, res_y, 0, GL_RGB
,GL_UNSIGNED_BYTE, data.get());
}
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
}
示例4: base_orient
// Orient an image's pixels as EXIF instructs
int base_orient(Exiv2::ExifData & exif, Magick::Image & img) {
int orient = -1;
try {
orient = exif["Exif.Image.Orientation"].toLong();
if (-1 == orient) {
orient = exif["Exif.Panasonic.Rotation"].toLong();
}
if (-1 == orient) {
orient = exif["Exif.MinoltaCs5D.Rotation"].toLong();
}
} catch (Exiv2::Error &) {}
if (1 > orient || 8 < orient) {
orient = 1;
}
switch (orient) {
case 2:
img.flop();
break;
case 3:
img.rotate(180.0);
break;
case 4:
img.flip();
break;
case 5:
img.rotate(90.0);
img.flip();
break;
case 6:
img.rotate(90.0);
break;
case 7:
img.rotate(270.0);
img.flip();
break;
case 8:
img.rotate(270.0);
break;
default:
break;
}
return orient;
}
示例5: drawScene
void drawScene() {
// get the axises
Vector3d ux = (camera->v % camera->vup).normalize();
Vector3d uy = camera->vup.normalize();
Vector3d uz = -camera->v.normalize();
Vector3d origin = camera->vp - (camera->focal * uz);
// loop over every pixel
for(int row = 0; row < image.rows(); row++) {
for(int col = 0; col < image.columns(); col++) {
Vector3d p = origin + camera->p(row, col, ux, uy);
Vector3d ur = perspective ? (p - camera->vp).normalize() : -uz;
double distance, min = -1;
Sphere* sphere;
// loop over the spheres
for(int i = 0; i < nspheres; i++) {
distance = spheres[i]->intersection(p, ur);
if(distance > 0 && (min < 0 || distance < min)) {
min = distance;
sphere = spheres[i];
}
}
Color color(0, 0, 0);
// if a sphere is hit loop over the lights
if(min > 0) {
Color ambient = sphere->material.color * sphere->material.ambient;
Color diffuse(0, 0, 0);
Color specular(0, 0, 0);
Vector3d hit = p + (ur * min);
for(int i = 0; i < 3; i++) {
diffuse = diffuse + lights[i]->diffuse(ur, hit, *sphere);
specular = specular + lights[i]->specular(ur, hit, *sphere);
}
Color reflection = Light::reflection(*sphere, ur, hit, spheres, nspheres, lights, nlights, 0);
// total up the color
color = ambient + diffuse + specular + reflection;
}
image.pixelColor(col, row, color.ColorRGB());
}
}
image.flip();
imageToPixmap();
}
示例6: loadTexture
void ObjectData::loadTexture(string objID, string textureFileName)
{
list<singleObject>::iterator iter;
for (iter = listOfObjects.begin() ; iter != listOfObjects.end(); iter++)
{
if ( iter->id == objID )
{
// load texture image
Magick::InitializeMagick("");
Magick::Image image;
Magick::Blob m_blob;
try
{
// Read a file into image object
if ( textureFileName != "")
{
image.read( textureFileName );
image.flip();
image.write(&m_blob, "RGBA");
}
else
{
throw std::invalid_argument("No texture file found");
}
}
catch(exception& tmp)
{
cout << "Error while reading in texture image, texture file not found" << endl;
}
int imageWidth = image.columns();
int imageHeight = image.rows();
// setup texture
glGenTextures(1, &(iter->bTexture));
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, iter->bTexture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, imageWidth, imageHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, m_blob.data());
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
}
}
示例7: ReadFile
//------------------------------------------------------------------------------
void Image::ReadFile(const std::string& _fileName)
{
//get data from file to local array
Magick::Image imageFile;
imageFile.read(_fileName);
imageFile.flip();
m_width = imageFile.columns();
m_height = imageFile.rows();
uint8_t* data = new uint8_t[ m_width * m_height * 4 ];
imageFile.write( 0, 0, m_width, m_height, "RGBA", Magick::CharPixel, data );
uint32_t size = m_width * m_height * 4;
m_pixels = std::vector<Color>(0);
for( uint32_t i=0; i< size; i+=4 )
{
uint32_t index = i/4.0;
if( index < m_width * m_height )
m_pixels.push_back ( Color ( data[i]/255.0, data[i+1]/255.0, data[i+2]/255.0, data[i+3]/255.0 ) );
}
delete [] data;
}
示例8: writeImage
void writeImage() {
if(filename != "") {
image.flip();
image.write(filename);
}
}
示例9: pixmapToImage
void pixmapToImage() {
Magick::PixelPacket* pixels = image.setPixels(0, 0, image.columns(), image.rows());
*pixels = *pixmap;
image.syncPixels();
image.flip();
}
示例10: imageToPixmap
void imageToPixmap() {
image.flip();
pixmap = image.getPixels(0, 0, image.columns(), image.rows());
}
示例11:
void Magick::flipImage::operator()( Magick::Image &image_ ) const
{
image_.flip( );
}
示例12: initialize
//.........这里部分代码省略.........
//Clean Up
//tempShape = NULL;
//delete objTriMesh;
//objTriMesh = NULL;
tempShape = NULL;
tempMotionState = NULL;
//--Load vertex shader and fragment shader from 2 text files
ShaderLoader loader("vertexShader.txt", "fragmentShader.txt");
program = loader.LoadShader();
//Now we set the locations of the attributes and uniforms
//this allows us to access them easily while rendering
loc_position = glGetAttribLocation(program,
const_cast<const char*>("v_position"));
if(loc_position == -1)
{
std::cerr << "[F] POSITION NOT FOUND" << std::endl;
return false;
}
loc_uv = glGetAttribLocation(program,
const_cast<const char*>("v_uv"));
if(loc_uv == -1)
{
std::cerr << "[F] V_UV NOT FOUND" << std::endl;
return false;
}
loc_mvpmat = glGetUniformLocation(program,
const_cast<const char*>("mvpMatrix"));
if(loc_mvpmat == -1)
{
std::cerr << "[F] MVPMATRIX NOT FOUND" << std::endl;
return false;
}
//--Init the view and projection matrices
// if you will be having a moving camera the view matrix will need to more dynamic
// ...Like you should update it before you render more dynamic
// for this project having them static will be fine
view = glm::lookAt( glm::vec3(.5, 7.0, 0), //Eye Position
glm::vec3(.5, 0.0, 0.0), //Focus point
glm::vec3(0.0, 0.0, 1.0)); //Positive Y is up
projection = glm::perspective( 45.0f, //the FoV typically 90 degrees is good which is what this is set to
float(w)/float(h), //Aspect Ratio, so Circles stay Circular
0.01f, //Distance to the near plane, normally a small value like this
100.0f); //Distance to the far plane,
// load texture image
Magick::InitializeMagick("");
Magick::Image image;
Magick::Blob m_blob;
try
{
// Read a file into image object
if ( textureFileName != "")
{
image.read( textureFileName );
image.flip();
image.write(&m_blob, "RGBA");
}
else
{
throw std::invalid_argument("No texture file found");
}
}
catch(exception& tmp)
{
cout << "Error while reading in texture image, texture file not found" << endl;
}
int imageWidth = image.columns();
int imageHeight = image.rows();
// setup texture
glGenTextures(1, &aTexture);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, aTexture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, imageWidth, imageHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, m_blob.data());
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
//enable depth testing
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
//and its done
return true;
}