void Warp::imresize(const XImage& im_in, const float scale, const InterpType interp_type, XImage* im_out) const{ const int new_h = ceil(static_cast<int>(scale * im_in.rows())); const int new_w = ceil(static_cast<int>(scale * im_in.cols())); imresize(im_in, new_h, new_w, interp_type, im_out); }
void Warp::imresize(const XImage& im_in, const int new_h, const int new_w, const InterpType interp_type, XImage* im_out) const{ const int num_channels = im_in.channels(); (*im_out) = XImage(num_channels); for(int i = 0; i < num_channels; i++) imresize(im_in.at(i), new_h, new_w, interp_type, &(im_out->at(i))); }
BOOL XGraphicsOpenGL::LoadImg( LPCTSTR szFilename, int *pWidth, int *pHeight, DWORD **ppImage ) { XImage<DWORD> *pImage = new XImageiOS<DWORD>( TRUE ); if( pImage->Load( szFilename ) ) { *pWidth = pImage->GetMemWidth(); *pHeight = pImage->GetMemHeight(); DWORD **pp = (DWORD **)ppImage; pImage->MovePtr( pp ); *ppImage = (DWORD *)*pp; SAFE_DELETE( pImage ); return TRUE; } SAFE_DELETE_ARRAY( pImage ); return FALSE; }
BOOL XSurfaceOpenGL::CreatePNG( LPCTSTR szFilename, BOOL bSrcKeep ) { // g_Pool.AllocMark(5); XImage<DWORD> *pImage = new XImageiOS<DWORD>( GetbHighReso() ); pImage->Load( szFilename ); // 빈 텍스쳐 만듬. SetSrcImg( NULL, pImage->GetMemWidth(), pImage->GetMemHeight() ); int memw = GetMemWidth(); int memh = GetMemHeight(); // m_nWidth = pImage->GetWidth(); // m_nHeight = pImage->GetHeight(); // w,h값을 2^단위로 정렬한다. GLsizei alignedW = pImage->GetMemWidth(); GLsizei alignedH = pImage->GetMemHeight(); GRAPHICS->AlignPowSize( &alignedW, &alignedH ); m_nAlignedWidth = alignedW; m_nAlignedHeight = alignedH; // 정렬된 크기로 버텍스버퍼생성. CreateVertexBuffer( GetWidth(), GetHeight(), 0, 0, memw, memh, alignedW, alignedH ); glGenTextures( 1, &m_textureID ); XBREAK( m_textureID == 0 ); glBindTexture(GL_TEXTURE_2D, m_textureID ); if( m_textureID == 0 ) { XERROR( "memw:%d memh:%d", GetMemWidth(), GetMemHeight() ); return FALSE; } // gl텍스쳐로 쓰기 위해 크기를 정렬한다 { // g_Pool.AllocMark(4); DWORD *temp, *_temp, *src; temp = _temp = new DWORD[ alignedW * alignedH ]; memset( temp, 0, alignedW * alignedH * sizeof(DWORD) ); int i, j; src = pImage->GetTextureData(); for( i = 0; i < memh; i ++ ) { for( j = 0; j < memw; j ++ ) { *_temp++ = *src++; } _temp += (alignedW - memw); } glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, alignedW, alignedH, 0, GL_RGBA, GL_UNSIGNED_BYTE, temp ); SAFE_DELETE( temp ); // g_Pool.RestoreMark(4); } // 클래스내 보관용 이미지를 가져옴 if( bSrcKeep ) { DWORD *pSrcImg; pImage->MovePtr( &pSrcImg ); // Image메모리 소유권을 가져온다 SetSrcImg( pSrcImg, memw, memh ); } SAFE_DELETE( pImage ); // g_Pool.RestoreMark(5); /* if( bSrcKeep == FALSE ) { SAFE_DELETE( temp ); } else m_pSrcImg = temp; */ return TRUE; }
void XilinxGUI::ShowPic() { XImage ximg; ui.lblImageView->setScaledContents(true); ui.lblImageView->setPixmap( QPixmap::fromImage(*ximg.receiveImage()) ); }