void OnKeyS() { int nRow = g_nCurBoxRow + 1; if (IsCanMove(nRow, g_nCurBoxCol)) { ClearBox(); g_nCurBoxRow++; CreateNewBox(g_nCurBoxType, g_nCurBoxSubType, g_nCurBoxRow, g_nCurBoxCol); ShowGame(); } else { FixBox(); ReleaseLine(); g_nCurBoxType = rand() % (sizeof(g_szBox) / 64); g_nCurBoxSubType = rand() % 4; g_nCurBoxRow = 0; g_nCurBoxCol = 4; CreateNewBox(g_nCurBoxType, g_nCurBoxSubType, g_nCurBoxRow, g_nCurBoxCol); ShowGame(); } }
//---------------------------------------------------------------------------------------------------------- // x1/y1: old, x2,y2: new // Not really optimized, just good enough to avoid flickering void SWDecoder::ClearFrame(uint x1, uint y1, uint x2, uint y2) { uint w=width,h=height_ar; w+=2+4*BORDER; h+=2+4*BORDER; x1-=2*BORDER; y1-=2*BORDER; x2-=2*BORDER; y2-=2*BORDER; // upper/lower bar if (y1<y2) ClearBox(x1,y1,w,y2-y1+2*BORDER); else if (y1>y2) ClearBox(x1,y2+height_ar,w,y1-y2+2*BORDER+2); // left/right bar if (x1<x2) ClearBox(x1,y2,x2-x1+2*BORDER,h); else if (x1>x2) ClearBox(x2+width,y1,x1-x2+2*BORDER+2,h); }
void DrawTable(const struct CGUIConstItem *Table) { assert(Table); assert(Table->Kind==IDK_TABLE); TableCtrlSpec=((struct CTableCtrl *)(Table->Specific)); tLeft = Table->Left; tTop = Table->Top; tWidth = Table->Width; tHeight = Table->Height; ClearBox(tLeft,tTop,tWidth,tHeight); RectangleSet(tLeft,tTop,tWidth,tHeight); hLine(tLeft+1,tTop+tHeight-2,tWidth-2); vLine(tLeft+tWidth-2,tTop+1,tHeight-3); Cols = TableCtrlSpec->ColCount; Rows = TableCtrlSpec->RowCount; Cell = Table->Contained; AddToDequeTail((void *)Cell,&DrawQueue); // Заголовок таблиці vLine(Cell->Width+Cell->Left-4,tTop+1,tHeight-3); for (i=1;i<Cols;i++) { ++Cell; vLine(Cell->Left-2,tTop+1,tHeight-3); } ++Cell; hLine(tLeft+1,Cell->Top-3,tWidth-3); // друк по рядках for (j=1;j<Rows;j++) { hLine(tLeft+1,Cell->Top-2,tWidth-3); Cell+=Cols; /* for (i=1;i<Cols;i++) { ++Cell; if (Cell->Additional->IsEnabled) DrawLimitedString(Cell->Left+4,Cell->Top+2,Cell->Width-4,Cell->Height-2, ((struct CEditBoxItem *)(Cell->Specific))->Text,guiNormalFont); else DrawLimitedString(Cell->Left+4,Cell->Top+2,Cell->Width-4,Cell->Height-2, ((struct CEditBoxItem *)(Cell->Specific))->Text,guiDisabledFont); } ++Cell;*/ } }
void OnKeyD() { int nCol = g_nCurBoxCol + 1; if (IsCanMove(g_nCurBoxRow, nCol)) { ClearBox(); g_nCurBoxCol++; CreateNewBox(g_nCurBoxType, g_nCurBoxSubType, g_nCurBoxRow, g_nCurBoxCol); ShowGame(); } }
void OnKeyW() { int nSubType = (g_nCurBoxSubType + 1) % 4; if (IsCanRotate(nSubType)) { ClearBox(); g_nCurBoxSubType = (g_nCurBoxSubType + 1) % 4; CreateNewBox(g_nCurBoxType, g_nCurBoxSubType, g_nCurBoxRow, g_nCurBoxCol); ShowGame(); } }
/***************************************************************************** * CharToBox(iChar) * * purpose: assigns matBox(2-d array containing ready pixel info. on char being * edited) according to pixels in portion of bitmap corresp. to char. * * params: BYTE iChar : index of char in bitmap offset array(offsets) * * returns: none * * side effects: changes matBox * ****************************************************************************/ VOID CharToBox( BYTE iChar ) { DWORD x, y, offset; HMENU hMenu; ClearBox(); offset = offsets[iChar]; wBox = (DWORD)(wBoxOld = (WORD) (offsets[iChar + 1] - offset)); /* Edit Box width */ kBox = font.PixHeight; /* Edit Box Height */ for (x = 0; x < wBox; x++) for (y = 0; y < kBox; y++) matBox[x][y] = (BYTE) (GetPixel(hMemDC, offset + x, y) ? 1 : 0); InvalidateRect(hBox, (LPRECT)NULL, TRUE); fEdited = FALSE; /* Not Changed Yet */ hMenu = GetMenu(hBox); EnableMenuItem(hMenu, BOX_UNDO, MF_GRAYED); EnableMenuItem(hMenu, BOX_REFRESH, MF_GRAYED); }
DBoundingBox::DBoundingBox () { ClearBox (); }
//---------------------------------------------------------------------------------------------------------- int SWDecoder::Convert(void) { uint qi=qin%PICS_BUF; uint dar1,dar2; // Aspect of decoded Frame uint var1,var2; // Aspect of video display dar1=av_context->sample_aspect_ratio.num; dar2=av_context->sample_aspect_ratio.den; var1=HdCommChannel::hda->aspect.w; var2=HdCommChannel::hda->aspect.h; // Adjust height depending on aspect ratio if ((!img_convert_ctx || av_context->width!=dec_width || av_context->height!=dec_height || dar1!=dec_num || dar2!=dec_den) && av_context->width && av_context->height && var2 && dar1) { if (img_convert_ctx) sws_freeContext(img_convert_ctx); // Cleanup old area, only for a valid height_ar if (height_ar > 0u) { ClearBox(xpos-BORDER,ypos-BORDER, width+2*BORDER, height_ar + 2*BORDER); } height_ar=(height*var1*av_context->height*dar2)/(var2*av_context->width*dar1); EmptyFrame(); img_convert_ctx = sws_getContext(av_context->width, av_context->height, PIX_FMT_YUV420P, width, height_ar, PIX_FMT_RGBA32, SWS_BILINEAR | SWS_CPU_CAPS_MMX, NULL, NULL, NULL); dec_width=av_context->width; dec_height=av_context->height; dec_num=dar1; dec_den=dar2; } if (!img_convert_ctx) { // printf("PiP Error initializing swscale context.\n"); return -1; } avpicture_fill((AVPicture *) rgb_frame[qi], rgb_buffer[qi], PIX_FMT_RGBA32, width, height); // Security check... if (decoded_frame->data && decoded_frame->linesize && rgb_frame[qi]->data && rgb_frame[qi]->linesize) sws_scale(img_convert_ctx, decoded_frame->data, decoded_frame->linesize, 0, av_context->height, rgb_frame[qi]->data, rgb_frame[qi]->linesize ); if (qi!=((qout-1)%PICS_BUF)) qin++; else { // Throw away current frame, throttle burst decoding a bit printf("PiP Queue overflow %i %i\n",qin,qout); start_stc=0; usleep(5*1000); } if (!show_enabled && qin>8) { printf("Enable PiP out\n"); show_enabled=1; } return 0; }
//---------------------------------------------------------------------------------------------------------- // Draw an empty frame and if drawImage=true then show NO_PIP_IMAGE // avoid drawing NO_PIP_IMAGE if it was already drawn void SWDecoder::EmptyFrame(bool drawImage) { uint n,m; int *z; int aval=60+alpha/4; int bval=(aval<<24)|(aval<<16)|(aval<<8)|aval; Byte **rows; int w, h; bool read_image_success = false; // requested draw NO_PIP_IMAGE and it was already drawn. // Do nothing. if (drawImage && noPipImageDrawn) { printf("nothing to do\n"); return; } if (drawImage) { // height_ar should be height of NO_PIP_IMAGE read_image_success = png_file_2_rgb(NO_PIP_IMAGE, rows, w, h); if (read_image_success) // read a png image { // if earlier pip-channel had a different aspect ratio // and therefore large height. Clear pip window. if (h < height_ar) ClearBox(xpos-BORDER,ypos-BORDER,width+2*BORDER,height_ar+2*BORDER); //prevent subsequent unnecessary calls to ClearBox() height_ar = h; } // if read_image_success else esyslog("%s:%d PiP image '%s' file not read successfully by png_file_2_rgb", __FILE__, __LINE__, NO_PIP_IMAGE); } // if (drawImage) // no border required, new PiP icon has its own #if 0 // draw empty frame here for(n=0;n<BORDER;n++) { z=(int*)(framebuffer+fbwidth*(n+ypos-BORDER)+xpos-BORDER); memset(z,bval,(width+BORDER*2)*4); z=(int*)(framebuffer+fbwidth*(n+ypos+height_ar)+xpos-BORDER); memset(z,bval,(width+BORDER*2)*4); } for(n=0;n<height_ar;n++) { z=(int*)(framebuffer+fbwidth*(n+ypos)+xpos-BORDER); for(m=0;m<BORDER;m++) *z++=bval; z=(int*)(framebuffer+fbwidth*(n+ypos)+xpos+width); for(m=0;m<BORDER;m++) *z++=bval; } #endif // draw NO_PIP_IMAGE ? if (!drawImage) return ; // only empty frame // could not read image if (!read_image_success) { noPipImageDrawn = false; return; } // if // draw NO_PIP_IMAGE on to OSD int al = (0xff<<24); // alpha ch printf("png_2_rgb w=%d h=%d\n", w, h); for (int y = 0; y < h; ++y) { unsigned char *r = rows[y]; z=(int*)(framebuffer+fbwidth*(y+ypos)+xpos); for(int m=0;m<w;m++) { // Assume image to be RGBA, write image to fb as ARGB //#define R ( (r[3]<<24) | (r[2]<<16) |(r[1]<<8)|r[0]) #define R ((r[0]<<16)|(r[1]<<8)|r[2]) *z++ = (r[3]<<24)|R; r += 4; } free(rows[y]); } free(rows); noPipImageDrawn = true; } // EmptyFrame()