Example #1
0
void BumpDraw( HWND hWindow )
/***********************************************************************/
{
	LPVIDEO lpVideo;
	if ( !(lpVideo = (LPVIDEO)GetWindowLong( hWindow, GWL_DATAPTR )) )
		return;

	RECT SRect = SrcRect;
	RECT DRect = DstRect;
	int iZoomFactor = (int)GetSwitchValue( 'z', lpVideo->lpSwitches );
	if ( !iCount )
	{
		SRect.top += 10;
		DRect = SRect;
		ScaleRect( &DRect, iZoomFactor );
		iCount = 1;
	}
	else
	{
		SRect.top -= 10;
		DRect = SRect;
		ScaleRect( &DRect, iZoomFactor );
		iCount = 0;
	}
	MCIClip( lpVideo->hDevice, &SRect, NULL/*&DRect*/, /*0*/iZoomFactor );
}
Example #2
0
void StatusOfRectangle(
/***********************************************************************/
LPRECT lpRect,
LFIXED fScale)
{
STRING szUnit, szString1, szString2, szString3, szString4;
LPSTR lpUnit;
RECT rFile;
int Resolution;

OrderRect( lpRect, &rFile );
if ( fScale )
	{
	Resolution = 1000;
	ScaleRect( &rFile, fScale );
	}
else
if (lpImage)
	Resolution = FrameResolution( ImgGetBaseEditFrame(lpImage) );
if ( AstralStr( Control.Units-IDC_PREF_UNITINCHES+IDS_INCHES, &lpUnit ) )
	{
	lstrcpy( szUnit, lpUnit );
	MessageStatus( IDS_RECT_STATUS,
		Unit2String( FGET( RectWidth(&rFile), Resolution ), szString1 ),
		Unit2String( FGET( RectHeight(&rFile), Resolution ), szString2),
		(LPSTR)szUnit,
		Unit2String( FGET( rFile.left, Resolution ), szString3 ),
		Unit2String( FGET( rFile.top, Resolution ), szString4 ) );
	}
}
void WidgetThumbnailGenerator::PaintBrowserViewThumbnail(OpBrowserView* browser_view)
{
	OpRect root_rect = m_widget.GetRect(TRUE);

	OpRect browser_rect = browser_view->GetRect(TRUE);
	browser_rect.OffsetBy(-root_rect.x, -root_rect.y);
	browser_rect = ScaleRect(browser_rect);

	if (browser_rect.width == 0 || browser_rect.height == 0)
		return;

	Image thumbnail;

	if(m_no_scale)
	{
		thumbnail = browser_view->GetSnapshotImage();
	}
	else
	{
		thumbnail = browser_view->GetThumbnailImage(browser_rect.width, browser_rect.height, m_high_quality);
	}
	OpBitmap *bitmap = thumbnail.GetBitmap(0);
	if(bitmap)
	{
		if (!thumbnail.IsEmpty())
			m_painter->DrawBitmapClipped(bitmap, OpRect(0, 0, thumbnail.Width(), thumbnail.Height()), OpPoint(browser_rect.x, browser_rect.y));

		thumbnail.ReleaseBitmap();
	}
}
Example #4
0
//-------------------------------------------------------------------------------
//
// SetupFilterRecordForProxy
//
// Called by the UI routine to set up the gFilterRecord with the proxy view
// information. CalcProxyScaleFactor sizes the proxy rectangle and calculates the
// scale factor. Then set up gFilterRecord and call advanceState() to init the
// inData with the pixel data for the display.
//
// Global Inputs and Outputs:
//		FilterRecord *gFilterRecord		inRect, inRowBytes, maskRect, etc. has all
//										the information needed to call 
//										advanceState so inData points to the proxy
//										pixel data and maskRect points to the 
//										selection data
//			
//-------------------------------------------------------------------------------
void SetupFilterRecordForProxy(void)
{
	CalcProxyScaleFactor();

	SetInRect(GetFilterRect()); // gFilterRecord->inRect = gFilterRecord->filterRect;
	
	VRect tempRect = GetInRect();
	
	ScaleRect(tempRect, 1, (int16)gData->scaleFactor);

	SetInRect(tempRect);
	
	SetMaskRect(GetInRect()); // gFilterRecord->maskRect = gFilterRecord->inRect;

	// Fixed numbers are 16.16 values 
	// the first 16 bits represent the whole number
	// the last 16 bits represent the fraction
	gFilterRecord->inputRate = (int32)gData->scaleFactor << 16;
	gFilterRecord->maskRate = (int32)gData->scaleFactor << 16;
 
	gFilterRecord->inputPadding = 255;
	gFilterRecord->maskPadding = gFilterRecord->inputPadding;
	
	gData->proxyWidth = gData->proxyRect.right - gData->proxyRect.left;
	gData->proxyHeight = gData->proxyRect.bottom - gData->proxyRect.top;
	gData->proxyPlaneSize = gData->proxyWidth * gData->proxyHeight;
}
Example #5
0
void
PageSetupWindow::UpdateSetupMessage()
{
    SetInt32(fSetupMsg, "xres", 300);
    SetInt32(fSetupMsg, "yres", 300);
    SetInt32(fSetupMsg, "orientation", fCurrentOrientation);

    // Save scaling factor
    float scale = atoi(fScaleControl->Text());
    if (scale <= 0.0) scale = 100.0;
    if (scale > 1000.0) scale = 1000.0;
    SetFloat(fSetupMsg, "scale", scale);

    float scaleR = 100.0 / scale;
    BMenuItem *item = fPageSizeMenu->Menu()->FindMarked();
    if (item) {
        float w, h;
        BMessage *msg = item->Message();
        msg->FindFloat("width", &w);
        msg->FindFloat("height", &h);
        BRect r(0, 0, w, h);
        if (fCurrentOrientation == PrinterDriver::LANDSCAPE_ORIENTATION)
            r.Set(0, 0, h, w);

        SetRect(fSetupMsg, "preview:paper_rect", r);
        SetRect(fSetupMsg, "paper_rect", ScaleRect(r, scaleR));
        SetString(fSetupMsg, "preview:paper_size", item->Label());

        // Save the printable_rect
        BRect margin = fMarginView->Margin();
        if (fCurrentOrientation == PrinterDriver::PORTRAIT_ORIENTATION) {
            margin.right = w - margin.right;
            margin.bottom = h - margin.bottom;
        } else {
            margin.right = h - margin.right;
            margin.bottom = w - margin.bottom;
        }
        SetRect(fSetupMsg, "preview:printable_rect", margin);
        SetRect(fSetupMsg, "printable_rect", ScaleRect(margin, scaleR));

        SetInt32(fSetupMsg, "units", fMarginView->Unit());
    }
}
Example #6
0
//-------------------------------------------------------------------------------
//
// CalcProxyScaleFactor
//
// Called by the UI routine to change the size of the Proxy rectangle and 
// calculate the scale factor. This information is needed by the displayPixels
// routine and the advanceState routine.
//
// Global Inputs:
//		Rect gFilterRecord->filterRect		Rectangle to filter
//
// Global Inputs and Outputs:
//		Rect gData->proxyRect				Rectangle for the Proxy to display in
//		float gData->scaleFactor			Scale factor of the filterRect 
//											to the ProxyRect
//			
//-------------------------------------------------------------------------------
void CalcProxyScaleFactor(void)
{
	int32 filterHeight, filterWidth, itemHeight, itemWidth;
	VPoint fraction;
	
	VRect filterRect = GetFilterRect();
	
	// we place a black frame around the proxy and leave a black
	// between the frame and the actual pixel data
	ShrinkRect(gData->proxyRect, 2, 2);

	filterHeight = filterRect.bottom - filterRect.top;
	filterWidth  = filterRect.right  - filterRect.left;
	
	itemHeight = (gData->proxyRect.bottom - gData->proxyRect.top);
	itemWidth  = (gData->proxyRect.right  - gData->proxyRect.left);
	
	// make sure the proxy isn't bigger than the image after the calculation
	// this will make the proxy half the size for images smaller than the proxy
	if (itemHeight > filterHeight)
		itemHeight = filterHeight;
		
	if (itemWidth > filterWidth)
		itemWidth = filterWidth;
	
	fraction.h = ((filterWidth + itemWidth) / itemWidth);
	fraction.v = ((filterHeight + itemHeight) / itemHeight);

	// calculate the scale factor based on the smaller of height or width
	if (fraction.h > fraction.v) 
		gData->scaleFactor = ((float)filterWidth + (float)itemWidth) /
		                      (float)itemWidth;
	else
		gData->scaleFactor = ((float)filterHeight + (float)itemHeight) / 
		                      (float)itemHeight;

	CopyRect(gData->proxyRect, filterRect);	
	ScaleRect(gData->proxyRect, 1, (int16)gData->scaleFactor);

	// recalculate the scale factor based on the actual proxy size
	// this will reduce rounding errors in the proxy view
	if (fraction.h > fraction.v) 
		gData->scaleFactor = (float)filterWidth / 
		                      (float)(gData->proxyRect.right  - 
							   gData->proxyRect.left);
	else
		gData->scaleFactor = (float)filterHeight / 
							  (float)(gData->proxyRect.bottom - 
							   gData->proxyRect.top);
}
Example #7
0
void wxImageBox::Paint()
{
  // image width & height
  m_imageWidth = (int) (GetImage().GetWidth()*m_scale);
  m_imageHeight = (int) (GetImage().GetHeight()*m_scale);
  if (m_imageWidth == 0 || m_imageHeight == 0)
  {
	delete m_buffer;
	m_buffer = new wxBitmap(0,0);
    return;
  }
  
  // get paintRect
  wxRect paintRect = getPaintRect();
  // make buffer 2 times as big as visible area (paintRect)
  paintRect.x -= paintRect.width/2; if (paintRect.x < 0) paintRect.x = 0;
  paintRect.y -= paintRect.height/2; if (paintRect.y < 0) paintRect.y = 0;
  paintRect.width *= 2;
  paintRect.height *= 2;
  
  if (paintRect.GetRight() > m_imageWidth)
    paintRect.width = m_imageWidth - paintRect.x;
  if (paintRect.GetBottom() > m_imageHeight)
    paintRect.height = m_imageHeight - paintRect.y;
  
  m_bufferX = paintRect.x;
  m_bufferY = paintRect.y;
  
  // scale
  //wxImage img = GetImage().Scale(m_imageWidth, m_imageHeight);
  wxRect subRect = ScaleRect(paintRect, 1/m_scale);
  wxImage img;
  int imgw = GetImage().GetWidth();
  int imgh = GetImage().GetHeight();
  // if subRect equal image (+-1%)
  if (subRect.x*100/imgw!=0 || subRect.y*100/imgh!=0 ||
     (subRect.width-imgw)*100/imgw!=0 || (subRect.height-imgh)*100/imgh!=0)
    img = GetImage().GetSubImage(subRect);
  else
    img = GetImage();
  img = img.Scale(paintRect.width, paintRect.height);
  
  PaintImg(img);
  delete m_buffer;
  m_buffer = new wxBitmap(img);
}
Example #8
0
File: magwin.c Project: gzorin/e17
static void
MagwinRedraw(MagWindow * mw, int paint)
{
   int                 ww, wh;
   int                 sx, sy, sw, sh;
   double              scale;
   int                 zoom_res;
   Drawable            draw;
   char                buf[128];
   int                 px, py;
   int                 qx, qy;
   int                 out;
   unsigned int        len;

   ww = mw->ewin->client.w;
   wh = mw->ewin->client.h;

   zoom_res = Conf.magwin.zoom_res;
   if (mw->scale < -6 * zoom_res)
      mw->scale = -6 * zoom_res;
   else if (mw->scale > 6 * zoom_res)
      mw->scale = 6 * zoom_res;
   scale = pow(2., (double)(mw->scale) / zoom_res);
   sw = (int)((ww + .999 * scale) / scale);
   if (sw > WinGetW(VROOT))
      scale = (double)ww / (double)WinGetW(VROOT);
   sh = (int)((wh + .999 * scale) / scale);
   if (sh > WinGetH(VROOT) && scale < (double)wh / (double)WinGetH(VROOT))
      scale = (double)wh / (double)WinGetH(VROOT);
   sw = (int)((ww + .999 * scale) / scale);
   sh = (int)((wh + .999 * scale) / scale);
   sx = mw->cx - sw / 2;
   sy = mw->cy - sh / 2;
   if (sx < 0)
      sx = 0;
   else if (sx + sw > WinGetW(VROOT))
      sx = WinGetW(VROOT) - sw;
   if (sy < 0)
      sy = 0;
   else if (sy + sh > WinGetH(VROOT))
      sy = WinGetH(VROOT) - sh;

   mw->sx = sx;
   mw->sy = sy;
   mw->sw = sw;
   mw->sh = sh;

   if (paint)
     {
	int                 dw, dh;

	dw = (int)(sw * scale + .5);
	dh = (int)(sh * scale + .5);
	draw = ECompMgrGetRootBuffer();
	ScaleRect(VROOT, draw, EwinGetClientWin(mw->ewin),
		  EwinGetClientXwin(mw->ewin), sx, sy, sw, sh,
		  0, 0, dw, dh, (mw->filter) ? EIMAGE_ANTI_ALIAS : 0);
     }

   if (mw->disable_text)
      return;

   /* Check if pointer is in magnifier window */
   EQueryPointer(EwinGetClientWin(mw->ewin), &px, &py, NULL, NULL);
   out = px < 0 || px >= mw->ewin->client.w ||
      py < 0 || py >= mw->ewin->client.h;

   /* Show magnified area coordinates */
   len = Esnprintf(buf, sizeof(buf), "x%.2f: %d,%d %dx%d",
		   scale, sx, sy, sw, sh);

   if (out)
      goto done;

   /* Show info about pixel at cursor (if in magnifier) */
   qx = (int)(px / scale);
   qy = (int)(py / scale);
   if (qx > WinGetW(VROOT) - 1)
      qx = WinGetW(VROOT) - 1;
   if (qy > WinGetH(VROOT) - 1)
      qy = WinGetH(VROOT) - 1;
   Esnprintf(buf + len, sizeof(buf) - len, "\n%d,%d: pixel=%#08x",
	     sx + qx, sy + qy,
	     MagwinGetPixel(EwinGetClientXwin(mw->ewin), px, py));
 done:
   MagwinDrawText(mw, 10, 10, buf);
}