本文整理汇总了C++中ImageType::getData方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageType::getData方法的具体用法?C++ ImageType::getData怎么用?C++ ImageType::getData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageType
的用法示例。
在下文中一共展示了ImageType::getData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: newIntImage
static jobject newIntImage(JNIEnv* env, ImageType& image) {
jclass cls = safeFindClassMacro(cls, "Lcom/intel/vpg/IntImage;")
jmethodID clsCons = safeFindMethodMacro(clsCons, cls, "<init>", "(II)V")
jobject jintImage = env->NewObject(cls, clsCons, image.getWidth(),
image.getHeight());
jfieldID dataField = env->GetFieldID(cls, "data", "[I");
jintArray jdata = (jintArray) env->GetObjectField(jintImage, dataField);
arrayCopyToJNIMacro(data, Int, jint, image.getData())
return jintImage;
}
示例2: draw
void GlutImage::draw()
{
if (m_firstRun)
{
glGenTextures(1, &m_texture);
m_firstRun = false;
}
glDisable(GL_LIGHTING);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBindTexture(GL_TEXTURE_2D, m_texture);
ImageType imageData;
if(image.tryTakeChanged(&imageData))
{
float maxPixel = imageData.getAsVector().maxCoeff();
if (maxPixel > 1.0)
{
float scaleFactor = 1.0 / maxPixel;
glPixelTransferf(GL_RED_SCALE, scaleFactor);
glPixelTransferf(GL_BLUE_SCALE, scaleFactor);
glPixelTransferf(GL_GREEN_SCALE, scaleFactor);
}
else
{
glPixelTransferf(GL_RED_SCALE, 1.0);
glPixelTransferf(GL_BLUE_SCALE, 1.0);
glPixelTransferf(GL_GREEN_SCALE, 1.0);
}
switch (imageData.getNumChannels())
{
case 1:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, static_cast<GLsizei>(imageData.getWidth()),
static_cast<GLsizei>(imageData.getHeight()), 0, GL_LUMINANCE, GL_FLOAT, imageData.getData());
break;
case 3:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, static_cast<GLsizei>(imageData.getWidth()),
static_cast<GLsizei>(imageData.getHeight()), 0, GL_RGB, GL_FLOAT, imageData.getData());
break;
}
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
}
glColor3d(1, 1, 1);
glBegin(GL_QUADS);
glTexCoord2f(1, 1);
glVertex2f(m_bounds.min()(0), m_bounds.min()(1));
glTexCoord2f(0, 1);
glVertex2f(m_bounds.max()(0), m_bounds.min()(1));
glTexCoord2f(0, 0);
glVertex2f(m_bounds.max()(0), m_bounds.max()(1));
glTexCoord2f(1, 0);
glVertex2f(m_bounds.min()(0), m_bounds.max()(1));
glEnd();
glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
}
示例3: draw
virtual void draw()
{
if (m_firstRun)
{
glGenTextures(1, &m_texture);
m_firstRun = false;
}
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(-m_numImages, m_numImages, -1, 1, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBindTexture(GL_TEXTURE_2D, m_texture);
ImageType imageData;
if(image.tryTakeChanged(&imageData))
{
float maxPixel = imageData.getAsVector().maxCoeff();
if (maxPixel > 1.0)
{
float scaleFactor = 1.0 / maxPixel;
glPixelTransferf(GL_RED_SCALE, scaleFactor);
glPixelTransferf(GL_BLUE_SCALE, scaleFactor);
glPixelTransferf(GL_GREEN_SCALE, scaleFactor);
}
else
{
glPixelTransferf(GL_RED_SCALE, 1.0);
glPixelTransferf(GL_BLUE_SCALE, 1.0);
glPixelTransferf(GL_GREEN_SCALE, 1.0);
}
switch (imageData.getNumChannels())
{
case 1:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, imageData.getWidth(), imageData.getHeight(), 0, GL_LUMINANCE,
GL_FLOAT, imageData.getData());
break;
case 3:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, imageData.getWidth(), imageData.getHeight(), 0, GL_RGB, GL_FLOAT,
imageData.getData());
break;
}
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
}
int xMin = -m_numImages + m_imageNum * 2;
glColor4f(1,1,1,1);
glBegin(GL_QUADS);
glTexCoord2f(1, 1);
glVertex2f(xMin, -1.0);
glTexCoord2f(0, 1);
glVertex2f(xMin+2, -1.0);
glTexCoord2f(0, 0);
glVertex2f(xMin+2, 1.0);
glTexCoord2f(1, 0);
glVertex2f(xMin, 1.0);
glEnd();
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
}