Ejemplo n.º 1
0
int G2DTestSystemDriver::MakeColor (int r, int g, int b, int a)
{
  /*if (!pfmt.PalEntries)
    return ((r >> (8 - pfmt.RedBits)) << pfmt.RedShift)
         | ((g >> (8 - pfmt.GreenBits)) << pfmt.GreenShift)
         | ((b >> (8 - pfmt.BlueBits)) << pfmt.BlueShift)
         | ((a >> (8 - pfmt.AlphaBits)) << pfmt.AlphaShift);

  // In paletted mode this is easy since we have a uniform 3-3-2 palette
  return ((r >> 5) << 5) | ((g >> 5) << 2) | (b >> 6);*/
  return myG2D->FindRGB (r, g, b, a);
}
Ejemplo n.º 2
0
void G2DTestSystemDriver::DrawAlphaTestScreen ()
{
  int w = myG2D->GetWidth ();
  int h = myG2D->GetHeight ();
  myG2D->SetClipRect(0,0,w,h);
  myG2D->DrawBox(0,0,w,h, dsteel);

  SetFont (fontItalic);
  WriteCentered (1, 1, white, -1, "ALPHA COLOR TEST");

  SetFont (fontLarge);
  WriteCentered (1, 16*2, black, -1, "If your current canvas is in 32-bit mode, you should");
  WriteCentered (1, 16*3, black, -1, "see various text and geometry at various transparencies.");

  myG2D->DrawBox (190, 80, 50, 100, black);
  myG2D->DrawBox (20, 100, 150, 75, myG2D->FindRGB (205, 0, 125, 200));
  myG2D->DrawBox (120, 100, 100, 50, myG2D->FindRGB (120, 50, 50, 100));
  myG2D->DrawLine (30, 110, 120, 60, myG2D->FindRGB (255, 128, 128, 128));
  myG2D->DrawLine (120, 60, 70, 120, myG2D->FindRGB (128, 255, 128, 128));
  myG2D->DrawLine (70, 120, 30, 110, myG2D->FindRGB (128, 128, 255, 128));

  if (alphaBlitImage.IsValid ())
  {
    myG2D->Blit (20, 160, alphaBlitImage->GetWidth (), alphaBlitImage->GetHeight (), 
      (unsigned char*)alphaBlitImage->GetImageData ());
  }

  myG2D->Write (font, 50, 140, myG2D->FindRGB (255, 255, 255, 100), -1,
    L"Here is some partially transparent text");
  myG2D->Write (font, 50, 150, myG2D->FindRGB (0, 0, 255, 150), -1,
    L"overlaying partially transparent boxes.");

  csString str;
  int i;
  int y = 140;
  int tw, th;
  font->GetMaxSize (tw, th);
  for (i = 0; i < 6; i++)
  {
    const uint8 alpha = (i * 51);
    str.Format ("FG has alpha %" PRIu8 , alpha);
    myG2D->Write (font, 320, y, MakeColor (255, 255, 255, alpha), 
      black, str);
    y += th;
    str.Format ("BG has alpha %" PRIu8, alpha);
    myG2D->Write (font, 320, y, white, MakeColor (0, 0, 0, alpha), 
      str);
    y += th;
  }
}