Commit 1189d590 authored by IOhannes m zmölnig's avatar IOhannes m zmölnig
Browse files

made pix_test an image source

parent ed2ac330
......@@ -14,10 +14,11 @@
/////////////////////////////////////////////////////////
#include "pix_test.h"
#include "Gem/State.h"
CPPEXTERN_NEW(pix_test);
/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////
//
// pix_test
//
......@@ -25,12 +26,11 @@ CPPEXTERN_NEW(pix_test);
// Constructor
//
/////////////////////////////////////////////////////////
pix_test :: pix_test() :
orgImage(0), orgdata(0),
off(0), csize(2)
pix_test :: pix_test()
{
myImage.xsize=myImage.ysize=myImage.csize=1;
myImage.data = new unsigned char[1];
m_pix.image.xsize=m_pix.image.ysize=128;
m_pix.image.setCsizeByFormat(GL_RGBA_GEM);
m_pix.image.reallocate();
}
/////////////////////////////////////////////////////////
......@@ -44,22 +44,19 @@ pix_test :: ~pix_test()
// processImage
//
/////////////////////////////////////////////////////////
void pix_test :: processImage(imageStruct &image)
void pix_test :: render(GemState*state)
{
image.xsize=myImage.xsize=64;
image.ysize=myImage.ysize=64;
image.csize=myImage.csize=csize;
image.format=myImage.format=GL_YUV422_GEM;
myImage.reallocate();
int rows=image.xsize;
int cols=image.xsize;
unsigned char* data=myImage.data;
switch (myImage.format){
unsigned char off=128;
int rows=m_pix.image.xsize;
int cols=m_pix.image.ysize;
int datasize;
unsigned char* data=m_pix.image.data;
switch (m_pix.image.format){
case GL_RGBA:
while(rows--){
int col=cols/2;
while(col--){
data[0]=data[2]=255;
data[0]=data[2]=off;
data[1]=0; data[3]=255;
data+=4;
data[0]=data[1]=data[2]=0;data[3]=255;
......@@ -68,12 +65,9 @@ void pix_test :: processImage(imageStruct &image)
}
break;
case GL_YUV422_GEM:
post("hallo yuv");
// rows/=2;
int datasize=image.xsize*image.xsize*image.csize;
datasize=m_pix.image.xsize*m_pix.image.ysize*m_pix.image.csize;
while(datasize--)*data++=off;
break;
#if 0
while(rows--){
int col=cols;
while(col--){
......@@ -81,10 +75,15 @@ void pix_test :: processImage(imageStruct &image)
*data++=128;
}
}
#endif
break;
case GL_LUMINANCE:
datasize=rows*cols;
while(datasize-->0) {
*data++=off;
}
}
image.data=myImage.data;
m_pix.newimage=true;
state->set(GemState::_PIX, &m_pix);
}
/////////////////////////////////////////////////////////
......@@ -93,14 +92,31 @@ void pix_test :: processImage(imageStruct &image)
/////////////////////////////////////////////////////////
void pix_test :: obj_setupCallback(t_class *classPtr)
{
CPPEXTERN_MSG1(classPtr, "float", floatMess, unsigned int);
CPPEXTERN_MSG1(classPtr, "csize", csizeMess, unsigned int);
CPPEXTERN_MSG2(classPtr, "dimen", dimenMess, unsigned int, unsigned int);
CPPEXTERN_MSG1(classPtr, "colorspace", csMess, std::string);
}
void pix_test :: csizeMess(unsigned int n)
void pix_test :: csMess(std::string cs)
{
csize=n;
GLenum fmt=GL_RGBA_GEM;
char c=0;
if(cs.size()>0)
c=tolower(cs[0]);
switch(c) {
case 'r': fmt=GL_RGBA_GEM; break;
case 'y': fmt=GL_YUV422_GEM;break;
case 'g': fmt=GL_LUMINANCE; break;
default:
error("invalid colorspace '%s'; must be 'rgba', 'yuv' or 'grey'", cs.c_str());
return;
}
m_pix.image.setCsizeByFormat(fmt);
m_pix.image.reallocate();
m_pix.newfilm=true;
}
void pix_test :: floatMess(unsigned int n)
void pix_test :: dimenMess(unsigned int w, unsigned int h)
{
off=n;
m_pix.image.xsize=w;
m_pix.image.ysize=h;
m_pix.image.reallocate();
m_pix.newfilm=true;
}
......@@ -53,21 +53,12 @@ class GEM_EXTERN pix_test : public GemPixObj
//////////
// Do the processing
virtual void processImage(imageStruct &image);
virtual void render(GemState*);
//////////
// Do the processing - this is a no-op
virtual void processGrayImage(imageStruct &image) { }
imageStruct myImage;
imageStruct *orgImage;
unsigned char*orgdata;
unsigned char off;
unsigned char csize;
pixBlock m_pix;
void floatMess(unsigned int);
void csizeMess(unsigned int);
void dimenMess(unsigned int, unsigned int);
void csMess(std::string);
};
#endif // for header file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment