示例#1
1
// -----------------------------------------------------------------------------
// Calculates the decode size and prepares members for scaling. 
// -----------------------------------------------------------------------------
//
TSize CMPXImageUtil::CalculateDecodeSize(const TSize& aSize)
    {
    const TFrameInfo& frameInfo = iImageDecoder->FrameInfo();
    TSize bitmapSize = frameInfo.iOverallSizeInPixels;
    TReal sourceAspectRatio( TReal( bitmapSize.iWidth) / bitmapSize.iHeight );
    TReal destinationAspectRatio( TReal( aSize.iWidth ) / aSize.iHeight );
    TReal xScale = TReal( bitmapSize.iWidth ) / aSize.iWidth;
    TReal yScale = TReal( bitmapSize.iHeight ) / aSize.iHeight;
    TReal scale(0.0f);
    
    if ( sourceAspectRatio > destinationAspectRatio )
        {
        scale = xScale;
        iSize.iWidth = aSize.iWidth;
        iSize.iHeight = Stretch( TReal( bitmapSize.iHeight ) / scale , 
                                 aSize.iHeight );
        }
    else
        {
        scale = yScale;
        iSize.iWidth = Stretch( TReal( bitmapSize.iWidth ) / scale ,
                                aSize.iWidth);
        iSize.iHeight = aSize.iHeight;
        }
     
    if ((frameInfo.iFlags & TFrameInfo::EFullyScaleable))
        {
        iScaleRquired = EFalse;
        bitmapSize = iSize;
        }
    else
        //Decoder only supports 2, 4 and 8 scallyng, the image will need 
        //to be reescaled after decoding.
        //Decoding to a scale that is just a bit bigger thant the target,
        //this will save memory and resources and we will get a sharp image 
        //after scaling.
        {
        TInt intscale = ( scale >= 8 ) ? 8 : 
                ( scale >= 4 ) ? 4 :
                ( scale >= 2 ) ? 2 : 1;
        TUint xCorrection = ( bitmapSize.iWidth % intscale ) ? 1 : 0;
        TUint yCorrection = ( bitmapSize.iHeight % intscale ) ? 1 : 0;
        bitmapSize.iWidth /= intscale;
        bitmapSize.iHeight /= intscale;
        bitmapSize += TSize( xCorrection, yCorrection );
        iScaleRquired = ETrue;
        }
    return bitmapSize;
    }
示例#2
0
void
Canvas::StretchMono(int dest_x, int dest_y,
                    unsigned dest_width, unsigned dest_height,
                    const Bitmap &src,
                    int src_x, int src_y,
                    unsigned src_width, unsigned src_height,
                    Color fg_color, Color bg_color)
{
  assert(IsDefined());
  assert(src.IsDefined());

#ifndef _WIN32_WCE
  if (bg_color == COLOR_BLACK && (src_width != dest_width ||
                                  src_height != dest_height)) {
    /* workaround for a WINE bug: stretching a mono bitmap ignores the
       text color; this kludge makes the text color white */
    SetTextColor(COLOR_BLACK);
    SetBackgroundColor(COLOR_WHITE);
    Stretch(dest_x, dest_y, dest_width, dest_height,
            src, src_x, src_y, src_width, src_height,
            MERGEPAINT);
    return;
  }
#endif

  /* on GDI, monochrome bitmaps are special: they are painted with the
     destination HDC's current colors */
  SetTextColor(fg_color);
  SetBackgroundTransparent();

  Stretch(dest_x, dest_y, dest_width, dest_height,
          src, src_x, src_y, src_width, src_height);
}
示例#3
0
void Bitmap::drawShadow(Bitmap & where, int x, int y, int intensity, Color color, double scale, bool facingRight) const {
    const double newheight = getHeight() * scale;
    Bitmap shade(getWidth(), (int) fabs(newheight));
    Stretch(shade);

    /* Could be slow, but meh, lets do it for now to make it look like a real shadow */
    for (int h = 0; h < shade.getHeight(); ++h){
        for (int w = 0; w < shade.getWidth(); ++w){
            Color pix = shade.getPixel(w, h);
            if (pix != MaskColor()){
                shade.putPixel(w, h, color);
            }
        }
    }

    transBlender(0, 0, 0, intensity);

    if (scale > 0){
        if (facingRight){
            shade.translucent().drawVFlip(x, y, where);
        } else { 
            shade.translucent().drawHVFlip(x, y, where);
        }
    } else if (scale < 0){
        y -= fabs(newheight);
        if (facingRight){
            shade.translucent().draw(x + 3, y, where);
        } else { 
            shade.translucent().drawHFlip(x - 3, y, where);
        }
    }
}
示例#4
0
void StretchedBitmap::finish(){
    if (getData() != where.getData()){
        switch (filter){
            case NoFilter: Stretch(where); break;
            case HqxFilter: {
                if (scaleToFilter.getWidth() > 1 &&
                    scaleToFilter.getHeight() > 1){
                    StretchHqx(scaleToFilter);
                    scaleToFilter.Stretch(where);
                } else {
                    StretchHqx(where);
                }
                break;
            }
            case XbrFilter: {
                if (scaleToFilter.getWidth() > 1 &&
                    scaleToFilter.getHeight() > 1){
                    StretchXbr(scaleToFilter);
                    scaleToFilter.Stretch(where);
                } else {
                    StretchXbr(where);
                }
                break;
            }
        }
    }
}
示例#5
0
void BaseMesh::CreateBox(float w, float h, float d, int refinement)
{
    Allocate(8, 12);

    MeshVertex Temp(Vec3f::Origin, Vec3f::Origin, RGBColor::White, Vec2f::Origin);

    int i,vc=VertexCount(),ic=IndexCount();
    MeshVertex *V = Vertices();
    DWORD *I = Indices();

    for(i=0;i<8;i++)
    {
        Temp.Pos = Vec3f(CubeVData[i][0],CubeVData[i][1],CubeVData[i][2]);
        V[i] = Temp;        ///load the vertices
    }
    for(i=0;i<12;i++)
    {
        I[i*3+0] = CubeIData[i][0];
        I[i*3+1] = CubeIData[i][1];
        I[i*3+2] = CubeIData[i][2];    //load the triangles
    }

    for(i=0;i<refinement;i++)
    {
        TwoPatch();                //refine the requested number of times
    }

    Stretch(Vec3f(0.5f*w, 0.5f*h, 0.5f*d));    //stretch to the requested dimensions
    GenerateNormals();
}
示例#6
0
void TrueLong::ShiftUp( ulong cnt )
{
   if( IsZero() )   return;

   ulong word_cnt = cnt >> 4;
   Stretch( meenl + word_cnt + 1 );
   memset( value + meenl, 0, (word_cnt + 1)*2 );
   if( word_cnt )
   {
      memmove( value + word_cnt, value, meenl*2 );
      memset( value, 0, word_cnt*2 );
   }
   meenl += word_cnt;

   uchar bits = uchar(cnt) & 0x0F; // Вот на такое кол-во бит и осталось сдвинуть массив
   if( !bits )   return;

   ushort *beg = value + word_cnt, *cur = value + meenl - 1;
   ushort add = 0;
   for( ulong* curl; cur >= beg; cur-- )
   {
       curl = (ulong*)cur;
       (*curl) <<= bits;
       cur[1] |= add;
       add = *cur;
       *cur = 0;
   }
   cur[1] |= add;
   if( value[meenl] )
      meenl++;
}
示例#7
0
文件: Canvas.cpp 项目: DRIZO/xcsoar
void
Canvas::StretchNot(const Bitmap &src)
{
  assert(src.IsDefined());

  GLLogicOp invert(GL_COPY_INVERTED);
  Stretch(src);
}
示例#8
0
void
Canvas::Stretch(int dest_x, int dest_y,
                unsigned dest_width, unsigned dest_height,
                const GLTexture &texture)
{
  Stretch(dest_x, dest_y, dest_width, dest_height,
          texture, 0, 0, texture.GetWidth(), texture.GetHeight());
}
示例#9
0
void
Canvas::Stretch(PixelScalar dest_x, PixelScalar dest_y,
                UPixelScalar dest_width, UPixelScalar dest_height,
                const GLTexture &texture)
{
  Stretch(dest_x, dest_y, dest_width, dest_height,
          texture, 0, 0, texture.GetWidth(), texture.GetHeight());
}
示例#10
0
文件: Canvas.hpp 项目: LK8000/LK8000
 void Stretch(int dest_x, int dest_y,
              unsigned dest_width, unsigned dest_height,
              const Canvas &src,
              int src_x, int src_y,
              unsigned src_width, unsigned src_height) {
   Stretch(dest_x, dest_y, dest_width, dest_height,
           src.buffer, src_x, src_y, src_width, src_height);
 }
示例#11
0
void
Canvas::stretch_transparent(const Bitmap &src, Color key)
{
  assert(src.IsDefined());

  // XXX
  Stretch(src);
}
示例#12
0
void
Canvas::Stretch(const Canvas &src,
                int src_x, int src_y,
                unsigned src_width, unsigned src_height)
{
  Stretch(0, 0, GetWidth(), GetHeight(),
          src, src_x, src_y, src_width, src_height);
}
示例#13
0
void
Canvas::Copy(int dest_x, int dest_y,
             unsigned dest_width, unsigned dest_height,
             const Bitmap &src, int src_x, int src_y)
{
  Stretch(dest_x, dest_y, dest_width, dest_height,
          src, src_x, src_y, dest_width, dest_height);
}
示例#14
0
void
Canvas::Stretch(const Bitmap &src)
{
  assert(src.IsDefined());

  const PixelSize size = src.GetSize();
  Stretch(src, 0, 0, size.cx, size.cy);
}
示例#15
0
void
Canvas::copy(PixelScalar dest_x, PixelScalar dest_y,
             UPixelScalar dest_width, UPixelScalar dest_height,
             const Bitmap &src, PixelScalar src_x, PixelScalar src_y)
{
  Stretch(dest_x, dest_y, dest_width, dest_height,
          src, src_x, src_y, dest_width, dest_height);
}
示例#16
0
 void StretchNotOr(PixelScalar dest_x, PixelScalar dest_y,
                   UPixelScalar dest_width, UPixelScalar dest_height,
                   const Bitmap &src,
                   PixelScalar src_x, PixelScalar src_y,
                   UPixelScalar src_width, UPixelScalar src_height) {
   Stretch(dest_x, dest_y, dest_width, dest_height,
           src, src_x, src_y, src_width, src_height,
           MERGEPAINT);
 }
示例#17
0
 void StretchAnd(PixelScalar dest_x, PixelScalar dest_y,
                 UPixelScalar dest_width, UPixelScalar dest_height,
                 const Bitmap &src,
                 PixelScalar src_x, PixelScalar src_y,
                 UPixelScalar src_width, UPixelScalar src_height) {
   Stretch(dest_x, dest_y, dest_width, dest_height,
           src, src_x, src_y, src_width, src_height,
           SRCAND);
 }
示例#18
0
BOOL CCJDockContext::TrackDockBar()
{
	if (::GetCapture() != NULL)
		return FALSE;
	m_pBar->SetCapture();
	ASSERT(m_pBar == CWnd::GetCapture());
	
	while (CWnd::GetCapture() == m_pBar)
	{
		MSG msg;
		if (!::GetMessage(&msg, NULL, 0, 0))
		{
			AfxPostQuitMessage(msg.wParam);
			break;
		}
		
		switch (msg.message)
		{
		case WM_LBUTTONUP:
			if (m_bDragging)
				EndDragDockBar();
			else
				EndResize();
			return TRUE;
		case WM_MOUSEMOVE:
			if (m_bDragging)
				MoveDockBar(msg.pt);
			else
				Stretch(msg.pt);
			break;
		case WM_KEYUP:
			if (m_bDragging)
				OnKey((int)msg.wParam, FALSE);
			break;
		case WM_KEYDOWN:
			if (m_bDragging)
				OnKey((int)msg.wParam, TRUE);
			if (msg.wParam == VK_ESCAPE)
			{
				CancelLoop();
				return FALSE;
			}
			break;
		case WM_RBUTTONDOWN:
			CancelLoop();
			return FALSE;
			
			// just dispatch rest of the messages
		default:
			DispatchMessage(&msg);
			break;
		}
	}
	
	CancelLoop();
	return FALSE;
}
示例#19
0
void
Canvas::invert_stretch_transparent(const Bitmap &src, Color key)
{
  assert(src.IsDefined());

  // XXX
  GLLogicOp invert(GL_COPY_INVERTED);
  Stretch(src);
}
示例#20
0
 void Stretch(PixelScalar dest_x, PixelScalar dest_y,
              UPixelScalar dest_width, UPixelScalar dest_height,
              const Canvas &src,
              PixelScalar src_x, PixelScalar src_y,
              UPixelScalar src_width, UPixelScalar src_height) {
   Stretch(dest_x, dest_y, dest_width, dest_height,
           src.surface,
           src_x, src_y, src_width, src_height);
 }
示例#21
0
void
Canvas::Stretch(int dest_x, int dest_y,
                unsigned dest_width, unsigned dest_height,
                const Bitmap &src)
{
  assert(src.IsDefined());

  const PixelSize size = src.GetSize();
  Stretch(dest_x, dest_y, dest_width, dest_height,
          src, 0, 0, size.cx, size.cy);
}
示例#22
0
void
Canvas::StretchNotOr(PixelScalar dest_x, PixelScalar dest_y,
                     UPixelScalar dest_width, UPixelScalar dest_height,
                     const Bitmap &src,
                     PixelScalar src_x, PixelScalar src_y,
                     UPixelScalar src_width, UPixelScalar src_height)
{
  GLLogicOp logic_op(GL_OR_INVERTED);
  Stretch(dest_x, dest_y, dest_width, dest_height,
          src, src_x, src_y, src_width, src_height);
}
示例#23
0
void
Canvas::StretchNot(const Bitmap &src)
{
  assert(IsDefined());
  assert(src.IsDefined());

  const PixelSize size = src.GetSize();

  Stretch(0, 0, GetWidth(), GetHeight(),
          src.GetNative(), 0, 0, size.cx, size.cy,
          NOTSRCCOPY);
}
示例#24
0
void
Canvas::Stretch(int dest_x, int dest_y,
                unsigned dest_width, unsigned dest_height,
                const Bitmap &_src)
{
  assert(IsDefined());
  assert(_src.IsDefined());

  ConstImageBuffer src = _src.GetNative();
  Stretch(dest_x, dest_y, dest_width, dest_height,
          src, 0, 0, src.width, src.height);
}
示例#25
0
  void Stretch(PixelScalar dest_x, PixelScalar dest_y,
               UPixelScalar dest_width, UPixelScalar dest_height,
               HDC src,
               PixelScalar src_x, PixelScalar src_y,
               UPixelScalar src_width, UPixelScalar src_height) {
    assert(IsDefined());
    assert(src != NULL);

    Stretch(dest_x, dest_y, dest_width, dest_height,
            src, src_x, src_y, src_width, src_height,
            SRCCOPY);
  }
示例#26
0
void D3D9Mesh::CreateTeapot(float radius)
{
    //just call the DirectX function to create the teapot
    FreeMemory();
    LPD3DXMESH teapot;
    D3DXCreateTeapot(GetD3DDevice(), &teapot, NULL);
    teapot->CloneMeshFVF(D3DMeshOptions, D3DMeshFVF, GetD3DDevice(), &_Mesh);
    teapot->Release();
    Stretch(radius);
    SetColor(RGBColor::White);
    GenerateNormals();
}
示例#27
0
  void Stretch(PixelScalar dest_x, PixelScalar dest_y,
               UPixelScalar dest_width, UPixelScalar dest_height,
               const Canvas &src,
               PixelScalar src_x, PixelScalar src_y,
               UPixelScalar src_width, UPixelScalar src_height,
               DWORD dwRop=SRCCOPY) {
    assert(IsDefined());
    assert(src.IsDefined());

    Stretch(dest_x, dest_y, dest_width, dest_height,
            src.dc, src_x, src_y, src_width, src_height,
            dwRop);
  }
示例#28
0
void
Canvas::Stretch(int dest_x, int dest_y,
                unsigned dest_width, unsigned dest_height,
                const Bitmap &src,
                int src_x, int src_y,
                unsigned src_width, unsigned src_height)
{
  assert(IsDefined());
  assert(src.IsDefined());

  Stretch(dest_x, dest_y, dest_width, dest_height,
          src.GetNative(),
          src_x, src_y, src_width, src_height);
}
示例#29
0
void
Canvas::ScaleCopy(int dest_x, int dest_y,
                  const Bitmap &src,
                  int src_x, int src_y,
                  unsigned src_width, unsigned src_height)
{
  if (Layout::ScaleEnabled())
    Stretch(dest_x, dest_y,
            Layout::Scale(src_width), Layout::Scale(src_height),
            src, src_x, src_y, src_width, src_height);
  else
    Copy(dest_x, dest_y, src_width, src_height,
         src, src_x, src_y);
}
示例#30
0
void
Canvas::ScaleCopy(PixelScalar dest_x, PixelScalar dest_y,
                   const Bitmap &src,
                   PixelScalar src_x, PixelScalar src_y,
                   UPixelScalar src_width, UPixelScalar src_height)
{
  if (Layout::ScaleEnabled())
    Stretch(dest_x, dest_y,
            Layout::Scale(src_width), Layout::Scale(src_height),
            src, src_x, src_y, src_width, src_height);
  else
    Copy(dest_x, dest_y, src_width, src_height,
         src, src_x, src_y);
}