void
MapArea::repaintPiece(const GP<MapPiece> & piece)
      // Sends PaintEvent to cause repaint of the specified piece
{
   if (pane && mapper)
   {
      GRect grect=*piece;
      mapper->map(grect);
      
      GRect prect=Q2G(pane->rect());
      GRect irect;
      if (irect.intersect(grect, prect)) repaint(irect);
   }
}
Esempio n. 2
0
void GDialog::OnPosChange()
{
    if (Children.Length() == 1)
    {
        List<GViewI>::I it = Children.Start();
        GTableLayout *t = dynamic_cast<GTableLayout*>((GViewI*)it.First());
        if (t)
        {
            GRect r = GetClient();
            r.Size(GTableLayout::CellSpacing, GTableLayout::CellSpacing);
            t->SetPos(r);
        }
    }
}
void
MapArea::repaint(void)
      // Generates PaintEvents for the whole area
{
   if (pane && mapper)
   {
      GRect brect=gmap_area->get_bound_rect();
      mapper->map(brect);
      brect.inflate(3, 3);	// Take into account possible edit controls

      GRect prect=Q2G(pane->rect());
      GRect irect;
      if (irect.intersect(brect, prect)) repaint(irect);
   }
}
Esempio n. 4
0
File: GView.cpp Progetto: FEI17N/Lgi
GRect &GView::GetClient(bool ClientSpace)
{
	int Edge = (Sunken() || Raised()) ? _BorderSize : 0;

	static GRect c;
	if (ClientSpace)
	{
		c.ZOff(Pos.X() - 1 - (Edge<<1), Pos.Y() - 1 - (Edge<<1));
	}
	else
	{
		c.ZOff(Pos.X()-1, Pos.Y()-1);
		c.Size(Edge, Edge);
	}
	return c;
}
GMsg VectorBuffer::EditFeatureRingFromInteraction(
        long fid, unsigned int geomid, unsigned int vtxid, const feature_ptr &src, const string &proj, const GRect &overwriting)
{
    feature_ptr src_transed = MapnikUtils::copy_feature(src, proj, _layer->proj());
    Q_ASSERT(src_transed->paths().size() == 1);
    feature_ptr ref = GetFeatureById(fid);
    Q_ASSERT(ref != nullptr);
    const geometry_type &geom = src_transed->get_geometry(0);
    MapnikUtils::RingIndex rindex = MapnikUtils::find_ring(ref, geomid, vtxid);
    if (!rindex._found) {
        return GMsg::WRN_INVALID_PARAM.with_instruction("abnormal behavior 0");
    }
    feature_ptr dst = MapnikUtils::replace_vertices(
                ref, geomid, rindex._startid, rindex._endid + 1, geom);
    if (dst == nullptr) {
        return GMsg::WRN_INVALID_PARAM.with_instruction("abnormal behavior 1");
    }

    _undoStack->beginMacro("Repair feature");
    Q_ASSERT(_deletedFeatures.find(fid) == _deletedFeatures.end());
    dst->put<value_unicode_string>(
                _config_app().VIEW_VECTORBUFFER_FIELD_EDITED,
                transcoder("utf-8").transcode("edited"));
    _undoStack->push(new VBCommandEditFeature(this, fid, dst));
    _undoStack->endMacro();

    if (overwriting.is_defined()) {
      std::unordered_set<long> targets = GetFeatureIdsInRect(proj, overwriting);
      std::unordered_set<long> immunes;
      immunes.insert(fid);
      return EraseFeatureFromInteraction(dst, _layer->proj(), targets, immunes);
    }
    return G_NOERR;
}
Esempio n. 6
0
void
DjVuTXT::Zone::get_text_with_rect(const GRect &box, 
                                  int &string_start, int &string_end) const
{
  GPosition pos=children;
  if(pos?box.contains(rect):intersects_zone(box,rect))
  {
    const int text_end=text_start+text_length;
    if(string_start == string_end)
    {
      string_start=text_start;
      string_end=text_end;
    }else
    {
      if (string_end < text_end)
        string_end=text_end;
      if(text_start < string_start)
        string_start=text_start;
    }
  }else if(pos&&intersects_zone(box,rect))
  {
    do
    {
      children[pos].get_text_with_rect(box,string_start,string_end);
    } while(++pos);
  }
}
Esempio n. 7
0
void MyCanvas::shadeRect(const GRect& rect, GShader* shader)
{
  assert(shader != nullptr);
  if (rect.isEmpty())
  {
    printf("Error: ShadeRect rectangle is empty\n");
    return;
  }

  /* Convert the rectangle into points, then CTM the resulting points */
  auto Points = Utility::RectToPoints(rect);  
  CTMPoints(Points);  
 
  if ( !CTM.preservesRect())  //If the CTM does not preserve a rectangle, draw a polygon
  {
    auto Edges = pointsToEdges(Points);
    shadeDevicePolygon(Edges, shader);
    return;
  }
  
  //Convert the CTM'd points back into a rect since we know it preserves it
  GIRect ConvertedRect = Utility::PointsToRect(Points).round();

  // Make sure rect is not an empty one and clip the edges from the bitmap with intersect
  if (ConvertedRect.isEmpty() || !ConvertedRect.intersect(BmpRect)) { return; }

  shadeDeviceRect(ConvertedRect, shader);
}
Esempio n. 8
0
GInput::GInput(GViewI *parent, const char *InitStr, const char *Msg, const char *Title, bool Password, GInputCallback callback, void *callbackparam)
{
	Callback = callback;
	CallbackParam = callbackparam;

	GText *Txt = new GText(-1, 5, 5, -1, -1, Msg);
	GDisplayString MsgDs(SysFont, ValidStr(InitStr)?InitStr:"A");
	int Dx = LgiApp->GetMetric(LGI_MET_DECOR_X) + 10;
	int Dy = LgiApp->GetMetric(LGI_MET_DECOR_Y);
	
	int ContextX = 400;
	ContextX = max(ContextX, MsgDs.X() + 40);
	ContextX = min(ContextX, (int)(GdcD->X() * 0.8));
	int EditX = ContextX;
	int CallbackX = callback ? GBUTTON_MIN_X + 20 : 0;
	ContextX = max(ContextX, Txt->X() + CallbackX);

	GRect r(0, 0, ContextX + CallbackX + Dx, 70 + Txt->Y() + Dy);

	SetParent(parent);
	Name(Title);
	SetPos(r);
	MoveToCenter();

	GRect c = GetClient();
	Children.Insert(Txt);
	Children.Insert(Edit = new GEdit(IDC_EDIT, 5, Txt->GetPos().y2 + 5, EditX - 1, MsgDs.Y()+7, InitStr));
	if (Edit)
	{
		Edit->Password(Password);
		Edit->Focus(true);
		if (Callback)
		{
			GRect e = Edit->GetPos();
			Children.Insert(new GButton(IDC_CALLBACK, c.X() - (CallbackX-5) - 6, e.y1, CallbackX-5, e.Y()-1, "..."));
		}
	}

	GButton *Ok = new GButton(IDOK, 0, 0, -1, -1, LgiLoadString(L_BTN_OK, "Ok"));
	GButton *Cancel = new GButton(IDCANCEL, 0, 0, -1, -1, LgiLoadString(L_BTN_CANCEL, "Cancel"));
	int BtnX = max(Ok->X(), Cancel->X());
	int BtnY = Edit->GetPos().y2 + 11;
	
	GRect p = Cancel->GetPos();
	p.x2 = p.x1 + BtnX - 1;
	p.Offset(c.X() - Cancel->X() - 5, BtnY);
	Cancel->SetPos(p);
	
	p = Ok->GetPos();
	p.x2 = p.x1 + BtnX - 1;
	p.Offset(Cancel->GetPos().x1 - p.X() - 5, BtnY);
	Ok->SetPos(p);

	Children.Insert(Ok);
	Children.Insert(Cancel);
	Ok->Default(true);
}
Esempio n. 9
0
void 
GRectMapper::set_output(const GRect &rect)
{
  if (rect.isempty())
    G_THROW( ERR_MSG("GRect.empty_rect2") );
  rectTo = rect;
  rw = rh = GRatio();
}
Esempio n. 10
0
int GDialog::DoModal(OsView OverideParent)
{
	d->ModalStatus = 0;

	if (Wnd && Attach(0))
	{
		GWindow *Owner = GetParent() ? GetParent()->GetWindow() : 0;
		if (Owner)
		{
			GRect Pr = Owner->GetPos();
			GRect Mr = GetPos();
			Mr.Offset(	Pr.x1 + (Pr.X() - Mr.X()) / 2 - Mr.x1,
						Pr.y1 + (Pr.Y() - Mr.Y()) / 2 - Mr.y1);
			SetPos(Mr);
			Owner->SetChildDialog(this);
		}
		
		d->IsModal = true;
		AttachChildren();
		Visible(true);
		
		RunAppModalLoopForWindow(Wnd);

		if (Owner) Owner->SetChildDialog(0);
	}

	return d->ModalStatus;
}
Esempio n. 11
0
File: GRect.cpp Progetto: FEI17N/Lgi
GRect GRegion::Bound()
{
	static GRect r;
	
	if (a && Size > 0)
	{
		r = a[0];
		for (int i=1; i<Size; i++)
		{
			r.Union(a+i);
		}
	}
	else
	{
		r.ZOff(-1, -1);
	}

	return r;
}
Esempio n. 12
0
	void OnMouseClick(GMouse &m)
	{
		GRect r = GetClient();
		r.Size(2, 2);
		if (r.Overlap(m.x, m.y))
		{
			int i = m.y / Ly;
			if (i == 0)
			{
				Colour->Value(0);
			}
			else
			{
				Colour->Value(Colour->Presets[i-1]);
			}

			Visible(false);
		}
	}
Esempio n. 13
0
void 
GBitmap::init(const GBitmap &ref, const GRect &rect, int border)
{
  GMonitorLock lock(monitor());
  // test bitmap physical equality
  if (this == &ref)
    {
      GBitmap tmp;
      tmp.grays = grays;
      tmp.border = border;
      tmp.bytes_per_row = bytes_per_row;
      tmp.ncolumns = ncolumns;
      tmp.nrows = nrows;
      tmp.bytes = bytes;
      tmp.gbytes_data.swap(gbytes_data);
      tmp.grle.swap(grle);
      bytes = 0 ;
      init(tmp, rect, border);
    }
  else
    {
      GMonitorLock lock(ref.monitor());
      // create empty bitmap
      init(rect.height(), rect.width(), border);
      grays = ref.grays;
      // compute destination rectangle
      GRect rect2(0, 0, ref.columns(), ref.rows() );
      rect2.intersect(rect2, rect);
      rect2.translate(-rect.xmin, -rect.ymin);
      // copy bits
      if (! rect2.isempty())
        {
          for (int y=rect2.ymin; y<rect2.ymax; y++)
            {
              unsigned char *dst = (*this)[y];
              const unsigned char *src = ref[y+rect.ymin] + rect.xmin;
              for (int x=rect2.xmin; x<rect2.xmax; x++)
                dst[x] = src[x];
            }
        }
    }
}
Esempio n. 14
0
void
parse_color_zones(const char *s)
{
  bool fullpage = false;
  int zones = 0;
  g().colorzones.empty();
  g().colorpalette = ByteStream::create();
  // zones
  while (s[0] == '#')
    {
      char rgb[3];
      GRect rect;
      s = parse_color_name(s+1, rgb);
      if (s[0] == ':')
        {
          int c[4];
          for (int i=0; i<4; i++)
            {
              char *e = 0;
              c[i] = strtol(s+1, &e, 10);
              if (e <= s || (i>=2 && c[i]<0) || (i<3 && e[0]!=','))
                G_THROW("Invalid coordinates in FGbz chunk specification");
              s = e;
            }
          rect = GRect(c[0],c[1],c[2],c[3]);
        }
      if (rect.isempty())
        fullpage = true;
      g().colorpalette->writall(rgb, 3);
      g().colorzones.touch(zones);
      g().colorzones[zones] = rect;
      zones++;
    }
  if (s[0])
    G_THROW("Syntax error in FGbz chunk specification");
  // add extra black palette entry
  if (! fullpage)
    {
      char rgb[3] = {0,0,0};
      g().colorpalette->writall(rgb, 3);
    }
}
Esempio n. 15
0
		bool GRect::isInRect(const GRect &rc) const
		{
			if(isEmpty() || rc.isEmpty())
				return false;

			if(xMin > rc.xMin) return false;
			if(xMax < rc.xMax) return false;
			if(yMin > rc.yMin) return false;
			if(yMax < rc.yMax) return false;
			return true;
		}
Esempio n. 16
0
    virtual void fillRect(const GRect& rect, const GColor& color) {
        GPixel c = color.premulToPixel();
        if (0 == GPixel_GetA(c)) {
            return;
        }

        GIRect ir = fIBounds;
        if (ir.intersect(rect.round())) {
            srcover_rect(fDevice, ir, c);
        }
    }
Esempio n. 17
0
		void GRect::expandRect(const GRect &rc)
		{
			if(rc.isEmpty())
				return;

			if(isEmpty())
			{
				set(rc.xMin, rc.yMin, rc.xMax, rc.yMax);
			}
			else
				set(min(xMin, rc.xMin),min(yMin, rc.yMin), max(xMax, rc.xMax),max(yMax, rc.yMax));
		}
Esempio n. 18
0
GP<GBitmap>
JB2Image::get_bitmap(const GRect &rect, int subsample, int align, int dispy) const
{
  if (width==0 || height==0)
    G_THROW( ERR_MSG("JB2Image.cant_create") );
  int rxmin = rect.xmin * subsample;
  int rymin = rect.ymin * subsample;
  int swidth = rect.width();
  int sheight = rect.height();
  int border = ((swidth + align - 1) & ~(align - 1)) - swidth;
  GP<GBitmap> bm = GBitmap::create(sheight, swidth, border);
  bm->set_grays(1+subsample*subsample);
  for (int blitno = 0; blitno < get_blit_count(); blitno++)
    {
      const JB2Blit *pblit = get_blit(blitno);
      const JB2Shape  &pshape = get_shape(pblit->shapeno);
      if (pshape.bits)
        bm->blit(pshape.bits, pblit->left-rxmin, pblit->bottom-rymin+dispy, subsample);
    }
  return bm;
}
Esempio n. 19
0
void MyCanvas::fillRect(const GRect& rect, const GColor& color)
{
  if (rect.isEmpty()) 
  {
    printf("Error: FillRect input rect is empty\n");
    return;
  }

  GShader* shader = GShader::FromColor(color);
  shadeRect(rect, shader);
  delete shader;
}
Esempio n. 20
0
/*
 * Function: skyColoring
 * Usage: skyColoring(colors,gw);
 * --------------------------
 * Iterates over the graphics window and adds squares of the appropriate color from the sdAlgo grid.
 * Randomly adds stars if night is set to true.
 */
void skyColoring(Grid<int> & colors, GWindow gw){
    double xStep = (double)width/colors.numCols();
    double yStep = (double)height/colors.numRows();
    int starInfreq = 14;
    for(int j=0; j<colors.numRows(); j++){
        for(int i=0; i<colors.numCols(); i++){
            int color = colors[i][j]*RED+(dusk?DUSK_BASE:DAY_BASE);
            if(night){
                color = colors[i][j]*.5;
            }
            GRect *rect = new GRect(xStep*j, yStep*i, xStep, yStep);
            rect->setFilled(true);
            rect->setColor(color);
            gw.add(rect);
            if(night){
                if(rand()%starInfreq==1){
                    GRect *star = new GRect(xStep*j, yStep*i, xStep*STAR_WIDTH, yStep*STAR_WIDTH);
                    star->setFilled(true);
                    star->setColor(WHITE);
                    gw.add(star);
                }
            }
        }
        starInfreq++;
    }
}
Esempio n. 21
0
void 
GRectMapper::set_input(const GRect &rect)
{
  if (rect.isempty())
    G_THROW( ERR_MSG("GRect.empty_rect1") );
  rectFrom = rect;
  if (code & SWAPXY)
  {
    iswap(rectFrom.xmin, rectFrom.ymin);
    iswap(rectFrom.xmax, rectFrom.ymax);
  }
  rw = rh = GRatio();
}
void
MapArea::drawEditControls(const GRect & grect, QPainter * p_in)
      // grect is in the screen coord system
      // Correct painter modes WILL be set
{
   GRect brect=gmap_area->get_bound_rect();
   mapper->map(brect);
   brect.inflate(3, 3);
  
   GRect irect;
   if (irect.intersect(grect, brect))
   {
      QPainter * p=p_in;
      try
      {
	    // Prepare
	 if (!p_in) p=new QPainter(pane);
	 else p_in->save();
	 p->setRasterOp(XorROP);
	 p->setPen(QColor(0xff, 0xff, 0xff));
	 p->setClipRect(G2Q(irect));

	    // Draw
	 int xmin=brect.xmin+3, xmax=brect.xmax-3;
	 int ymin=brect.ymin+3, ymax=brect.ymax-3;
	 _drawFrame(*p, xmin-1, ymin-1, xmax+1, ymax+1, 10);
	 _drawFrame(*p, xmin-3, ymin-3, xmax+3, ymax+3, 12);      
	 ma_drawEditControls(p);

	    // Finish
	 if (!p_in) { delete p; p=0; }
	 else p_in->restore();
      } catch(...)
      {
	 if (!p_in) delete p;
	 throw;
      }
   }
}
Esempio n. 23
0
void GSlider::OnPaint(GSurface *pDC)
{
	pDC->Colour(LC_MED, 24);
	pDC->Rectangle();
	
	GRect r = GetClient();
	int y = r.Y() >> 1;
	r.y1 = y - 2;
	r.y2 = r.y1 + 3;
	r.x1 += 3;
	r.x2 -= 3;
	LgiWideBorder(pDC, r, DefaultSunkenEdge);
	
	if (Min <= Max)
	{
		int x = Val * r.X() / (Max-Min);
		Thumb.ZOff(5, 9);
		Thumb.Offset(r.x1 + x - 3, y - 5);
		GRect b = Thumb;
		LgiWideBorder(pDC, b, DefaultRaisedEdge);
		pDC->Rectangle(&b);		
	}
}
void
QDBase::eraseMapAreas(bool search_results_too, bool allow_draw)
{
   DEBUG_MSG("QDBase::eraseMapAreas(): Erasing the map areas\n");
   DEBUG_MAKE_INDENT(3);

   GRect grect;
   grect.intersect(rectDocument, rectVisible);
   
   for(GPosition pos=map_areas;pos;)
   {
      GP<MapArea> ma=map_areas[pos];
      if (search_results_too || ma->getComment()!=search_results_name)
      {
	 GPosition this_pos=pos;
	 ++pos;
	 map_areas.del(this_pos);
	 
	 if (!grect.isempty() && allow_draw) ma->repaint();
      } else ++pos;
   }
   cur_map_area=0;
   delete map_area_tip; map_area_tip=0;
}
void
MapArea::draw(const GRect & bm_rect, const GP<GBitmap> & bm_in,
	      GRect & pm_rect, GP<GPixmap> & pm_out,
	      DRAW_MODE draw_mode)
      // Draws itself into the specified bitmap. The bm_rect should be
      // in the pane's coordinates. Since GBitmap may not contain color
      // information, we will create a color GPixmap patch (pm_out), where we
      // will actually be drawing. The pm_rect is a rectangle in
      // pane coordinates where this pm_out should go to.
{
   DEBUG_MSG("MapArea::draw(): Highlighting " << gmap_area->url << ":" <<
	     gmap_area->target << "\n");
   DEBUG_MAKE_INDENT(3);

   if (pane)
   {
      GRect brect=gmap_area->get_bound_rect();
      mapper->map(brect);
      brect.inflate(3, 3);
      
      GRect irect;
      if (irect.intersect(bm_rect, brect))
      {
	 pm_rect=irect;
	 irect.translate(-bm_rect.xmin, -bm_rect.ymin);
	 pm_out=GPixmap::create(*bm_in, GRect(irect.xmin, bm_in->rows()-irect.ymax,
					  irect.width(), irect.height()));
	 if (!isInactiveOutlineMode())
	    if (draw_mode==DRAW_INACTIVE || draw_mode==DRAW_ACTIVE)
	       ma_drawInactive(pm_rect, pm_out);
	 if (!isActiveOutlineMode())
	    if (draw_mode==APPLY_ACTIVE || draw_mode==DRAW_ACTIVE)
	       ma_applyActive(pm_rect, pm_out);
      }
   }
}
/*
 * Registers that a click occurred, storing the location appropriately and
 * updating the graphics.  If the click was on an invalid location, returns
 * false.  If the click was at a valid location, returns true.
 */
static bool registerClick(Grid<double>& world, double x, double y,
                          WorldType worldType) {
    if (gWindow == NULL) {
        error("Window has not yet been initialized.");
    }
    if (gFirstSelected != NULL && gSecondSelected != NULL) {
        error("Two tiles have already been selected.");
    }

    // Determine where we clicked and make sure it's in-bounds.
    TBLoc loc = coordToLoc(x, y);
    if (!world.inBounds(loc.row, loc.col) ||
            (worldType == MAZE_WORLD && world[loc.row][loc.col] == kMazeWall)) {
        return false;
    }

    // Add the selection to the display.
    double selectionX, selectionY;
    locToCoord(loc, selectionX, selectionY);
    GRect* selection = new GRect(selectionX, selectionY, gPixelsPerWidth, gPixelsPerHeight);
    selection->setLineWidth(2.0);
    selection->setColor(kSelectedLocationColor);
    gWindow->add(selection);

    // Store the selection appropriately based on whether this is the first or
    // second click.
    if (gFirstSelected == NULL) {
        gFirstSelected = selection;
        gStartLocation = loc;
    } else {
        gSecondSelected = selection;
        gEndLocation = loc;
    }

    return true;
}
Esempio n. 27
0
void GPostscriptPort::DrawRect (const GRect &r)
{
    PostscriptStream << r.GetLeft() << " " << -r.GetTop() << " moveto" 	<< std::endl;
    PostscriptStream << r.GetWidth() << " 0 rlineto" 					<< std::endl;
    PostscriptStream << "0 " << -r.GetHeight() << " rlineto" 			<< std::endl;
    PostscriptStream << -r.GetWidth() << " 0 rlineto" 					<< std::endl;
    PostscriptStream << "0 " << r.GetHeight() << " rlineto"				<< std::endl;
    PostscriptStream << "closepath" 									<< std::endl;
    PostscriptStream << "stroke" 										<< std::endl;
    PostscriptStream << std::endl;
}
Esempio n. 28
0
void GContext4::drawRect(const GRect& rect, const GPaint& bucket){
    if((int)(bucket.getAlpha()*255 + .5) > 0){ //only do something if the alpha is greater than zero
        const GColor& color = bucket.getColor();
        if(helper.isLegalColor(color)){
            if(!rect.isEmpty()){
                float rTop=rect.fTop,rBottom=rect.fBottom,rLeft=rect.fLeft,rRight=rect.fRight;
                mapping.vectorMult(&rLeft, &rTop);
                mapping.vectorMult(&rRight, &rBottom);
                if(rLeft>rRight){
                    rLeft += rRight;
                    rRight = rLeft - rRight;
                    rLeft = rLeft - rRight;
                }
                if (rTop > rBottom){
                    rTop += rBottom;
                    rBottom = rTop - rBottom;
                    rTop = rTop - rBottom;
                }
                int left = helper.roundToInt(rLeft);
                int right = helper.roundToInt(rRight);
                int top = helper.roundToInt(rTop);
                int bottom = helper.roundToInt(rBottom);
                helper.findIntersection(&left, &right, &top, &bottom, Btmp.fHeight, Btmp.fWidth);
                uint32_t storedResult = 0x01;
                uint32_t storedDestination = 0x01;
                uint32_t DstColor;
                uint32_t rectColor = helper.packARGB(color);
                char* row = ((char*) Btmp.fPixels) + top*Btmp.fRowBytes;
                for(int j = top; j<bottom; j++){
                    for(int i=left ; i<right; i++){
                        DstColor = *((GPixel*) row + i);
                        if(storedDestination == DstColor){ //if we have the value already, don't do the math
                            *((GPixel*) row + i) = storedResult;
                        }
                        else{
                            storedDestination = DstColor;
                            storedResult = helper.blendColor(DstColor, rectColor);
                            *((GPixel*) row + i) = storedResult; //blends the two colors
                        }
                    }
                    row += Btmp.fRowBytes;
                }
            }
        }
    }
}
Esempio n. 29
0
GMatrix<float> RectToRect(const GRect& src, const GRect& dst)
{
  // Make translation matrix of the source from the origin
  GMatrix<float> SrcTranslate;
  SrcTranslate.setTranslation(-src.left(), -src.top());

  // Make scale matrix of dx, dy. Dst / Src
  GMatrix<float> Scale;
  Scale.setScale(dst.width() / src.width(), dst.height() / src.height());

  // Get translation matrix of the dst rectangle
  GMatrix<float> DstTranslate;
  DstTranslate.setTranslation(dst.left(), dst.top());

  // Concatenate the 3 matrices. DstTranslate * Scale * SrcTranslate
  DstTranslate.concat(Scale).concat(SrcTranslate);

  return DstTranslate;
}
Esempio n. 30
0
void MyCanvas::fillBitmapRect(const GBitmap& src, const GRect& dst)
{
  if (dst.isEmpty())
  {
    printf("Error: FillBitmapRect dst rect is empty\n");
    return;
  }

  /* Get the matrix of the conversion from src to dst rect
   * Use the rect to rect matrix to create bitmap shader */
  auto LocalMatrix = Utility::RectToRect(GRect::MakeWH(src.width(), src.height()), dst);
  float localArr[6];
  LocalMatrix.GetTwoRows(localArr);
  
  GShader* shader = GShader::FromBitmap(src, localArr);
  shadeRect(dst, shader);
  delete shader;
}