本文介绍了使用滑块控件增加/减少opengl纹理应用图像的强度或亮度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我希望通过MFC中的滑块控制移动来增加/减少图像的亮度。 我尝试了什么: i使用字节数组创建了opengl纹理应用图像。 m_pbyImageData = new BYTE [WIDTH * HEIGHT * PIXEL]; m_pbyImageData1 = new BYTE [WIDTH * HEIGHT * PIXEL]; TCHAR tcszFileName [MAX_PATH]; swprintf_s(tcszFileName,ptcszFilePath_i); FILE * pFile = NULL; _wfopen_s(& pFile,tcszFileName,_T ( RB)); if(NULL!= pFile) { fread(m_pbyImageData,WIDTH * HEIGHT * PIXEL,1,pFile); fclose(pFile); } GLuint glTexture; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_TEXTURE_2D); glGenTextures(1,& glTexture); glBindTexture (GL_TEXTURE_2D,glTexture); glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE); //选择调制以将纹理与颜色混合以进行着色 //当纹理区域较小时,双线性过滤最近的mipmap glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); //当纹理区域很大时,双线性过滤原始的 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); //纹理包裹在边缘(重复) glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP); glTexImage2D( GL_TEXTURE_2D,0,1,WIDTH,HEIGHT,0,GL_LUMINANCE,GL_UNSIGNED_BYTE,m_pbyImageData); //将纹理应用图像显示到屏幕 现在通过移动滑块我需要增加和减少强度这是怎么回事。请帮助我。解决方案 当然有可能:你必须写: 1. a滑块的处理函数 2.根据需要操纵强度位而不是制作 3.使用glTexImage2(....)在OpenGL中进行绘制调用 i want to increase/ decrease the brightness of the image by slider control movement in MFC.What I have tried:i created the opengl texture applied image using a byte array. m_pbyImageData = new BYTE[ WIDTH * HEIGHT * PIXEL ]; m_pbyImageData1 = new BYTE[ WIDTH * HEIGHT * PIXEL ]; TCHAR tcszFileName[MAX_PATH]; swprintf_s(tcszFileName, ptcszFilePath_i); FILE* pFile = NULL; _wfopen_s(&pFile, tcszFileName, _T("rb")); if ( NULL != pFile ) { fread(m_pbyImageData, WIDTH * HEIGHT * PIXEL, 1, pFile); fclose(pFile); } GLuint glTexture ; glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glEnable( GL_TEXTURE_2D ); glGenTextures( 1, &glTexture ); glBindTexture( GL_TEXTURE_2D, glTexture ); glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); // Select modulate to mix texture with color for shading // When texture area is small, bilinear filter the closest mipmap glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); // When texture area is large, bilinear filter the original glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); // The texture wraps over at the edges (repeat) glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP ); glTexImage2D( GL_TEXTURE_2D, 0, 1, WIDTH, HEIGHT, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, m_pbyImageData ); // To dislay texture applied image to screenNow by movement of slider i need to increase and decrease intensity how is this possible. Please help me. 解决方案 Of course it is possible: you must write :1. a handler function of your slider which2. manipulates the bits for the intensity as needed and than make3. a draw call in OpenGL with glTexImage2(....). 这篇关于使用滑块控件增加/减少opengl纹理应用图像的强度或亮度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-09 17:45