示例#1
0
/********************************************************************
*
*       _Draw
*
* Function description
*   Draws some coloured output to the current device (display or memory device)
*/
static void _Draw(void) {
  int i;
  GUI_SetBkColor(GUI_YELLOW);
  GUI_ClearRect(0, 75, 319, 138);
  GUI_SetColor(GUI_RED);
  GUI_SetFont(&GUI_Font32B_ASCII);
  GUI_DispStringHCenterAt("Printing demo", 160, 75);
  for (i = 0; i < 12; i += 2) {
    GUI_SetColor(GUI_GREEN);
    GUI_DrawRect(5 + i, 80 + i, 50 - i, 101 - i);
    GUI_SetColor(GUI_BLUE);
    GUI_DrawRect(269 + i, 80 + i, 314 - i, 101 - i);
  }
  for (i = 0; i < 32; i += 8) {
    GUI_SetColor(GUI_BLUE);
    GUI_FillRect(0, 107 + i, 319, 110 + i);
    GUI_SetColor(GUI_YELLOW);
    GUI_FillRect(0, 111 + i, 319, 114 + i);
  }
  i = 8;
  _DrawBitmap(&bmTestPicture1, i +   0, 111, 0, 0);
  _DrawBitmap(&bmTestPicture1, i +  35, 111, 1, 0);
  _DrawBitmap(&bmTestPicture1, i +  70, 111, 0, 1);
  _DrawBitmap(&bmTestPicture2, i + 105, 111, 0, 0);
  _DrawBitmap(&bmTestPicture2, i + 140, 111, 1, 0);
  _DrawBitmap(&bmTestPicture4, i + 175, 111, 0, 0);
  _DrawBitmap(&bmTestPicture4, i + 210, 111, 1, 0);
  _DrawBitmap(&bmTestPicture8, i + 245, 111, 0, 0);
  _DrawBitmap(&bmTestPicture8, i + 280, 111, 1, 0);
}
示例#2
0
// DrawBitmap
void
Painter::DrawBitmap(const ServerBitmap* bitmap,
					BRect bitmapRect, BRect viewRect) const
{
	if (bitmap && bitmap->InitCheck()) {
		// the native bitmap coordinate system
		BRect actualBitmapRect(bitmap->Bounds());

		agg::rendering_buffer srcBuffer;
		srcBuffer.attach(bitmap->Bits(),
						 bitmap->Width(),
						 bitmap->Height(),
						 bitmap->BytesPerRow());

		_DrawBitmap(srcBuffer, bitmap->ColorSpace(), actualBitmapRect, bitmapRect, viewRect);
	}
}
示例#3
0
// DrawBitmap
void
Painter::DrawBitmap(const BBitmap* bitmap,
					BRect bitmapRect, BRect viewRect) const
{
	if (bitmap && bitmap->IsValid()) {
		// the native bitmap coordinate system
		// (can have left top corner offset)
		BRect actualBitmapRect(bitmap->Bounds());

		agg::rendering_buffer srcBuffer;
		srcBuffer.attach((uint8*)bitmap->Bits(),
						 (uint32)actualBitmapRect.IntegerWidth() + 1,
						 (uint32)actualBitmapRect.IntegerHeight() + 1,
						 bitmap->BytesPerRow());

		_DrawBitmap(srcBuffer, bitmap->ColorSpace(), actualBitmapRect, bitmapRect, viewRect);
	}
}
/*********************************************************************
*
*       _DrawBitmap
*/
static void _DrawBitmap(int x0, int y0, int xsize, int ysize, const U8 GUI_UNI_PTR * pPixel, const LCD_LOGPALETTE GUI_UNI_PTR * pLogPal, int xMag, int yMag, tLCDDEV_Index2Color * pfIndex2Color) {
  const U32 * pData;
  int y, OldIndex, Mag, BytesPerLine, UseDrawBitmap = 0;
  U32 PrevColor;
  GUI_USE_PARA(pLogPal);
  OldIndex = LCD_GetColorIndex();
  PrevColor = GUI_INVALID_COLOR;
  pData = (const U32 *)pPixel;
  Mag = (xMag | yMag);
  BytesPerLine = xsize * 4;
  /* Check if bitmaps color format fits to the current color conversion */
  if (Mag == 1) {
    #if GUI_SUPPORT_MEMDEV
    if (!GUI_Context.hDevData) {
    #else
    {
    #endif
      if (LCD_GetpfIndex2ColorEx(GUI_Context.SelLayer) == pfIndex2Color) {
        UseDrawBitmap = 1;
      }
    }
  }
  if (UseDrawBitmap) {
    LCD_DrawBitmap(x0, y0, xsize, ysize, 1, 1, 24, BytesPerLine, pPixel, 0);
  } else {
    if (Mag == 1) {
      /* Perform clipping */
      int x1, y1, Diff;
      y1 = y0 + ysize - 1;
      x1 = x0 + xsize - 1;
      /* Clip Y */
      if (y0 < GUI_Context.ClipRect.y0) {
        Diff = GUI_Context.ClipRect.y0 - y0;
        y0   = GUI_Context.ClipRect.y0;
        #if GUI_SUPPORT_LARGE_BITMAPS                       /* Required only for 16 bit CPUs if some bitmaps are >64kByte */
          pData += (U32)Diff * (U32)BytesPerLine / 4;
        #else
          pData += (unsigned)Diff * (unsigned)BytesPerLine / 4;
        #endif
        ysize -= Diff;
      }
      Diff = y1 - GUI_Context.ClipRect.y1;
      if (Diff > 0) {
        ysize -= Diff;
      }
      if (ysize <=0) {
		    return;
      }
      /* Clip right side */
      Diff = x1 - GUI_Context.ClipRect.x1;
      if (Diff > 0) {
        xsize -= Diff;
      }
      /* Clip left side */
      if (x0 < GUI_Context.ClipRect.x0) {
        Diff = GUI_Context.ClipRect.x0 - x0;
			  xsize -= Diff;
        pData += Diff; 
        x0 += Diff; 
      }
      if (xsize <=0) {
		    return;
      }
      /* Simple, unmagnified output using LCD_L0_SetPixel() */
      for (y = 0; y < ysize; y++) {
        int x;
        const U32 * p = pData;
        for (x = 0; x < xsize; x++) {
          U32 Color;
          Color = *p++;
          if (Color != PrevColor) {
            LCD_SetColor(pfIndex2Color(Color));
            PrevColor = Color;
          }
          LCDDEV_L0_SetPixelIndex(x + x0, y + y0, LCD_COLORINDEX);
        }
        pData += BytesPerLine / 4;
      }
    } else {
      /* Magnified output using LCD_FillRect() */
      int x,y;
      int yi;
      for (y = y0, yi = 0; yi < ysize; yi++, y += yMag, pPixel += BytesPerLine) {
        int yMax;
        yMax = y + yMag - 1;
        /* Draw if within clip area */
        if ((yMax >= GUI_Context.ClipRect.y0) && (y <= GUI_Context.ClipRect.y1)) {
          int xi;
          const U32 GUI_UNI_PTR * p = pData;
          for (x = x0, xi = 0; xi < xsize; xi++, x += xMag) {
            U32 Color;
            Color = *p++;
            if (Color != PrevColor) {
              LCD_SetColor(pfIndex2Color(Color));
              PrevColor = Color;
            }
            LCD_FillRect(x, y, x + xMag - 1, yMax);
          }
        }
        pData += BytesPerLine / 4;
      }
    }
    GUI_SetColorIndex(OldIndex);
  }
}

/*********************************************************************
*
*       _DrawBitmap_565
*/
static void _DrawBitmap_888(int x0, int y0, int xsize, int ysize, const U8 GUI_UNI_PTR * pPixel, const LCD_LOGPALETTE GUI_UNI_PTR * pLogPal, int xMag, int yMag) {
  _DrawBitmap(x0, y0, xsize, ysize, pPixel, pLogPal, xMag, yMag, GUI_BitmapMethods888.pfIndex2Color);
}
/*********************************************************************
*
*       _DrawBitmap_M565
*/
static void _DrawBitmap_M888(int x0, int y0, int xsize, int ysize, const U8 GUI_UNI_PTR * pPixel, const LCD_LOGPALETTE GUI_UNI_PTR * pLogPal, int xMag, int yMag) {
  _DrawBitmap(x0, y0, xsize, ysize, pPixel, pLogPal, xMag, yMag, GUI_BitmapMethodsM888.pfIndex2Color);
}
示例#6
0
void GameOverScene::Draw(int *video, int w, int h)
{
	_DrawBitmap(video,w,h,128,0,g_pDeath->_video,1024,720);
}