33 #include <FreeImage.h>
50 if(fif != FIF_UNKNOWN) {
67 m_ImagesProcessed = 0;
69 m_pResourceManager = NULL;
71 m_bLoadCompleted =
false;
72 m_pBufferLevels =
new moTextureFrames* [100];
73 for(
int i=0; i<100; i++ ) {
74 m_pBufferLevels[i] =
new moTextureFrames [10];
75 for(
int j = 0; j<10; j++ ) {
76 m_pBufferLevels[i][j].Init( 0 , NULL );
93 if (!m_pResourceManager)
106 pattern_width = p_pattern_width;
107 pattern_height = p_pattern_height;
111 str_format =
"LEVELS";
115 str_format =
"PATTERNS";
119 return Init( p_foldername, str_format, p_pResourceManager );
124 m_pResourceManager = p_pResourceManager;
126 m_FolderName = p_foldername;
128 m_BufferFormat = p_bufferformat;
133 if (!m_pDirectory)
return false;
143 m_Frames.Init( 0, NULL);
151 for(
int L=0; L<100*100*3; L++) {
161 for(
MOuint i=0; i<m_Frames.Count(); i++) {
165 delete pTextureMemory;
169 for(
int j=0 ; j<100; j++) {
170 if (m_pBufferLevels[j]!=NULL) {
171 for(
int k=0 ; k<10; k++) {
172 m_pBufferLevels[j][k].Empty();
174 delete [] m_pBufferLevels[j];
177 m_pBufferLevels = NULL;
184 m_pResourceManager = NULL;
190 return m_bLoadCompleted;
200 if (!m_pDirectory)
return false;
202 if (m_ActualImage>=(
MOint)m_pDirectory->
GetFiles().Count()) {
203 m_bLoadCompleted =
true;
207 if (m_ActualImage==0)
210 pFile = m_pDirectory->
Find(m_ActualImage);
217 FREE_IMAGE_FORMAT fif;
220 if( fif == FIF_UNKNOWN ) {
225 if( (fif != FIF_UNKNOWN) && FreeImage_FIFSupportsReading(fif) ) {
242 if ( m_ActualImage == (m_pDirectory->
GetFiles().Count()-2) ) {
246 barra =
moText(
"###################################################################################");
248 for(
int k=0; k<100; k++) {
250 nivel.
Left( m_pBufferLevels[k][0].Count() );
257 FreeImage_Unload(pImage);
266 if (counter==maxfiles && maxfiles!=(-1))
269 }
while ( (pFile = m_pDirectory->
FindNext()) );
279 FIBITMAP* _pImage = (FIBITMAP*)pImage;
280 FIBITMAP* pImageResult = NULL;
282 FIBITMAP* pImageScaled = NULL;
285 MODebug2->
Error(
"moTextureBuffer::LoadImage > indeximage invalid or unused for: " + p_ImageName);
297 pImageResult = _pImage;
300 if ( ( FreeImage_GetWidth(_pImage) % 4 ) != 0 || ( FreeImage_GetHeight(_pImage) % 4) == 0 ) {
302 w = FreeImage_GetWidth(_pImage) / 4;
305 h = FreeImage_GetHeight(_pImage) / 4;
308 pImageScaled = FreeImage_Rescale( pImageResult, w, h, FILTER_BICUBIC );
311 pImageResult = pImageScaled;
317 if (
RenderMan()->IsTextureNonPowerOf2Disabled()) {
319 w = FreeImage_GetWidth(pImageResult);
320 h = FreeImage_GetHeight(pImageResult);
323 for (i = 1; i < w; i *= 2);
326 for (i = 1; i < h; i *= 2);
332 pImageScaled = FreeImage_Rescale( pImageResult, w, h, FILTER_BICUBIC );
335 pImageResult = pImageScaled;
339 FreeImage_AdjustContrast( pImageResult, 0 );
340 FreeImage_AdjustBrightness( pImageResult, 0 );
373 if (pTextureMemory) {
376 m_Frames.Add(pTextureMemory);
378 int contrastlevel = pTextureMemory->
GetContrast() / 2000;
379 int luminancelevel = (int)((
float)pTextureMemory->
GetLuminance() / (float)2.56 ) - 1;
394 if (luminancelevel>=100) {
403 if (contrastlevel>=10) {
406 if (0<=luminancelevel && luminancelevel<100 && 0<=contrastlevel && contrastlevel<10) {
408 m_pBufferLevels[luminancelevel][contrastlevel].Add( pTextureMemory );
410 int icc = momin( m_pBufferLevels[luminancelevel][contrastlevel].Count(), 99 );
424 if (pImageResult!=_pImage)
425 FreeImage_Unload(pImageResult);
444 if (p_ImageReference && x>=0 && y>=0 && width>0 && height>0 ) {
445 return m_pBufferPatterns[index+0];
448 return m_pBufferPatterns[index];
455 if (p_ImageReference.
GetMOId() && x>=0 && y>=0 && width>0 && height>0 ) {
456 return m_pBufferPatterns[index+0];
458 return m_pBufferPatterns[index];
464 if (0<=L && L<100 && 0<=C && C<10) {
465 return m_pBufferLevels[L][C];
468 return m_pBufferLevels[99][0];
478 if ( p_i<m_Frames.Count()) {
484 return pTextureMemory->
GetGLId();
496 if ( p_i<m_Frames.Count()) {
506 if ( p_i<m_Frames.Count()) {
509 return pTextureMemory;
556 int m_id_default =
AddTexture(
"default", 256, 256);
565 if (DefaultTexture)
if (!DefaultTexture->
BuildFromFile(logoFile)) {
566 MODebug2->
Error(
"moTextureManager::Init > error loading " + logoFile );
569 m_id_default =
AddTexture(
"moldeonegro", 1800, 600);
575 moText(
"moldeonegro.png");
578 m_id_default =
AddTexture(
"moldeotrans", 1800, 600);
584 moText(
"moldeotrans.png");
588 if (DefaultTexture)
if (!DefaultTexture->
BuildFromFile(logoFile)) {
589 MODebug2->
Error(
"moTextureManager::Init > error loading " + logoFile );
608 if (-1 < moid)
return moid;
617 if (-1 < moid)
return moid;
630 if ((ptex != NULL) && (!stricmp(ptex->
GetName(), p_name))) {
631 if (p_refresh) ptex->
Refresh();
660 if (p_foldername.
Trim() ==
moText(
""))
return -1;
664 if ((ptexbuffer != NULL) && (!stricmp(ptexbuffer->
GetName(), p_foldername)))
return i;
685 if ((ptex != NULL) && (ptex->
GetGLId() == p_glid))
return i;
730 res = ptex_mov->
Load(p_value);
735 res = ptex_videobuffer->
Load(p_value);
740 res = ptex_circularvideobuffer->
Load(p_value);
809 moFile TexFileName( p_filename );
810 p_filename = TexFileName.GetAbsolutePath();
834 MODebug2->
Error(
"moTextureManager::AddTexture > filename: " + p_filename +
" failed BuildFromFile()/LoadMovieFile()");
852 MODebug2->
Error(
moText(
"moTextureManager::AddTextureBuffer Error: Initializing texturebuffer: ") + (
moText)p_foldername );
879 moText extension = p_filename;
880 moText begin = p_filename;
883 moFile FileName(p_filename);
886 if (!stricmp(extension,
".tga")
887 || !stricmp(extension,
".jpg")
888 || !stricmp(extension,
".png")
889 || !stricmp(extension,
".bmp")
890 || !stricmp(extension,
".tif")
891 || !stricmp(extension,
".xpm"))
893 if (!stricmp(begin,
"multiple"))
895 if (!stricmp(extension,
".mkv")
896 || !stricmp(extension,
".ogg")
897 || !stricmp(extension,
".ogv")
898 || !stricmp(extension,
".avi")
899 || !stricmp(extension,
".mov")
900 || !stricmp(extension,
".mpg")
901 || !stricmp(extension,
".mpeg")
902 || !stricmp(extension,
".mts")
903 || !stricmp(extension,
".m2ts")
904 || !stricmp(extension,
".vob")
905 || !stricmp(extension,
".m2v")
906 || !stricmp(extension,
".mp4")
907 || !stricmp(extension,
".web")
908 || !stricmp(extension,
".webm"))
958 ptex = (
moTexture*)ptex_circularvideobuffer;
978 for (
MOuint i = 0; i < nfiles; i++)
1000 if (Events==NULL)
return;
virtual void ReleaseFrame(MOuint p_i)
void FreeImageErrorHandler(FREE_IMAGE_FORMAT fif, const char *message)
MOint GetTextureBuffer(moText p_foldername, MOboolean p_create_tex=true, moText p_bufferformat="JPGAVERAGE")
virtual ~moTextureBuffer()
Parámetros internos de una textura.
static void Message(moText p_text)
Anuncia un mensaje al usuario además de guardarlo en el log de texto.
moTextureArray m_textures_array
moTextureBufferFormat
Buffer de imágenes.
void Error(moText p_text)
Anuncia y registra un error.
virtual MOboolean Finish()
void SetName(const moText &p_name)
moValueBase & GetSubValue(MOint p_indexsubvalue=0)
MOboolean BuildFromBuffer(MOuint p_width, MOuint p_height, const GLvoid *p_buffer, GLenum p_format=GL_RGBA, GLenum p_type=GL_UNSIGNED_BYTE)
moDefineDynamicArray(moTextureBuffers) moDefineDynamicArray(moTextureFrames) void FreeImageErrorHandler(FREE_IMAGE_FORMAT fif
MOboolean LoadImage(moText p_ImageName, moBitmap *pImage, int indeximage)
una textura animada basada en una película
static void Error(moText p_text)
Anuncia un error.
MOboolean Load(moParam *p_param)
MOboolean LoadCompleted()
virtual moTextureMemory * GetTexture(MOuint p_i)
void SetMOId(MOuint p_moid)
MOint AddTexture(MOuint p_type, moText p_name, moTexParam p_tex_param=MODefTex2DParams)
void SetResourceType(moResourceType p_restype)
virtual int GetFrame(MOuint p_i)
moGLManager * m_glmanager
MOboolean BuildEmpty(MOuint p_width, MOuint p_height)
MOboolean LoadMovieFile(moText p_filename)
moFile * Find(MOint index)
moText GetExtension()
Get absolute path and filename "/D/PP/myFileName.txt".
moFBManager * m_fbmanager
void AddFrame(moTexture *p_texture)
clase de para manejar textos
moTexture * GetTexture(MOuint p_moid)
moResourceManager * m_pResourceManager
Puntero al administrador de recursos.
moTextureBuffers m_textures_buffers
Dispositivo de entrada/salida, típicamente, interfaces humanas de IO y datos ( teclado, mouse, tableta, tcp, udp, serial )
void Log(moText p_text)
Escribe un mensaje en el archivo de registro (log)
MOboolean UpdateImages(int maxfiles=-1)
Buffer de imágenes para video.
virtual MOboolean Init()
Inicializa el objeto.
MOboolean DeleteTexture(MOuint p_moid)
moFileManager * GetFileMan()
MOuint GetGLId(MOuint p_moid)
MOboolean ValidTexture(MOuint p_moid)
MOuint GetTypeForFile(moText p_filename)
MOint GetTextureMOId(moParam *param, MOboolean p_create_tex)
int m_preview_texture_idx
clase base para el manejo de una textura
moDirectory * GetDirectory(moText p_Path)
moText GetCompletePath()
Get inmediate folder name: return "PP" for "PP/myFileName.txt".
Administrador de recursos.
MOboolean CreateMultipleTex(moTextureMultiple *p_tex_mult, moParam *p_param)
moTextureFrames & GetBufferPatterns(moTexture *p_ImageReference, int x, int y, int width=0, int height=0)
void SetLabelName(const moText &p_labelname)
static moDebug * MODebug2
Clase de impresión de errores para depuración
moMoldeoObjectType GetType() const
virtual void Update(moEventList *Events)
moDataManager * GetDataMan()
virtual ~moTextureManager()
virtual MOboolean Init(moText p_name, MOuint p_moid, moResourceManager *p_res, moTexParam p_param=MODefTex2DParams)
MOboolean BuildFromFile(moText p_filename)
moTextureFrames & GetBufferLevels(int L, int C)
void Push(moText p_text)
Apila el mensaje dentro de la pila de mensajes.
moValue & GetValue(MOint i=-1)
MOboolean Load(moParam *p_param)
MOint AddTextureBuffer(moText p_foldername, moText p_bufferformat="JPGAVERAGE")
LIBMOLDEO_API moText0 IntToStr(int a)
MOboolean IsBuildedFromFile() const
virtual MOboolean BuildFromBitmap(moBitmap *p_bitmap, moText p_bufferformat="JPG")
Guarda el bitmap con el formato elegido en memoria, luego construye la textura opengl.
clase base para el manejo de una textura con su copia comprimida en memoria
MOuint GetSubValueCount()
MOboolean m_bInitialized
Valor de inicialización
virtual MOboolean Finish()
Finaliza el objeto, libera recursos.
Circular Video Buffer for live loop video recording.
void Message(moText p_text)
Anuncia un mensaje al usuario además de guardarlo en el log de texto.
moTexture * CreateTexture(MOuint p_type, moText p_name, moTexParam p_param=MODefTex2DParams)
virtual MOboolean Finish()
void SetType(moMoldeoObjectType p_type)
moTextureManager * GetTextureMan()