コード例 #1
0
ファイル: sony_support.c プロジェクト: petesh/pocketcity
BitmapType *
_BmpCreate(Coord width, Coord height, UInt8 depth, ColorTableType *clut,
    UInt16 *error)
{
	if (hires)
		return (HRBmpCreate(hires, width, height, depth, clut, error));
	else
		return (BmpCreate(width, height, depth, clut, error));
}
コード例 #2
0
ファイル: screen.c プロジェクト: TimofonicJunkRoom/plucker
/* Do NOT mix PortableBbmCreate() with BmpDelete() or
   PortableBmpDelete() with BmpCreate() calls! */
BitmapType* PortableBmpCreate
    (
    Coord           bitmapX,
    Coord           bitmapY,
    UInt8           depth,
    ColorTableType* colorTable,
    Err*            err
    )
{
    PalmBitmapTypeV2* bitmap;
    UInt16            rowBytes;
    UInt32            size;
    UInt16            colorTableSize;
    if ( ! SupportHighDensity() )
        return BmpCreate( bitmapX, bitmapY, depth, NULL, err );
    rowBytes = ( bitmapX * depth + 15 ) / 16 * 2;
    if ( colorTable != NULL ) {
        colorTableSize = sizeof( PalmColorTableType ) +
                             sizeof( RGBColorType ) *
                                 ( ( ( PalmColorTableType* )colorTable )->
                                     numEntries & 0xFF );
    }
    else
        colorTableSize = 0;
    size     = ( UInt32 ) rowBytes * bitmapY + sizeof( PalmBitmapTypeV2 ) +
                   colorTableSize;
    bitmap   = SafeMemPtrNew( size );
    MemSet( bitmap, size, 0 );
    bitmap->rowBytes = rowBytes;
    bitmap->width    = bitmapX;
    bitmap->height   = bitmapY;
    bitmap->version  = 2;
    bitmap->pixelSize   = depth;
    MemMove( ( ( UInt8* )bitmap ) + sizeof( PalmBitmapTypeV2 ), colorTable,
               colorTableSize );
    if ( err != NULL )
        *err = errNone;
    return ( BitmapType* )bitmap;
}
コード例 #3
0
ファイル: xfer.c プロジェクト: jemyzhang/DiddleBug
/*
** DrawPlugButton
*/
void DrawPlugButton(DynamicButtonType* btn) {
  Char str[48], str2[48];
  Int16 i = -1;
  WinHandle oldH = WinSetDrawWindow(btn->content.bmpW);

  /* Set up draw state */
  WinPushDrawState();
  WinSetBackColor(0); /* otherwise the pixels will not count as "off" */

  if (d.xfer.pluglistH && ((i = GetCurrentXferAppListIndex()) != -1)) {
    BitmapType* bmp = NULL;
    BitmapTypeV3* bmpV3 = NULL;
    WinHandle tmpH = NULL;
    Coord x, y;
    UInt32 depth;
    Err err = errNone;

    /* Hi-res 1-bpp-bug-workaround, part 1 */
    if (d.hires && !d.sonyClie) {
      /* Create a new temporary bitmap with screen depth */
      BmpGetDimensions(btn->bmp, &x, &y, NULL);
      WinScreenMode(winScreenModeGet, NULL, NULL, &depth, NULL);
      bmp = BmpCreate(x, y, depth, NULL, &err);
      if (err) abort();

      /* ...make it a double density bitmap */
      bmpV3 = BmpCreateBitmapV3(bmp, kDensityDouble, BmpGetBits(bmp), NULL);

      /* ...and create a temporary window */
      tmpH = WinCreateBitmapWindow((BitmapType*) bmpV3, &err);
      if (err) abort();

      /* Draw to temporary window for the time being... */
      WinSetDrawWindow(tmpH);

      /* ...and set the right foreground color */
      WinSetForeColor(WinRGBToIndex(&black));
    }

    /* Get the plugin icon and draw it */
    DrawPlugBitmap(i, boogerID_button, 0, 0);

    /* Hi-res 1-bpp-bug-workaround, part 2 */
    if (d.hires && !d.sonyClie) {
      /* Copy the icon to the actual button */
      WinSetDrawWindow(btn->content.bmpW);
      WinPaintBitmap(WinGetBitmap(tmpH), 0, 0);

      /* Clean up */
      if (tmpH) WinDeleteWindow(tmpH, false);
      if (bmpV3) BmpDelete((BitmapType*) bmpV3);
      if (bmp) BmpDelete(bmp);
    }

    /* Load "goto" behavior */
    GetPlugString(i, boogerID_gotobehavior, str);
    if (StrChr(str, 'n')) 
      xferGotoSetNever();
    else if (StrChr(str, 'a')) 
      xferGotoSetAlways();
    else
      xferGotoClear();

    /* Load "completion" behaviour ("completion" is never on by default (yet)) */
    GetPlugString(i, boogerID_completebehavior, str2);
    if (StrChr(str2, 'a')) 
      xferCompleteSetAlways();
    else if (StrChr(str2, 'o')) 
      xferCompleteClear();
    else
      xferCompleteSetNever();
  } else {
    DrawBitmap(XferNoAppBitmap, 0, 0);
    xferGotoClear();
    xferCompleteClear();
  }

  /* Restore old draw window & state */
  WinPopDrawState();
  WinSetDrawWindow(oldH);
}