void ofxTexture::DrawString(string text, ofxBitmapFont* font, ofRectangle dest_rect, unsigned char font_size) { if(m_Locked) return; // TODO: implement draw text with boundary float scale; if(font_size == 0) { scale = 1.0f; } else { scale = (float)font_size/font->GetFontSize(); } ofVec2f cursor(dest_rect.x, dest_rect.y); ilDisable(IL_BLIT_BLEND); for (int i = 0; i < text.size(); i++) { ofVec2f draw_region = scale*font->GetRect(text[i]); ILuint character_image = font->GetImageId(text[i]); ILuint dummy = ilGenImage(); ilBindImage(dummy); ilCopyImage(character_image); iluScale(draw_region.x, draw_region.y, 1); ilBindImage(m_ImageId); ilBlit(dummy, cursor.x, cursor.y, 0, 0, 0, 0, draw_region.x, draw_region.y, 1); ilDeleteImage(dummy); cursor.x += draw_region.x; } ilEnable(IL_BLIT_BLEND); }
void ofxTexture::BlockTransfer(ofxTexture* source, ofRectangle source_rect, ofVec2f dest_pos, int alpha) { if(m_Locked || source->IsLocked()) return; ilBindImage(m_ImageId); ilDisable(IL_BLIT_BLEND); ilBlit(source->GetDevilId(), dest_pos.x, dest_pos.y, 0, source_rect.x, source_rect.y, 0, source_rect.width, source_rect.height, 1); ilEnable(IL_BLIT_BLEND); }
//! Overlays the image found in Src on top of the current bound image at the coords specified. ILboolean ILAPIENTRY ilOverlayImage(ILuint Source, ILint XCoord, ILint YCoord, ILint ZCoord) { ILuint Width, Height, Depth; ILuint Dest; Dest = ilGetCurName(); ilBindImage(Source); Width = iCurImage->Width; Height = iCurImage->Height; Depth = iCurImage->Depth; ilBindImage(Dest); return ilBlit(Source, XCoord, YCoord, ZCoord, 0, 0, 0, Width, Height, Depth); }
void ofxTexture::Fill(ofFloatColor color, ofRectangle dest_rect) { if(m_Locked) return; ILuint dummy = ilGenImage(); ilBindImage(dummy); ilTexImage(dest_rect.width, dest_rect.height, 0, 4, IL_RGBA , IL_UNSIGNED_BYTE, NULL); ilClearColour(color.r, color.g, color.b, color.a); ilClearImage(); ilBindImage(m_ImageId); ilDisable(IL_BLIT_BLEND); ilBlit(dummy, dest_rect.x, dest_rect.y, 0, 0, 0, 0, dest_rect.width, dest_rect.height, 1); ilEnable(IL_BLIT_BLEND); ilDeleteImage(dummy); }
void ofxTexture::StretchTransfer(ofxTexture* source, ofRectangle source_rect, ofRectangle dest_rect, int alpha) { if(m_Locked || source->IsLocked()) return; ILuint dummy = ilGenImage(); ilBindImage(dummy); ilCopyImage(source->GetDevilId()); iluScale(dest_rect.width, dest_rect.height, 1); ilBindImage(m_ImageId); ilDisable(IL_BLIT_BLEND); ilBlit(dummy, dest_rect.x, dest_rect.y, 0, source_rect.x, source_rect.y, 0, source_rect.width, source_rect.height, 1); ilEnable(IL_BLIT_BLEND); ilDeleteImage(dummy); }
bool TextureControl::GenerateComposite(string sourceName,string modName,string outputName, unsigned int destSize, unsigned int mode ) { ILuint srctex = 0; ILuint modtex = 0; ILuint canvas = 0; if(namedImages.find(modName) == namedImages.end()) // mod not selected? return false; modtex = namedImages[modName]; ilBindImage(modtex); ILuint mW = ilGetInteger(IL_IMAGE_WIDTH); ILuint mH = ilGetInteger(IL_IMAGE_HEIGHT); if(destSize && (mW != destSize)) { iluImageParameter(ILU_FILTER, ILU_SCALE_BSPLINE); iluScale(destSize,destSize,1); mW = mH = destSize; } if(namedImages.find(sourceName) == namedImages.end()) // source not selected? return false; srctex = namedImages[sourceName]; ilBindImage(srctex); ILuint sW = ilGetInteger(IL_IMAGE_WIDTH); ILuint sH = ilGetInteger(IL_IMAGE_HEIGHT); if(destSize && (sW != destSize)) { iluImageParameter(ILU_FILTER, ILU_SCALE_BSPLINE); iluScale(destSize,destSize,1); sW = sH = destSize; } if(namedImages.find(outputName) != namedImages.end()) // already have an output? ilDeleteImage(namedImages[outputName]); if(sW < mW) { ilBindImage(modtex); iluImageParameter(ILU_FILTER, ILU_SCALE_BSPLINE); iluScale(sW,sH,1); ilBindImage(srctex); } else if(sW > mW){ iluImageParameter(ILU_FILTER, ILU_SCALE_BSPLINE); iluScale(mW,mH,1); sW=mW; sH=mH; } namedImages[outputName] = getImageHandle(); ilTexImage(sW,sH,1,4,IL_RGBA,IL_UNSIGNED_BYTE,NULL); ilBlit(srctex,0,0,0,0,0,0,sW,sH,1); ilEnable(IL_BLIT_BLEND); ilBlit(modtex,0,0,0,0,0,0,sW,sH,1); return true; }
void ilFBlit_(int *RetVal, int *Source, int *DestX, int *DestY, int *DestZ, int *SrcX, int *SrcY, int *SrcZ, int *Width, int *Height, int *Depth) { *RetVal = ilBlit(*Source, *DestX, *DestY, *DestZ, *SrcX, *SrcY, *SrcZ, *Width, *Height, *Depth); return; }