예제 #1
0
void WDL_VirtualIconButton::OnPaintOver(LICE_IBitmap *drawbm, int origin_x, int origin_y, RECT *cliprect)
{
  if (m_iconCfg && m_iconCfg->olimage)
  {
    RECT r;
    GetPositionPaintOverExtent(&r);

    int sx=0;
    int sy=0;
    int w=m_iconCfg->olimage->getWidth();
    int h=m_iconCfg->olimage->getHeight();
    if (m_iconCfg->image_ltrb_used.flags&1)  { w-=2; h-= 2; sx++,sy++; }

    w/=3;

    if (w>0 && h>0)
    {
      if (m_is_button)
      {
        if ((m_pressed&2))  sx+=(m_pressed&1) ? w*2 : w;
      }
      LICE_ScaledBlit(drawbm,m_iconCfg->olimage,r.left+origin_x,r.top+origin_y,
        r.right-r.left,
        r.bottom-r.top,
        (float)sx,(float)sy,(float)w,(float)h, m_alpha,  // m_grayed?
        LICE_BLIT_MODE_COPY|LICE_BLIT_FILTER_BILINEAR|LICE_BLIT_USE_ALPHA);      
    }
  }
}
예제 #2
0
파일: SnM_VWnd.cpp 프로젝트: Breeder/sws
void SNM_ImageVWnd::OnPaint(LICE_IBitmap *drawbm, int origin_x, int origin_y, RECT *cliprect) {
	if (m_img)
	{
		LICE_ScaledBlit(drawbm,m_img,
			m_position.left+origin_x,m_position.top+origin_y,
			m_position.right-m_position.left,m_position.bottom-m_position.top, 
			0.0f,0.0f,(float)GetWidth(),(float)GetHeight(),
			1.0f,LICE_BLIT_MODE_COPY|LICE_BLIT_USE_ALPHA);
	}
}
예제 #3
0
void WDL_VirtualIconButton::OnPaintOver(LICE_IBitmap *drawbm, int origin_x, int origin_y, RECT *cliprect)
{
  if (m_iconCfg && m_iconCfg->olimage)
  {
    int sx=0;
    int sy=0;
    int w=m_iconCfg->olimage->getWidth();
    int h=m_iconCfg->olimage->getHeight();
    if (m_iconCfg->image_ltrb_used.flags&1)  { w-=2; h-= 2; sx++,sy++; }

    w/=3;

    if (w>0 && h>0)
    {
      if (m_is_button)
      {
        if ((m_pressed&2))  sx+=(m_pressed&1) ? w*2 : w;
      }

      if (m_iconCfg->image_ltrb_used.flags&2) // use main image's stretch areas (outer areas become unstretched)
      {
        WDL_VirtualWnd_BGCfg cfg={0,};
        LICE_SubBitmap sb(m_iconCfg->olimage,sx,sy,w,h);
        cfg.bgimage = &sb;
        cfg.bgimage_lt[0] = m_iconCfg->image_ltrb_main[0]+1; // image_ltrb_main expects 1-based number
        cfg.bgimage_lt[1] = m_iconCfg->image_ltrb_main[1]+1;
        cfg.bgimage_rb[0] = m_iconCfg->image_ltrb_main[2]+1;
        cfg.bgimage_rb[1] = m_iconCfg->image_ltrb_main[3]+1;
        cfg.bgimage_lt_out[0] = m_iconCfg->image_ltrb_ol[0]+1;
        cfg.bgimage_lt_out[1] = m_iconCfg->image_ltrb_ol[1]+1;
        cfg.bgimage_rb_out[0] = m_iconCfg->image_ltrb_ol[2]+1;
        cfg.bgimage_rb_out[1] = m_iconCfg->image_ltrb_ol[3]+1;
        cfg.bgimage_noalphaflags=0;

        RECT r=m_position,r2;
        GetPositionPaintOverExtent(&r2);
        WDL_VirtualWnd_ScaledBlitBG(drawbm,&cfg,
          r.left+origin_x,r.top+origin_y,r.right-r.left,r.bottom-r.top,
          r2.left+origin_x,r2.top+origin_y,r2.right-r2.left,r2.bottom-r2.top,
          m_alpha,LICE_BLIT_MODE_COPY|LICE_BLIT_FILTER_BILINEAR|LICE_BLIT_USE_ALPHA);
      }
      else
      {
        RECT r;
        GetPositionPaintOverExtent(&r);
        LICE_ScaledBlit(drawbm,m_iconCfg->olimage,r.left+origin_x,r.top+origin_y,
          r.right-r.left,
          r.bottom-r.top,
          (float)sx,(float)sy,(float)w,(float)h, m_alpha,  // m_grayed?
          LICE_BLIT_MODE_COPY|LICE_BLIT_FILTER_BILINEAR|LICE_BLIT_USE_ALPHA);      
      }
    }
  }
}
예제 #4
0
void StretchBlt(HDC hdcOut, int x, int y, int w, int h, HDC hdcIn, int xin, int yin, int srcw, int srch, int mode)
{
  HDC__ *in = (HDC__ *)hdcIn;
  HDC__ *out = (HDC__ *)hdcOut;
  if (!HDC_VALID(out) || !HDC_VALID(in)) return;
  if (!in->surface || !out->surface) return;
  LICE_ScaledBlit(out->surface,in->surface,
            x+out->surface_offs.x,y+out->surface_offs.y,w,h,
            xin+in->surface_offs.x,yin+in->surface_offs.y,srcw,srch,
            1.0f,LICE_BLIT_MODE_COPY);
  swell_DirtyContext(out,x,y,x+w,y+h);
}
예제 #5
0
void WDL_VirtualIconButton::OnPaint(LICE_IBitmap *drawbm, int origin_x, int origin_y, RECT *cliprect) 
{ 
  int col;

  float alpha = (m_grayed ? 0.25f : 1.0f) * m_alpha;

  bool isdown = !!(m_pressed&1);
  bool ishover = !!(m_pressed&2);

  if (m_iconCfg && m_iconCfg->image && !m_iconCfg->image_issingle)
  {
    bool swapupdown = (m_checkstate > 0);
    bool isdownimg = (swapupdown != isdown);
    
    RECT r=m_position;

    int sx=0;
    int sy=0;
    int w=m_iconCfg->image->getWidth();
    int h=m_iconCfg->image->getHeight();

    if (w>0 && (m_iconCfg->image_ltrb_used.flags&2))
      w-=2;

    w/=3;
    if (w>0 && h > 0)
    {
      if (m_is_button)
      {
        if (isdownimg) sx += w*2;
        else if (ishover) sx += w;
      }


      if (m_iconCfg->image_ltrb_used.flags&2)
      {
        WDL_VirtualWnd_BGCfg cfg={0,};
        LICE_SubBitmap sb(m_iconCfg->image,sx+1,sy+1,w,h-2);
        cfg.bgimage = &sb;
        cfg.bgimage_lt[0] = m_iconCfg->image_ltrb_main[0]+1; // image_ltrb_main expects 1-based number
        cfg.bgimage_lt[1] = m_iconCfg->image_ltrb_main[1]+1;
        cfg.bgimage_rb[0] = m_iconCfg->image_ltrb_main[2]+1;
        cfg.bgimage_rb[1] = m_iconCfg->image_ltrb_main[3]+1;
        cfg.bgimage_noalphaflags=0;

        WDL_VirtualWnd_ScaledBlitBG(drawbm,&cfg,
          r.left+origin_x,r.top+origin_y,r.right-r.left,r.bottom-r.top,
          r.left+origin_x,r.top+origin_y,r.right-r.left,r.bottom-r.top,
          alpha,LICE_BLIT_MODE_COPY|LICE_BLIT_FILTER_BILINEAR|LICE_BLIT_USE_ALPHA);

      }
      else
        LICE_ScaledBlit(drawbm,m_iconCfg->image,r.left+origin_x,r.top+origin_y,
          r.right-r.left,
          r.bottom-r.top,
          (float)sx,(float)sy,(float)w,(float)h, alpha,
          LICE_BLIT_MODE_COPY|LICE_BLIT_FILTER_BILINEAR|LICE_BLIT_USE_ALPHA);      
    }
  }
  else
  {
    RECT r=m_position;
    r.left+=origin_x;
    r.right+=origin_x;
    r.top+=origin_y;
    r.bottom+=origin_y;
    if (m_is_button)
    {
      if (WDL_STYLE_WantGlobalButtonBackground(&col))
      {
        LICE_FillRect(drawbm,r.left,r.top,r.right-r.left,r.bottom-r.top,LICE_RGBA_FROMNATIVE(col,255),alpha,LICE_BLIT_MODE_COPY);
      }

      if (ishover || m_forceborder || WDL_STYLE_WantGlobalButtonBorders())
      {
        int cidx=isdown?COLOR_3DSHADOW:COLOR_3DHILIGHT;

        int pencol = GSC(cidx);
        pencol = LICE_RGBA_FROMNATIVE(pencol,255);

        LICE_Line(drawbm,r.left,r.bottom-1,r.left,r.top,pencol,alpha,LICE_BLIT_MODE_COPY,false);
        LICE_Line(drawbm,r.left,r.top,r.right-1,r.top,pencol,alpha,LICE_BLIT_MODE_COPY,false);
        cidx = isdown?COLOR_3DHILIGHT:COLOR_3DSHADOW;
        pencol = GSC(cidx);
        pencol = LICE_RGBA_FROMNATIVE(pencol,255);
        LICE_Line(drawbm,r.right-1,r.top,r.right-1,r.bottom-1,pencol,alpha,LICE_BLIT_MODE_COPY,false);
        LICE_Line(drawbm,r.right-1,r.bottom-1,r.left,r.bottom-1,pencol,alpha,LICE_BLIT_MODE_COPY,false);
      }
    }
    if (m_iconCfg && m_iconCfg->image)
    {
      int sz=16,sz2=16;
      WDL_STYLE_ScaleImageCoords(&sz,&sz2);

      //if (m_position.right-m_position.left > 24) sz=m_position.right-m_position.left-8;
    
      int x=r.left+((r.right-r.left)-sz)/2;
      int y=r.top+((r.bottom-r.top)-sz2)/2;
      if (m_is_button)
      {
        if (isdown && ishover) { x++; y++; }
      }

      LICE_ScaledBlit(drawbm,m_iconCfg->image,x,y,sz,sz2,0.0f,0.0f,
        (float)m_iconCfg->image->getWidth(),
        (float)m_iconCfg->image->getHeight(),alpha,LICE_BLIT_MODE_COPY|LICE_BLIT_FILTER_BILINEAR|LICE_BLIT_USE_ALPHA);

    }
  }

  if (!m_iconCfg || m_forcetext)
  {
    RECT r2=m_position;
    r2.left+=origin_x;
    r2.right+=origin_x;
    r2.top+=origin_y;
    r2.bottom+=origin_y;

    if (m_checkstate>=0 && !m_iconCfg)
    {
      RECT tr=r2;
      int sz=tr.bottom-tr.top;
      r2.left+=sz+2;

      tr.top+=2;
      tr.bottom-=2;
      sz-=4;
      sz&=~1;
      LICE_FillRect(drawbm ,tr.left,tr.top,sz,sz,LICE_RGBA(255,255,255,255),alpha,LICE_BLIT_MODE_COPY);
      LICE_Line(drawbm,tr.left,tr.top,tr.left+sz,tr.top,LICE_RGBA(128,128,128,255),alpha,LICE_BLIT_MODE_COPY,false);
      LICE_Line(drawbm,tr.left+sz,tr.top,tr.left+sz,tr.bottom,LICE_RGBA(128,128,128,255),alpha,LICE_BLIT_MODE_COPY,false);
      LICE_Line(drawbm,tr.left+sz,tr.bottom,tr.left,tr.bottom,LICE_RGBA(128,128,128,255),alpha,LICE_BLIT_MODE_COPY,false);
      LICE_Line(drawbm,tr.left,tr.bottom,tr.left,tr.top,LICE_RGBA(128,128,128,255),alpha,LICE_BLIT_MODE_COPY,false);
      int nl = (m_checkstate>0) ? 3:0;        
      if (isdown) nl ^= 2;

      if (nl&1)
        LICE_Line(drawbm,tr.left+2,tr.bottom-2,tr.left+sz-2,tr.top+2,LICE_RGBA(0,0,0,255),alpha,LICE_BLIT_MODE_COPY,false);
      if (nl&2)
        LICE_Line(drawbm,tr.left+2,tr.top+2,tr.left+sz-2,tr.bottom-2,LICE_RGBA(0,0,0,255),alpha,LICE_BLIT_MODE_COPY,false);


    }

    LICE_IFont *font = m_textfont;
    bool isVert=false;
    if (font && m_textfontv && m_position.right-m_position.left < m_position.bottom - m_position.top)
    {
      isVert=true;
      font = m_textfontv;
    }
    // draw text
    if (font&&m_textlbl.Get()[0])
    {
      int fgc=m_forcetext_color ? m_forcetext_color : LICE_RGBA_FROMNATIVE(GSC(COLOR_BTNTEXT),255);
      //font->SetCombineMode(LICE_BLIT_MODE_COPY, alpha); // this affects the glyphs that get cached
      font->SetBkMode(TRANSPARENT);
      font->SetTextColor(fgc);

      r2.left += m_margin_l;
      r2.right -= m_margin_r;
      r2.top += m_margin_t;
      r2.bottom -= m_margin_b;

      if (isdown)
      {
        if (m_textalign<0) r2.left+=1;
        else if (m_textalign>0) r2.right+=1;
        else r2.left+=2;
        r2.top+=2;
      }
      int f = DT_SINGLELINE|DT_NOPREFIX;
      if (isVert)
      {
        if (m_textalign == 0)
        {
          RECT mr={0,};
          font->DrawText(drawbm,m_textlbl.Get(),-1,&mr,f|DT_CALCRECT);
          f |= (mr.bottom < r2.bottom-r2.top) ? DT_VCENTER : DT_TOP;
        }
        else
          f |= m_textalign<0?DT_TOP:DT_BOTTOM;

        f |= DT_CENTER;
      }
      else
      {
        if (m_textalign == 0)
        {
          RECT mr={0,};
          font->DrawText(drawbm,m_textlbl.Get(),-1,&mr,f|DT_CALCRECT);
          f |= (mr.right < r2.right-r2.left) ? DT_CENTER : DT_LEFT;
        }
        else
          f |= m_textalign<0?DT_LEFT:DT_RIGHT;

        f |= DT_VCENTER;
      }
      font->DrawText(drawbm,m_textlbl.Get(),-1,&r2,f);
    }
    
  }

  if (m_bgcol1_msg)
  {
    int brcol=-100;
    SendCommand(m_bgcol1_msg,(INT_PTR)&brcol,GetID(),this);
    if (brcol != -100)
    {
      RECT r=m_position;

      int bh=(r.bottom-r.top)/5;
      if (bh<1) bh=1;
      int bw=(r.right-r.left)/5;
      if (bw<1) bw=1;

      LICE_FillRect(drawbm,
        r.left+origin_x,r.top+origin_y,
        r.right-r.left,
        bh,LICE_RGBA_FROMNATIVE(brcol,255),0.75,LICE_BLIT_MODE_COPY);

      LICE_FillRect(drawbm,
        r.left+origin_x,r.top+origin_y+bh,
        bw,
        r.bottom-r.top-bh*2,LICE_RGBA_FROMNATIVE(brcol,255),0.75,LICE_BLIT_MODE_COPY);

      LICE_FillRect(drawbm,
        r.right+origin_x-bw,r.top+origin_y+bh,
        bw,
        r.bottom-r.top-bh*2,LICE_RGBA_FROMNATIVE(brcol,255),0.75,LICE_BLIT_MODE_COPY);

      LICE_FillRect(drawbm,
        r.left+origin_x,r.bottom+origin_y-bh,
        r.right-r.left,
        bh,LICE_RGBA_FROMNATIVE(brcol,255),0.75,LICE_BLIT_MODE_COPY);
    }
  }

} 
예제 #6
0
파일: imgs2gif.cpp 프로젝트: Artogn/licecap
int main(int argc, char **argv)
{
  int delay=10;
  int size_w=0,size_h=0;
  int i;
  int rv=0;
  int leaddelay=0;
  bool skipempty=false;
  void *gifOut=NULL;
  const char *fn=NULL;

  LICE_MemBitmap lastfr, fr,fr2;
  int accum_lat=0;

  for (i=1;i<argc;i++)
  {
    if (argv[i][0]=='-')
    {
      if (fn||gifOut) usage("Flag after filename",argv[i]);

      if (!strcmp(argv[i],"-w")) 
      {
        if (++i >= argc) usage("Missing parameter",argv[i-1]);
        size_w = atoi(argv[i]);
      }
      else if (!strcmp(argv[i],"-h")) 
      {
        if (++i >= argc) usage("Missing parameter",argv[i-1]);
        size_h = atoi(argv[i]);
      }
      else if (!strcmp(argv[i],"-d")) 
      {
        if (++i >= argc) usage("Missing parameter",argv[i-1]);
        delay = atoi(argv[i]);
      }
      else if (!strcmp(argv[i],"-skipempty")) skipempty=true;
      else if (!strcmp(argv[i],"-leaddelay")) 
      {
        if (++i >= argc) usage("Missing parameter",argv[i-1]);
        leaddelay=atoi(argv[i]);
      }
      else usage("Unknown option",argv[i]);
    }
    else if (!fn) fn=argv[i];
    else
    {
      printf("Loading %s\n",argv[i]);
      if (!LICE_LoadImage(argv[i],&fr) || !fr.getWidth() || !fr.getHeight()) 
      {
        printf("Error loading image: %s\n",argv[i]);
        continue;
      }
     
      if (!size_w) size_w=fr.getWidth();
      if (!size_h) size_h=fr.getHeight();
      LICE_MemBitmap *usefr = &fr;
      if (fr.getWidth() != size_w || fr.getHeight() != size_h)
      {
        fr2.resize(size_w,size_h);
        LICE_ScaledBlit(usefr=&fr2,&fr,0,0,size_w,size_h,0,0,fr.getWidth(),fr.getHeight(),1.0f,LICE_BLIT_MODE_COPY|LICE_BLIT_FILTER_BILINEAR);
      }
       
      if (!gifOut)
      {
        gifOut=LICE_WriteGIFBegin(fn,usefr,0,leaddelay?leaddelay:delay,false);
        if (!gifOut) usage("Error writing to file",fn);
      }
      else
      {
        accum_lat += delay;
        int diffcoords[4]={0,0,size_w,size_h};
        if (LICE_BitmapCmp(usefr,&lastfr,diffcoords))
        {
          LICE_SubBitmap bm(usefr,diffcoords[0],diffcoords[1], diffcoords[2],diffcoords[3]);
          LICE_WriteGIFFrame(gifOut,&bm,diffcoords[0],diffcoords[1], true, accum_lat);
          accum_lat=0;
        }
        if (skipempty) accum_lat=0;
      }
 
      LICE_Copy(&lastfr,usefr);
    }
  }
  printf("finishing up\n");
  if (gifOut) LICE_WriteGIFEnd(gifOut);
  
  return rv;
}