/** \brief Rotate a canvas. * * Apply a 180-degree transformation to a canvas, choosing characters * that look like the upside-down version wherever possible. Some * characters will stay unchanged by the process, but the operation is * guaranteed to be involutive: performing it again gives back the * original canvas. * * This function never fails. * * \param cv The canvas to rotate. * \return This function always returns 0. */ int caca_rotate_180(caca_canvas_t *cv) { uint32_t *cbegin = cv->chars; uint32_t *cend = cbegin + cv->width * cv->height - 1; uint32_t *abegin = cv->attrs; uint32_t *aend = abegin + cv->width * cv->height - 1; int y; if(!cbegin) return 0; while(cbegin < cend) { uint32_t ch; uint32_t attr; /* Swap attributes */ attr = *aend; *aend = *abegin; *abegin = attr; /* Swap characters */ ch = *cend; *cend = rotatechar(*cbegin); *cbegin = rotatechar(ch); cbegin++; cend--; abegin++; aend--; } if(cbegin == cend) *cbegin = rotatechar(*cbegin); /* Fix fullwidth characters. Could it be done in one loop? */ for(y = 0; y < cv->height; y++) { cbegin = cv->chars + y * cv->width; cend = cbegin + cv->width - 1; for( ; cbegin < cend; cbegin++) { if(cbegin[0] == CACA_MAGIC_FULLWIDTH) { cbegin[0] = cbegin[1]; cbegin[1] = CACA_MAGIC_FULLWIDTH; cbegin++; } } } if(!cv->dirty_disabled) caca_add_dirty_rect(cv, 0, 0, cv->width, cv->height); return 0; }
void OsdSetTitle(char *s,int a) { // Compose the title, condensing character gaps arrow=a; char zeros=0; char i=0,j=0; char outp=0; while(1) { int c=s[i++]; if(c && (outp<64)) { unsigned char *p = &charfont[c][0]; for(j=0;j<8;++j) { unsigned char nc=*p++; if(nc) { zeros=0; titlebuffer[outp++]=nc; } else if(zeros==0) { titlebuffer[outp++]=0; zeros=1; } if(outp>63) break; } } else break; } for(i=outp;i<64;++i) { titlebuffer[i]=0; } // Now centre it: int c=(63-outp)/2; for(i=(63-c);i>=0;--i) { titlebuffer[i+c]=titlebuffer[i]; } for(i=0;i<c;++i) titlebuffer[i]=0; // Finally rotate it. for(i=0;i<64;i+=8) { unsigned char tmp[8]; rotatechar(&titlebuffer[i],tmp); for(c=0;c<8;++c) { titlebuffer[i+c]=tmp[c]; } } }