示例#1
0
void SuperEagle(ALLEGRO_BITMAP * src, ALLEGRO_BITMAP * dest, int s_x, int s_y, int d_x, int d_y, int w, int h)
{
	int sbpp, dbpp;

	ALLEGRO_BITMAP *dst2 = NULL;

	if (!src || !dest)
		return;

	sbpp = bitmap_color_depth(src);
	dbpp = bitmap_color_depth(dest);

	if ((sbpp != xsai_depth) || (sbpp != dbpp))	/* Must be same color depth */
		return;

	BLIT_CLIP2(src, dest, s_x, s_y, d_x, d_y, w, h, 2, 2);	
		
	if (w < 4 || h < 4) {  /* Image is too small to be 2xSaI'ed. */
		stretch_blit(src, dest, s_x, s_y, w, h, d_x, d_y, w * 2, h * 2);
		return;
	}	
	
	sbpp = BYTES_PER_PIXEL(sbpp);
	if (d_x || d_y)
		dst2 = create_sub_bitmap(dest, d_x, d_y, w * 2, h * 2);
	
	SuperEagle_ex(src->line[s_y] + s_x * sbpp, (unsigned int)(src->line[1] - src->line[0]), NULL, dst2 ? dst2 : dest, w, h);
	
	if (dst2)
		destroy_bitmap(dst2);
	
	return;
}
/** \ingroup faders
 *  Fades source bitmap from/to a color and places output bitmap into the
 *  destination at the specified coordinates. Source and destination
 *  bitmaps must have the same color depth; supported color depths are 15,
 *  16 and 32 bpp. Fact should range 0-255, and it is used to specify the
 *  fade factor with which the destination bitmap will be drawn.
 *  A factor of 255 will render the original bitmap, whereas a factor of 0
 *  will only draw a rectangle of the specified color.
 *
 * <pre>
 *  dest_red = (src_red * fact / 255) + (color * (255 - fact) / 255)
 * </pre>
 *  Repeat for green and blue, and for all pixels to be displayed.
 *
 *  MMX and SSE will automatically be used if they are present.
 *
 *  \param src  The source bitmap. Must be a linear memory bitmap or
 *              sub-bitmap thereof, and must be in 15, 16 or 32 bpp.
 *  \param dst  The destination bitmap. Must be in 15, 16 or 32 bpp
 *              and linear, but not necessarily a memory bitmap.
 *  \param x    The coordinate on the X axis of teh destination bitmap
 *              to place the faded source bitmap at.
 *  \param y    The coordinate on the Y axis of teh destination bitmap
 *              to place the faded source bitmap at.
 *  \param color The color to fade to. This needs to be in the same depth
 *              as the bitmaps.
 *  \param fact Fade factor. Should be in the range 0-255.
 */
void fblend_fade_to_color(BITMAP *src, BITMAP *dst, int x, int y, int color, int fact) {

    int w, h;
	
	int src_x = 0, src_y = 0, dst_x = x, dst_y = y;
	int src_depth, dst_depth;
	
	w = src->w;
	h = src->h;
	
	/* Clip the image */
	if (dst_x < 0) {
		w += dst_x;
		src_x -= dst_x;
		dst_x = 0;
	}
	if (dst_y < 0) {
		h += dst_y;
		src_y -= dst_y;
		dst_y = 0;
	}
	if (dst_x + w >= dst->w)
		w -= dst_x + w - dst->w;
	if (dst_y + h >= dst->h)
		h -= dst_y + h - dst->h;

	/* Nothing to do? */
	if (w < 1 || h < 1)
		return;
	
	src_depth = bitmap_color_depth(src);
	dst_depth = bitmap_color_depth(dst);
	
	/* Incorrct color depths */
	if (!(src_depth == 16 && dst_depth == 16)
			&& !(src_depth == 15 && dst_depth == 15)
			&& !(src_depth == 32 && dst_depth == 32))
		return;
		
	/* Can we do a blit or rectfill instead? */
	if (fact >= 255) {
		blit(src, dst, src_x, src_y, dst_x, dst_y, w, h);
		return;
	}
	if (fact <= 0) {
		rectfill(dst, dst_x, dst_y, dst_x + w - 1, dst_y + h - 1, color);
		return;
	}

	acquire_bitmap(dst);

	/* 16 bit code */	
	if (src_depth == 16) {

		#ifdef FBLEND_MMX
			if (cpu_capabilities & CPU_MMX) {
				fact = (fact + 7) >> 3;
				fblend_fade_mmx_16(src, dst, src_x, src_y, dst_x, dst_y, w, h, color, fact);
			}
			else
示例#3
0
// ==========================================================================
// draw the shadow projection of a sprite at the zoom 1:div
// dst & sprite MUST be 8bpp color depth both
// dst & sprite MUST be linear bitmaps both (not plannar)
// cmap must point on an array of 256 bytes
// offx and offy are the coordinates of the pivot point of the sprite
void stretch_trans_shadow_8bpp(BITMAP * dst, BITMAP * sprite, int x0, int y0, int div, UBYTE * cmap, int offy)
{
   int dx1, dy1, dx2, dy2, sx1, sy1, sw, sh;

   // ridiculous cases
   if ((bitmap_color_depth(dst) != 8) || (bitmap_color_depth(sprite) != 8)){
      return;
   }
   if (( ! is_linear_bitmap(dst)) || ( ! is_linear_bitmap(sprite))){
      return;
   }

   sx1 = 0;
   sy1 = 0;
   sw  = sprite->w / div;
   sh  = sprite->h / (div * 2);

   dy1 = y0 + ((offy - y0) / 2);
   dx1 = x0 - ((offy - y0) / 2);

   dx2 = dx1 + sw - 1;
   dy2 = dy1 + sh - 1;

   // draw
   {
      int dx, dy, sx, sy;

      dx = dx1;
      dy = dy1;
      sx = sx1;
      sy = sy1;
      for(;;) {
         if ((dx >= 0) && (dy >= 0) && (dx < dst->w) && (dy < dst->h)) {
            if (sprite->line[sy][sx]){
               dst->line[dy][dx] = cmap[ dst->line[dy][dx] ];
            }
         }
         dx++;
         if (dx > dx2) {
            dx1++;
            dx2++;
            dx = dx1;
            sx = sx1;
            dy++;
            if (dy > dy2){
               return;
            } else{
               sy += div * 2;
            }
         } else{
            sx += div;
         }
      }
   }
}
示例#4
0
/* set_mouse_sprite:
 *  Sets the sprite to be used for the mouse pointer. If the sprite is
 *  NULL, restores the default arrow.
 */
void set_mouse_sprite(struct BITMAP *sprite)
{
   BITMAP *old_mouse_screen = _mouse_screen;
   int am_using_sys_cursor = use_system_cursor;

   if (!mouse_driver)
      return;

   if (_mouse_screen && !am_using_sys_cursor)
      show_mouse(NULL);

   if (sprite)
      mouse_sprite = sprite;
   else {
      if (_mouse_pointer)
	 destroy_bitmap(_mouse_pointer);
      _mouse_pointer = create_mouse_pointer(mouse_arrow_data);
      mouse_sprite = _mouse_pointer;
   }

   cursors[MOUSE_CURSOR_ALLEGRO] = mouse_sprite;
   
   lock_bitmap((struct BITMAP*)mouse_sprite);

   /* make sure the ms bitmap is big enough */
   if ((!ms) || (ms->w < mouse_sprite->w) || (ms->h < mouse_sprite->h) ||
       (bitmap_color_depth(mouse_sprite) != bitmap_color_depth(ms))) {
      if (ms) {
	 destroy_bitmap(ms);
	 destroy_bitmap(mtemp);
      }

      ms = create_bitmap(mouse_sprite->w, mouse_sprite->h);
      lock_bitmap(ms);

      mtemp = create_bitmap(mouse_sprite->w*2, mouse_sprite->h*2);
      lock_bitmap(mtemp);
   }

   mouse_x_focus = 1;
   mouse_y_focus = 1;

   if (!am_using_sys_cursor)
      hw_cursor_dirty = TRUE;

   if (old_mouse_screen && !am_using_sys_cursor)
      show_mouse(old_mouse_screen);
}
示例#5
0
/* set_mouse_etc:
 *  Hook for setting up the motion range, cursor graphic, etc, called by
 *  the mouse init and whenever we change the graphics mode.
 */
static void set_mouse_etc(void)
{
   if ((!mouse_driver) || (!gfx_driver))
      return;

   if ((!_mouse_pointer) || 
       ((screen) && (_mouse_pointer) &&
	(bitmap_color_depth(_mouse_pointer) != bitmap_color_depth(screen))))
      set_mouse_sprite(NULL);
   else
      hw_cursor_dirty = TRUE;

   set_mouse_range(0, 0, SCREEN_W-1, SCREEN_H-1);
   set_mouse_speed(2, 2);
   position_mouse(SCREEN_W/2, SCREEN_H/2);
}
示例#6
0
NaroolLurker::NaroolLurker(Vector2 opos, double shipAngle,
ShipData *shipData, unsigned int code)
:
Ship(opos, shipAngle, shipData, code)
{
	STACKTRACE;
	weaponRange    = scale_range(get_config_float("Weapon", "Range", 0));
	weaponVelocity = scale_velocity(get_config_float("Weapon", "Velocity", 0));
	weaponDamage   = get_config_int("Weapon", "Damage", 0);
	weaponArmour   = get_config_int("Weapon", "Armour", 0);
	weaponDuration = get_config_int("Weapon", "Duration", 0);
	poison         = get_config_float("Weapon", "poison", 0);

	normalRechargeAmount = recharge_amount;

	cloak = FALSE;
	cloak_frame = 0;

	BITMAP *shpbmp = sprite->get_bitmap(0);
	int bpp = bitmap_color_depth(shpbmp);
	lightningbmp = create_bitmap_ex(bpp, shpbmp->w, shpbmp->h);
	clear_to_color(lightningbmp, makeacol(0,0,0,255));
	//maxsparktime = 2000;
	maxsparktime = get_config_float("Quirk", "maxsparktime", 2000);
	sparktime = maxsparktime;
	sparkpos = 0.5 * Vector2(lightningbmp->w,lightningbmp->h);

	Rmax = get_config_float("Quirk", "Rmax", 1);
}
示例#7
0
/* reconstruct_kids:
 *  Recursive helper to rebuild any sub-bitmaps to point at their new
 *  parents.
 */
static void reconstruct_kids(BITMAP *parent, BITMAP_INFORMATION *info)
{
   int x, y, i;

   while (info) {
      info->bmp->vtable = parent->vtable;
      info->bmp->write_bank = parent->write_bank;
      info->bmp->read_bank = parent->read_bank;
      info->bmp->seg = parent->seg;
      info->bmp->id = parent->id | BMP_ID_SUB;

      x = info->bmp->x_ofs - parent->x_ofs;
      y = info->bmp->y_ofs - parent->y_ofs;

      if (is_planar_bitmap(info->bmp))
	 x /= 4;

      x *= BYTES_PER_PIXEL(bitmap_color_depth(info->bmp));

      for (i=0; i<info->bmp->h; i++)
	 info->bmp->line[i] = parent->line[y+i] + x;

      reconstruct_kids(info->bmp, info->child);
      info = info->sibling;
   }
}
示例#8
0
/* save_bitmap_state:
 *  Remember everything important about a screen bitmap.
 *
 *  Note: this must run even for SWITCH_BACKAMNESIA.  With the fbcon driver,
 *  writes to the screen would still show up while we are switched away.
 *  So we let this function run to redirect the screen to a memory bitmap while
 *  we are switched away.  We also let this run for SWITCH_AMNESIA just for
 *  consistency.
 */
static void save_bitmap_state(BITMAP_INFORMATION *info, int switch_mode)
{
   int copy;

   info->other = create_bitmap_ex(bitmap_color_depth(info->bmp), info->bmp->w, info->bmp->h);
   if (!info->other)
      return;

   copy = (switch_mode != SWITCH_AMNESIA) && (switch_mode != SWITCH_BACKAMNESIA);
   fudge_bitmap(info->bmp, info->other, copy);
   info->blit_on_restore = copy;

   info->acquire = info->other->vtable->acquire;
   info->release = info->other->vtable->release;

   info->other->vtable->acquire = info->bmp->vtable->acquire;
   info->other->vtable->release = info->bmp->vtable->release;

   #define INTERESTING_ID_BITS   (BMP_ID_VIDEO | BMP_ID_SYSTEM | \
				  BMP_ID_SUB | BMP_ID_MASK)

   info->other->id = (info->bmp->id & INTERESTING_ID_BITS) | 
		     (info->other->id & ~INTERESTING_ID_BITS);

   swap_bitmap_contents(info->bmp, info->other);
}
示例#9
0
// ACTION: QUITTING EMULATOR --------------------------------------------------
// FIXME-DEPTH: Ressources (machines, icons) not faded out
void    Action_Quit (void)
{
    int depth = bitmap_color_depth(gui_buffer);

    Msg (MSGT_USER_INFOLINE, Msg_Get(MSG_Quit));

    // Shut up sound while fading
    Sound_Playback_Stop();

    // Redraw last time, so message appears on screen
    gui_redraw_everything_now_once();

    /*
    // Software, naive, slow fade
    // Only 32-bits supported
    switch (depth)
    {
    case 32:
        {
            while (TRUE)
            {
                bool more = FALSE;
                int  y;
                u32 **ppixels = (u32 **)&gui_buffer->line;
                for (y = gui_buffer->h; y != 0; y--)
                {
                    u32 *pixels = *ppixels++;
                    int  x;
                    for (x = gui_buffer->w; x != 0; x--)
                    {
                        u32 c = *pixels;
                        int r = c & 0x000000FF;
                        int g = c & 0x0000FF00;
                        int b = c & 0x00FF0000;
                        int loop;
                        for (loop = 3; loop != 0; loop--)
                        {
                            if (r != 0) r -= 0x000001;
                            if (g != 0) g -= 0x000100;
                            if (b != 0) b -= 0x010000;
                        }
                        c = r | g | b;
                        if (c != 0)
                            more = TRUE;
                        *pixels++ = c;
                    }
                }
                Blit_GUI();
                if (!more)
                    break;
            }
        } // 32
    }
    */

    // Switch to full black skin
    //Skins_Select(Skins_GetSystemSkinBlack(), TRUE);
    //Skins_QuitAfterFade();
    opt.Force_Quit = TRUE;
}
示例#10
0
/* color_copy_glyph_range:
 *  Colour font helper function. Copies (part of) a glyph range
 */
static FONT_COLOR_DATA *color_copy_glyph_range(FONT_COLOR_DATA *cf, int begin, int end)
{
   FONT_COLOR_DATA *newcf;
   BITMAP **gl;
   BITMAP *g;
   int num, c;
   
   if (begin<cf->begin || end>cf->end)
      return NULL;
   
   newcf = _AL_MALLOC(sizeof *newcf);

   if (!newcf)
      return NULL;

   newcf->begin = begin;
   newcf->end = end;
   newcf->next = NULL;
   num = end - begin;

   gl = newcf->bitmaps = _AL_MALLOC(num * sizeof *gl);
   for (c=0; c<num; c++) {
      g = cf->bitmaps[begin - cf->begin + c];
      gl[c] = create_bitmap_ex(bitmap_color_depth(g), g->w, g->h);
      int y;
      for (y = 0; y < g->h; y++){
          memcpy(gl[c]->line[y], g->line[y], g->w);
      }
      //blit(g, gl[c], 0, 0, 0, 0, g->w, g->h);
   }

   return newcf;
}
示例#11
0
/* save_rgba:
 *  Core save routine for 32 bpp images.
 */
static int save_rgba(png_structp png_ptr, BITMAP *bmp)
{
    unsigned char *rowdata;
    int x, y;

    ASSERT(bitmap_color_depth(bmp) == 32);

    rowdata = (unsigned char *)malloc(bmp->w * 4);
    if (!rowdata)
	return 0;

    for (y=0; y<bmp->h; y++) {
	unsigned char *p = rowdata;
	
        for (x=0; x<bmp->w; x++) {
            int c = getpixel(bmp, x, y);
	    *p++ = getr32(c);
	    *p++ = getg32(c);
	    *p++ = getb32(c);
	    *p++ = geta32(c);
        }

        png_write_row(png_ptr, rowdata);
    }

    free(rowdata);

    return 1;
}
示例#12
0
文件: bgfx.c 项目: rofl0r/GfxRip
/*this is a slightly modified version of something
  found in Allegro's mouse.c*/
void data2bmp(unsigned char d[], BITMAP *b, int w, int h)
{
 int pcolor;
 int x, y;
 for (y=0; y<h; y++) {
  for (x=0; x<w; x++) {
   if(d[y*w+x] == 1)
    pcolor = get_bill_color(bill_hlight);
   else if(d[y*w+x] == 2)
    pcolor = get_bill_color(bill_framebg);
   else if(d[y*w+x] == 3)
    pcolor = get_bill_color(bill_light);
   else if(d[y*w+x] == 4)
    pcolor = get_bill_color(bill_shadow);
   else if(d[y*w+x] == 5)
    pcolor = get_bill_color(bill_dkshadow);
   else if(d[y*w+x] == 6)
    pcolor = get_bill_color(bill_dkshadow);
   else if(d[y*w+x] == 7)
    pcolor = get_bill_color(bill_face);
   else
   {
    if (bitmap_color_depth(b) == 8)
     pcolor = 0;
    else 
     pcolor = makecol(255, 0, 255);
   }
   putpixel(b, x, y, pcolor);
  }
 } 
}
示例#13
0
void GfxMode::updateWithCurrentMode()
{
  m_card    = gfx_driver->id;
  m_width   = SCREEN_W;
  m_height  = SCREEN_H;
  m_depth   = bitmap_color_depth(screen);
  m_scaling = get_screen_scaling();
}
示例#14
0
/* splits bitmaps into sub-sprites, using regions bounded by col #255 */
static void datedit_find_character(BITMAP *bmp, int *x, int *y, int *w, int *h)
{
  int c1;
  int c2;

  if (bitmap_color_depth(bmp) == 8) {
    c1 = 255;
    c2 = 255;
  }
  else {
    c1 = makecol_depth(bitmap_color_depth(bmp), 255, 255, 0);
    c2 = makecol_depth(bitmap_color_depth(bmp), 0, 255, 255);
  }

  /* look for top left corner of character */
  while ((getpixel(bmp, *x, *y) != c1) ||
         (getpixel(bmp, *x+1, *y) != c2) ||
         (getpixel(bmp, *x, *y+1) != c2) ||
         (getpixel(bmp, *x+1, *y+1) == c1) ||
         (getpixel(bmp, *x+1, *y+1) == c2)) {
    (*x)++;
    if (*x >= bmp->w) {
      *x = 0;
      (*y)++;
      if (*y >= bmp->h) {
        *w = 0;
        *h = 0;
        return;
      }
    }
  }

  /* look for right edge of character */
  *w = 0;
  while ((getpixel(bmp, *x+*w+1, *y) == c2) &&
         (getpixel(bmp, *x+*w+1, *y+1) != c2) &&
         (*x+*w+1 <= bmp->w))
    (*w)++;

  /* look for bottom edge of character */
  *h = 0;
  while ((getpixel(bmp, *x, *y+*h+1) == c2) &&
         (getpixel(bmp, *x+1, *y+*h+1) != c2) &&
         (*y+*h+1 <= bmp->h))
    (*h)++;
}
示例#15
0
/* lock_bitmap:
 *  Locks all the memory used by a bitmap structure.
 */
void lock_bitmap(BITMAP *bmp)
{
   LOCK_DATA(bmp, sizeof(BITMAP) + sizeof(char *) * bmp->h);

   if (bmp->dat) {
      LOCK_DATA(bmp->dat, bmp->w * bmp->h * BYTES_PER_PIXEL(bitmap_color_depth(bmp)));
   }
}
示例#16
0
void Alleg4Surface::getFormat(SurfaceFormatData* formatData) const
{
  formatData->format = kRgbaSurfaceFormat;
  formatData->bitsPerPixel = bitmap_color_depth(m_bmp);

  switch (formatData->bitsPerPixel) {
    case 8:
      formatData->redShift   = 0;
      formatData->greenShift = 0;
      formatData->blueShift  = 0;
      formatData->alphaShift = 0;
      formatData->redMask    = 0;
      formatData->greenMask  = 0;
      formatData->blueMask   = 0;
      formatData->alphaMask  = 0;
      break;
    case 15:
      formatData->redShift   = _rgb_r_shift_15;
      formatData->greenShift = _rgb_g_shift_15;
      formatData->blueShift  = _rgb_b_shift_15;
      formatData->alphaShift = 0;
      formatData->redMask    = 31 << _rgb_r_shift_15;
      formatData->greenMask  = 31 << _rgb_g_shift_15;
      formatData->blueMask   = 31 << _rgb_b_shift_15;
      formatData->alphaMask  = 0;
      break;
    case 16:
      formatData->redShift   = _rgb_r_shift_16;
      formatData->greenShift = _rgb_g_shift_16;
      formatData->blueShift  = _rgb_b_shift_16;
      formatData->alphaShift = 0;
      formatData->redMask    = 31 << _rgb_r_shift_16;
      formatData->greenMask  = 63 << _rgb_g_shift_16;
      formatData->blueMask   = 31 << _rgb_b_shift_16;
      formatData->alphaMask  = 0;
      break;
    case 24:
      formatData->redShift   = _rgb_r_shift_24;
      formatData->greenShift = _rgb_g_shift_24;
      formatData->blueShift  = _rgb_b_shift_24;
      formatData->alphaShift = 0;
      formatData->redMask    = 255 << _rgb_r_shift_24;
      formatData->greenMask  = 255 << _rgb_g_shift_24;
      formatData->blueMask   = 255 << _rgb_b_shift_24;
      formatData->alphaMask  = 0;
      break;
    case 32:
      formatData->redShift   = _rgb_r_shift_32;
      formatData->greenShift = _rgb_g_shift_32;
      formatData->blueShift  = _rgb_b_shift_32;
      formatData->alphaShift = _rgb_a_shift_32;
      formatData->redMask    = 255 << _rgb_r_shift_32;
      formatData->greenMask  = 255 << _rgb_g_shift_32;
      formatData->blueMask   = 255 << _rgb_b_shift_32;
      formatData->alphaMask  = 255 << _rgb_a_shift_32;
      break;
  }
}
示例#17
0
AMesaBuffer GLAPIENTRY AMesaCreateBuffer(AMesaVisual visual, BITMAP* bmp)
{
	AMesaBuffer buffer;

	/* Buffer and visual must share the same color depth */
	if (bitmap_color_depth(bmp) != visual->Depth)
		return NULL;

	buffer = (AMesaBuffer) malloc(sizeof(struct amesa_buffer));
	if (!buffer)
		return NULL;

	buffer->FrontBuffer    = bmp;
	buffer->BackBuffer     = NULL;
	buffer->Active         = NULL;
	buffer->ReadActive     = NULL;
	buffer->DepthBuffer    = NULL;

	if (visual->DBFlag) {
		buffer->BackBuffer = create_bitmap_ex(visual->Depth, bmp->w, bmp->h);
		if (!buffer->BackBuffer) {
			free(buffer);
			return NULL;
		}
	}
	
	if (visual->GLVisual->depthBits > 0) {
		buffer->DepthBuffer = create_zbuffer(bmp);
		if (!buffer->DepthBuffer) {
			if (buffer->BackBuffer)
				destroy_bitmap(buffer->BackBuffer);
			free(buffer);
			return NULL;
		}
		set_zbuffer(buffer->DepthBuffer);
	}

	buffer->GLBuffer = _mesa_create_framebuffer(visual->GLVisual,
                         0,   				    /*depth buffer is handled by Allegro */
                         visual->GLVisual->stencilBits > 0, /*software stencil buffer*/
                         visual->GLVisual->accumRedBits > 0,/*software accum buffer*/
                         GL_FALSE ); /*software alpha buffer*/

	if (!buffer->GLBuffer) {
		if (buffer->BackBuffer)
			destroy_bitmap(buffer->BackBuffer);
		if (buffer->DepthBuffer)
			destroy_zbuffer(buffer->DepthBuffer);
		free(buffer);
      		return NULL;
	}

	buffer->Width  = bmp->w;
	buffer->Height = bmp->h;

	return buffer;
}
示例#18
0
void window_sub::resize_sub_buffer(coord_int w, coord_int h)
{
  if (sub_buffer) destroy_bitmap(sub_buffer);

  sub_buffer = create_bitmap_ex(bitmap_color_depth(get_master()->get_buffer()), w+1, h+1);     
  Assert(sub_buffer, "Error allocating new sub-buffer for window " << this);

  update_sub();
}
示例#19
0
bool Bitmap::CreateCopy(Bitmap *src, int color_depth)
{
    if (Create(src->_alBitmap->w, src->_alBitmap->h, color_depth ? color_depth : bitmap_color_depth(src->_alBitmap)))
    {
        blit(src->_alBitmap, _alBitmap, 0, 0, 0, 0, _alBitmap->w, _alBitmap->h);
        return true;
    }
    return false;
}
示例#20
0
/* set_mouse_etc:
 *  Hook for setting up the motion range, cursor graphic, etc, called by
 *  the mouse init and whenever we change the graphics mode.
 */
static void set_mouse_etc(void)
{
   if ((!mouse_driver) || (!gfx_driver))
      return;

   if ((!_mouse_pointer) ||
       ((screen) && (_mouse_pointer) &&
        (bitmap_color_depth(_mouse_pointer) != bitmap_color_depth(screen))))
      set_mouse_sprite(NULL);
   else
      hw_cursor_dirty = TRUE;

   set_mouse_range(0, 0, SCREEN_W-1, SCREEN_H-1);
   set_mouse_speed(2, 2);

   /* As now we support window resizing, it's not recommended to change the mouse position. */
   /*position_mouse(SCREEN_W/2, SCREEN_H/2);*/
}
示例#21
0
文件: ali3dsw.cpp 项目: sonneveld/ags
void ALSoftwareGraphicsDriver::draw_sprite_with_transparency(BITMAP* piccy, int xxx, int yyy, int transparency)
{
    int screen_depth = bitmap_color_depth(virtualScreen);
    int sprite_depth = bitmap_color_depth(piccy);

    if (sprite_depth < screen_depth) {

        if ((sprite_depth == 8) && (screen_depth >= 24)) {
            // 256-col sprite -> truecolor background
            // this is automatically supported by allegro, no twiddling needed
            draw_sprite(virtualScreen, piccy, xxx, yyy);
            return;
        }
        // 256-col spirte -> hi-color background, or
        // 16-bit sprite -> 32-bit background
        BITMAP* hctemp=create_bitmap_ex(screen_depth, piccy->w, piccy->h);
        blit(piccy,hctemp,0,0,0,0,hctemp->w,hctemp->h);
        int bb,cc,mask_col = bitmap_mask_color(virtualScreen);

        if (sprite_depth == 8) {
            // only do this for 256-col, cos the blit call converts
            // transparency for 16->32 bit
            for (bb=0; bb<hctemp->w; bb++) {
                for (cc=0; cc<hctemp->h; cc++)
                    if (_getpixel(piccy,bb,cc)==0) putpixel(hctemp,bb,cc,mask_col);
            }
        }

        draw_sprite(virtualScreen, hctemp, xxx, yyy);
        destroy_bitmap(hctemp);
    }
    else
    {
        if ((transparency != 0) && (screen_depth > 8) &&
                (sprite_depth > 8) && (bitmap_color_depth(virtualScreen) > 8))
        {
            set_trans_blender(0,0,0, transparency);
            draw_trans_sprite(virtualScreen, piccy, xxx, yyy);
        }
        else
            draw_sprite(virtualScreen, piccy, xxx, yyy);
    }

}
示例#22
0
/* Renders the next frame in a GIF animation to the specified bitmap and
 * the given position. You need to call this in order on the same
 * destination for frames [0..gif->frames_count - 1] to properly render all
 * the frames in the GIF.
 */
void
algif_render_frame (GIF_ANIMATION *gif, BITMAP *bitmap, int frame, int xpos,
                    int ypos)
{
    int x, y, w, h;
    GIF_FRAME *f = &gif->frames[frame];
    GIF_PALETTE *pal;
    if (frame == 0)
        rectfill (bitmap, xpos, ypos, xpos + gif->width - 1,
              ypos + gif->height - 1, bitmap_mask_color (bitmap));
    else
    {
        GIF_FRAME *p = &gif->frames[frame - 1];
        if (p->disposal_method == 2)
            rectfill (bitmap, xpos + p->xoff, ypos + p->yoff,
                xpos + p->xoff + p->bitmap_8_bit->w - 1,
                ypos + p->yoff + p->bitmap_8_bit->h - 1,
                bitmap_mask_color (bitmap));
        else if (p->disposal_method == 3 && gif->store)
        {
            blit (gif->store, bitmap, 0, 0, xpos + p->xoff, ypos + p->yoff,
                gif->store->w, gif->store->h);
            destroy_bitmap (gif->store);
            gif->store = NULL;
        }
    }
    w = f->bitmap_8_bit->w;
    h = f->bitmap_8_bit->h;
    if (f->disposal_method == 3)
    {
        if (gif->store)
            destroy_bitmap (gif->store);
        gif->store = create_bitmap_ex (bitmap_color_depth (bitmap), w, h);
        blit (bitmap, gif->store, xpos + f->xoff, ypos + f->yoff, 0, 0, w, h);
    }
    pal = &gif->frames[frame].palette;
    if (pal->colors_count == 0)
        pal = &gif->palette;

    //int i;
    //for (i = 0; i < pal->colors_count; i++)
    //    printf("%d: %d %d %d\n", i, pal->colors[i].r, pal->colors[i].g, pal->colors[i].b);

    for (y = 0; y < h; y++)
    {
        for (x = 0; x < w; x++)
        {
            int c = getpixel (f->bitmap_8_bit, x, y);
            if (c != f->transparent_index)
            {
                putpixel (bitmap, xpos + f->xoff + x, ypos + f->yoff + y,
                          get_rgbcolor (&pal->colors[c]));
            }
        }
    }
}
示例#23
0
文件: radar.cpp 项目: Yurand/tw-light
ZRadar::ZRadar(BITMAP *BlankSlate, Presence *target, double Size)
{
	STACKTRACE;
	Blank=BlankSlate;
	Painted = create_bitmap_ex(bitmap_color_depth(screen),Blank->w,Blank->h);
	t=target;
	size=Size;
	active=TRUE;
	set_depth(DEPTH_STARS + 0.1);
}
示例#24
0
void masked_image::load(BITMAP* bmp)
{
  if (image) destroy_bitmap(image);
  
  if (bmp)
  {
    image = create_bitmap_ex(bitmap_color_depth(bmp), bmp->w, bmp->h);
    if (image) blit(bmp, image, 0, 0, 0, 0, bmp->w, bmp->h);
  }  
}
示例#25
0
void Alleg4Surface::fillRect(gfx::Color color, const gfx::Rect& rc)
{
  if (gfx::geta(color) < 255) {
    set_trans_blender(0, 0, 0, gfx::geta(color));
    drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
  }

  rectfill(m_bmp, rc.x, rc.y, rc.x+rc.w-1, rc.y+rc.h-1, to_allegro(bitmap_color_depth(m_bmp), color));
  solid_mode();
}
示例#26
0
void Alleg4Surface::drawVLine(gfx::Color color, int x, int y, int h)
{
  if (gfx::geta(color) < 255) {
    set_trans_blender(0, 0, 0, gfx::geta(color));
    drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
  }

  vline(m_bmp, x, y, y+h-1, to_allegro(bitmap_color_depth(m_bmp), color));
  solid_mode();
}
示例#27
0
void Alleg4Surface::drawLine(gfx::Color color, const gfx::Point& a, const gfx::Point& b)
{
  if (gfx::geta(color) < 255) {
    set_trans_blender(0, 0, 0, gfx::geta(color));
    drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
  }

  line(m_bmp, a.x, a.y, b.x, b.y, to_allegro(bitmap_color_depth(m_bmp), color));
  solid_mode();
}
示例#28
0
//Create the stream sample which will be used to call updates on the video
HRESULT InitRenderToSurface() {

    HRESULT hr;
    DDSURFACEDESC	ddsd;

    //Use the multimedia stream to get the primary video media stream
    hr = g_pMMStream->GetMediaStream(MSPID_PrimaryVideo, &g_pPrimaryVidStream);
    if (FAILED(hr)) {
        strcpy (lastError, "MMStream::GetMediaStream failed to create the primary video stream.");
        return E_FAIL;
    }

    //Use the media stream to get the IDirectDrawMediaStream
    hr = g_pPrimaryVidStream->QueryInterface(IID_IDirectDrawMediaStream, (void **)&g_pDDStream);
    if (FAILED(hr)) {
        strcpy(lastError, "The video stream does not support the IDirectDrawMediaStream interface; ensure you have the latest DirectX version installed.");
        return E_FAIL;
    }

    //Must set dwSize before calling GetFormat
    ddsd.dwSize = sizeof(ddsd);
    hr = g_pDDStream->GetFormat(&ddsd, NULL, NULL, NULL);
    if (FAILED(hr)) {
        strcpy(lastError, "IDirectDrawMediaStream::GetFormat failed");
        return E_FAIL;
    }

    RECT rect;
    rect.top = rect.left = 0;
    // these are the width and height of the video
    rect.bottom = ddsd.dwHeight;
    rect.right = ddsd.dwWidth;

    if (vscreen == NULL)
        vscreen = gfx_directx_create_system_bitmap(ddsd.dwWidth, ddsd.dwHeight);

    if (vscreen == NULL) {
        strcpy(lastError, "Unable to create the DX Video System Bitmap");
        return E_FAIL;
    }

    vsMemory = create_bitmap_ex(bitmap_color_depth(vscreen), vscreen->w, vscreen->h);

    IDirectDrawSurface *g_pDDSOffscreen;
    g_pDDSOffscreen = get_bitmap_surface (vscreen);

    //Create the stream sample
    hr = g_pDDStream->CreateSample(g_pDDSOffscreen, &rect, 0, &g_pSample);
    if (FAILED(hr)) {
        strcpy (lastError, "VideoStream::CreateSample failed");
        return E_FAIL;
    }

    return NOERROR;
}
示例#29
0
文件: gui.cpp 项目: Julien-B/aseprite
static void save_gui_config()
{
    she::Display* display = Manager::getDefault()->getDisplay();
    if (display) {
        set_config_bool("GfxMode", "Maximized", display->isMaximized());
        set_config_int("GfxMode", "Width", display->originalWidth());
        set_config_int("GfxMode", "Height", display->originalHeight());
        set_config_int("GfxMode", "Depth", bitmap_color_depth(screen));
    }
    set_config_int("GfxMode", "ScreenScale", screen_scaling);
}
示例#30
0
void IAGSEngine::GetBitmapDimensions (BITMAP *bmp, int32 *width, int32 *height, int32 *coldepth) {
  if (bmp == NULL)
    return;
  
  if (width != NULL)
    width[0] = bmp->w;
  if (height != NULL)
    height[0] = bmp->h;
  if (coldepth != NULL)
    coldepth[0] = bitmap_color_depth(bmp);
}