CIwTexture* Transitions2D::CaptureScreen() { int w = IwGxGetDeviceWidth(); int h = IwGxGetDeviceHeight(); int length = w * h * 4; uint8* buffer = new uint8[length]; glReadPixels(0, 0, w, h, 0x1908, 0x1401, buffer); uint8* buffer2 = new uint8[length]; int lineSize = w * 4; uint8* b1 = buffer; uint8* b2 = buffer2 + h * lineSize;; for(int y = h; y > 0; y--) { b2 -= lineSize; for(int x = w; x > 0; x--) { *b2++ = *b1++; *b2++ = *b1++; *b2++ = *b1++; *b2++ = *b1++; } b2 -= lineSize; } CIwTexture* texture = new CIwTexture; CIwImage& img = texture->GetImage(); img.SetFormat(CIwImage::ABGR_8888); img.SetWidth(w); img.SetHeight(h); img.SetBuffers(buffer2, length); //img.SaveBmp("screenshot.bmp"); texture->SetMipMapping(false); texture->Upload(); delete buffer; delete buffer2; return texture; }
CzTexture CzPlatformImaging::CreateTexture(CzTexture source, CzImage::eFormat format) { CIwImage::Format f = toMarmImageFormat(format); if (f == CIwImage::FORMAT_UNDEFINED) return NULL; CIwTexture* t = static_cast<CIwTexture*>(source); CIwImage* image = new CIwImage(); image->SetFormat(f); image->SetWidth(t->GetWidth()); image->SetHeight(t->GetHeight()); t->GetImage().ConvertToImage(image); CIwTexture* texture = new CIwTexture(); texture->_SetFlags( CIwTexture::NO_CHROMA_KEY_F ); texture->SetMipMapping(t->GetMipMapping()); texture->SetFiltering(t->GetFiltering()); texture->SetModifiable(t->GetModifiable()); texture->CopyFromImage(image); delete image; return (CzTexture)texture; }
void CzPlatformImaging::SaveTextureAsJpeg(CzTexture texture, const char* filename) { CIwTexture* t = static_cast<CIwTexture*>(texture); t->GetImage().SaveJpg(filename); }