Пример #1
0
T_Pen::T_Pen(int* bufferHeight, int* bufferWidth)
{
	m_bufferHeight = bufferHeight;
	m_bufferWidth = bufferWidth;

	m_maxFloat = 1.0;
	m_brushBool = true;
	m_stampBool = false;
	m_kernelBool = false;
	m_luminanceBool= false;
	m_needTempCanvas = false;

	m_defaultWidth = 3;
	m_defaultHeight = 3;
	m_defaultMaskSize= 3;

	m_toolSize = 1.0;
	m_width = m_defaultWidth;
	m_height = m_defaultHeight;
	m_maskSize = m_defaultMaskSize;

	m_drawLineLimitFactor=0.0; // zero means no limitation

	setMaskBehavior(new M_FlatEllipseMask());
	makeMask();
}
Пример #2
0
BrushStamp makeGimpStyleBrushStamp(const Brush &brush, const Point &point)
{
	BrushStamp s;

	if(brush.subpixel()) {
		// optimization: don't bother with a high resolution mask for large brushes
		float radius = brush.fsize(point.pressure());

		if(radius < 8)
			s = makeHighresMask(brush, point.pressure());
		else
			s = makeMask(brush, point.pressure());

		const float fx = floor(point.x());
		const float fy = floor(point.y());
		s.left += fx;
		s.top += fy;

		float xfrac = point.x()-fx;
		float yfrac = point.y()-fy;

		if(xfrac<0.5) {
			xfrac += 0.5;
			s.left--;
		} else
			xfrac -= 0.5;

		if(yfrac<0.5) {
			yfrac += 0.5;
			s.top--;
		} else
			yfrac -= 0.5;

		s.mask = offsetMask(s.mask, xfrac, yfrac);

	} else {
		s = makeMask(brush, point.pressure());
		s.left += point.x();
		s.top += point.y();
	}

	return s;
}
Пример #3
0
// Apply a permutation network to a ciphertext
// FIXME: Do we need to also give an EncryptedArray object as paramter?
void PermNetwork::applyToCtxt(Ctxt& c) const
{
  const PAlgebra& al = c.getContext().zMStar;
  EncryptedArray ea(c.getContext());
  // Use G(X)=X for this ea object, this works since we only have 0/1 entries

  // Apply the layers, one at a time
  for (long i=0; i<layers.length(); i++) {
    const PermNetLayer& lyr = layers[i];
    if (lyr.isID) continue; // this layer is the identity permutation

    // This layer is shifted via powers of g^e mod m
    long g2e = PowerMod(al.ZmStarGen(lyr.genIdx), lyr.e, al.getM());

    Vec<long> unused = lyr.shifts; // copy to a new vector
    vector<long> mask(lyr.shifts.length());  // buffer to hold masks
    Ctxt sum(c.getPubKey(), c.getPtxtSpace()); // an empty ciphertext

    long shamt = 0;
    bool frst = true;
    while (true) {
      pair<long,bool> ret=makeMask(mask, unused, shamt); // compute mask
      if (ret.second) { // non-empty mask
	Ctxt tmp = c;
	ZZX maskPoly;
	ea.encode(maskPoly, mask);    // encode mask as polynomial
	tmp.multByConstant(maskPoly); // multiply by mask
	if (shamt!=0) // rotate if the shift amount is nonzero
	  tmp.smartAutomorph(PowerMod(g2e, shamt, al.getM()));
	if (frst) {
	  sum = tmp;
	  frst = false;
	}
	else
	  sum += tmp;
      }
      if (ret.first >= 0)
	shamt = unused[ret.first]; // next shift amount to use

      else break; // unused is all-zero, done with this layer
    }
    c = sum; // update the cipehrtext c before the next layer
  }
}
Пример #4
0
Файл: main.c Проект: caomw/grass
int main(int argc, char *argv[])
{
    char *name;
    d_Mask *maskRules;
    struct GModule *module;

    G_gisinit(argv[0]);

    module = G_define_module();
    G_add_keyword(_("raster3d"));
    G_add_keyword(_("mask"));
    G_add_keyword(_("voxel"));
    module->description =
	_("Establishes the current working 3D raster mask.");

    params.map = G_define_option();
    params.map->key = "map";
    params.map->type = TYPE_STRING;
    params.map->required = YES;
    params.map->multiple = NO;
    params.map->gisprompt = "old,grid3,3d-raster";
    params.map->description = _("3D raster map with reference values");

    params.maskVals = G_define_option();
    params.maskVals->key = "maskvalues";
    params.maskVals->key_desc = "val[-val]";
    params.maskVals->type = TYPE_STRING;
    params.maskVals->required = NO;
    params.maskVals->multiple = YES;
    params.maskVals->description = _("List of cell values to be masked out");

    if (G_parser(argc, argv))
	exit(EXIT_FAILURE);

    if (Rast3d_mask_file_exists())
	G_fatal_error(_("Cannot create mask file: RASTER3D_MASK already exists"));

    getParams(&name, &maskRules);

    makeMask(name, maskRules);

    exit(EXIT_SUCCESS);
}
Пример #5
0
LinearBrush::LinearBrush(BGRA color, int flow, int radius)
    : Brush(color, flow, radius)
{
    // @TODO: [BRUSH] You'll probably want to set up the mask right away.
    makeMask();
}
Пример #6
0
LinearBrush::LinearBrush() : Brush()
{
    // @TODO: [BRUSH] You'll probably want to set up the mask right away.
    makeMask();
}
Пример #7
0
int
main(int argc, char *argv[])
{
  int seedX=-1,seedY=-1; 
  char szWrap[MAXNAME], szUnwrap[MAXNAME];
  meta_parameters *meta;

  logflag=0;

  while (currArg < (argc-2)) {
    char *key = argv[currArg++];
    if (strmatch(key,"-log")) {
      CHECK_ARG(1);
      strcpy(logFile,GET_ARG(1));
      fLog = FOPEN(logFile, "a");
      logflag = 1;
    }
    else if (strmatch(key,"-x")) {
      CHECK_ARG(1);
      sscanf(GET_ARG(1), "%d", &seedX);
    }
    else if (strmatch(key,"-y")) {
      CHECK_ARG(1);
      sscanf(GET_ARG(1), "%d", &seedY);
    }
    else {
      printf("\n   ***Invalid option: %s\n", argv[currArg-1]);
      usage(argv[0]);
    }
  }
  create_name(szWrap, argv[currArg++], ".img");
  create_name(szUnwrap, argv[currArg], ".img");

  printf("%s\n",date_time_stamp());
  printf("Program: escher\n\n");
  if (logflag) {
    StartWatchLog(fLog);
    printLog("Program: escher\n\n");
  }

  meta = meta_read(szWrap);
  wid = meta->general->sample_count;
  len = meta->general->line_count;
  if ((seedX==-1)&&(seedY==-1))
  {
  	seedX=wid/2;
  	seedY=len/2;
  }
  
  meta_write(meta, szUnwrap);
  

  size = wid*len;
  mask  = (Uchar *)calloc(size, sizeof(Uchar));
  im    = (Uchar *)calloc(size, sizeof(Uchar));
  phase = (float *)MALLOC(sizeof(float)*size);
  /*coh   = (float *)MALLOC(sizeof(float)*size);*/

  /* perform steps*/
  printf("\n   begin unwrapping phase...\n");
  loadWrappedPhase(szWrap);
  groundBorder();
  makeMask();
  
  doStats("   after makeMask():");

  installCordon("cordon");
  cutMask();

  doStats("   after cutMask():");

#if DO_DEBUG_CHECKS
  saveMask((char *)mask, "test");

  verifyCuts();                                           
#endif

  checkSeed(&seedX, &seedY);

  integratePhase(seedX, seedY);

  doStats("   after integratePhase():");

  finishUwp();

  saveMask(mask, szUnwrap);

  saveUwp(szUnwrap);
  
  /* clean up & save*/
  free(mask);
  free(im);
  free(phase);
  return(0);
}