void SpriteSheet::LoadTexture(RESID spritesheet_res_id, bool invert_img_y) { // Load the sprite sheet texture FileResource spritesheet_res = ResourceLoader::GetBinResource(spritesheet_res_id); int width = 0, height = 0, channels = 0; unsigned char* texture_img = SOIL_load_image_from_memory((unsigned char*)spritesheet_res.bin_data, spritesheet_res.res_size, &width, &height, &channels, SOIL_LOAD_RGBA); tex_width_ = width; tex_height_ = height; if (invert_img_y) { unsigned char* inverted_image = InvertImage(texture_img, width, height, channels); SOIL_free_image_data(texture_img); texture_img = inverted_image; } glGenTextures(1, &spritesheet_texture_); glBindTexture(GL_TEXTURE_2D, spritesheet_texture_); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex_width_, tex_height_, 0, GL_RGBA, GL_UNSIGNED_BYTE, texture_img); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glBindTexture(GL_TEXTURE_2D, 0); if (invert_img_y) delete[] texture_img; else SOIL_free_image_data(texture_img); }
void Capture::update() { cvGrabFrame(m_capture); IplImage *frame = cvRetrieveFrame(m_capture); TmpBufferImage btmp(CV_8UC3); if ( frame != NULL ) { CvMat *mat = cvCreateMat(frame->height, frame->width, CV_8UC3); if ( m_invert ) { CvMat *tmp = btmp.getImage(frame->width, frame->height); cvConvertImage(frame, tmp, CV_CVTIMG_SWAP_RB); InvertImage(tmp, mat); } else { cvConvertImage(frame, mat, CV_CVTIMG_SWAP_RB); } m_wpipe.write(mat); } }
// Invert image using C++ with MMX void CChildView::OnInvertcolorsCMmx() { InvertImage(&CImg32Operations::InvertImageC_MMX); }
// Invert image using Assembly void CChildView::OnInvertcolorsAssemblyMmx() { InvertImage(&CImg32Operations::InvertImageAssembly_MMX); }
// Invert image using C++ void CChildView::OnInvertcolorsC() { InvertImage(&CImg32Operations::InvertImageCPlusPlus); }