void imProcessPixelate(const imImage* src_image, imImage* dst_image, int box_size) { int hbox = ((src_image->width + box_size-1)/ box_size); int vbox = ((src_image->height + box_size-1)/ box_size); for (int i = 0; i < src_image->depth; i++) { imbyte *src_map=(imbyte*)src_image->data[i]; imbyte *dst_map=(imbyte*)dst_image->data[i]; int vbox_size = box_size; for (int bv = 0; bv < vbox; bv++) { int bv_pos = bv*box_size; if (bv == vbox-1) vbox_size = src_image->height - bv_pos; int hbox_size = box_size; for (int bh = 0; bh < hbox; bh++) { int bh_pos = bh*box_size; if (bh == hbox-1) hbox_size = src_image->width - bh_pos; int offset = bv_pos*src_image->width + bh_pos; int shift = src_image->width - hbox_size; unsigned char mean = BoxMean(src_map, offset, shift, hbox_size, vbox_size); BoxSet(dst_map, offset, shift, hbox_size, vbox_size, mean); } } } }
//----------------------------------------------------------------------- BoxRenderer::BoxRenderer(void) : ParticleRenderer() { // Create Box set mBoxSet = PU_NEW BoxSet("", 0, true); // World-relative axes mBoxSet->setBoxesInWorldSpace(true); autoRotate = false; }
Puzzle::Puzzle(char* puzzle, int length) { //The idea here is to convert a string into a puzzle. //The string must be made up of ASCI characters m_BoxSetWidth = (int)sqrt(sqrt((float)length)); m_PuzzleWidth = m_BoxSetWidth * m_BoxSetWidth; //create the boxes in linear order m_BoxSets = new BoxSet[m_PuzzleWidth]; for(int i = 0; i < m_PuzzleWidth; i++) m_BoxSets[i] = BoxSet(puzzle + i*m_PuzzleWidth, m_PuzzleWidth ); }