Esempio n. 1
0
/* Initialize the filter. */
static int
s_ISpecialDownScale_init(stream_state * st)
{
    stream_ISpecialDownScale_state *const ss = (stream_ISpecialDownScale_state *) st;
    gs_memory_t *mem = ss->memory;

    ss->sizeofPixelIn = ss->params.BitsPerComponentIn / 8;
    ss->sizeofPixelOut = ss->params.BitsPerComponentOut / 8;

    ss->src_size = 
        ss->params.WidthIn * ss->sizeofPixelIn * ss->params.spp_interp;
    ss->dst_size = 
        ss->params.WidthOut * ss->sizeofPixelOut * ss->params.spp_interp;

    /* Initialize destination DDAs. */
    ss->dst_x = 0;
    ss->src_offset = ss->dst_offset = 0;
    dda_init(ss->dda_x, 0, ss->params.WidthIn, ss->params.WidthOut);
    ss->dda_x_init = ss->dda_x;
    ss->src_y = ss->dst_y = 0;
    dda_init(ss->dda_y, 0, ss->params.HeightOut, ss->params.HeightIn);

    /* create intermediate image to hold horizontal zoom */
    ss->tmp = 
        gs_alloc_byte_array(mem, ss->params.WidthOut * ss->params.spp_interp,
                            ss->sizeofPixelIn, "image_scale tmp");
    /* Allocate buffers for 1 row of source and destination. */
    ss->dst = 
        gs_alloc_byte_array(mem, ss->params.WidthOut * ss->params.spp_interp,
                            ss->sizeofPixelOut, "image_scale dst");
    ss->src = 
        gs_alloc_byte_array(mem, ss->params.WidthIn * ss->params.spp_interp,
                            ss->sizeofPixelIn, "image_scale src");
    if (ss->tmp == 0 || ss->dst == 0 || ss->src == 0) {
        s_ISpecialDownScale_release(st);
        return ERRC;
/****** WRONG ******/
    }

    return 0;

}
Esempio n. 2
0
/// Startup code, run when we come out of reset
void init(void) {

	halInit();
  	chSysInit();

#if defined(PORT_LED1) && defined(PIN_LED1)
	palSetPadMode(PORT_LED1, PIN_LED1, PAL_MODE_OUTPUT_PUSHPULL);
#endif
#if defined(PORT_LED2) && defined(PIN_LED2)
	palSetPadMode(PORT_LED2, PIN_LED2, PAL_MODE_OUTPUT_PUSHPULL);
#endif

	// set up watchdog
	wd_init();

	// set up serial
	serial_init();

	// set up G-code parsing
	gcode_init();

	// set up inputs and outputs
	io_init();

	// set up timers
	timer_init();

	// read PID settings from EEPROM
	heater_init();

	// set up dda
	dda_init();

	// start up analog read interrupt loop,
	// if any of the temp sensors in your config.h use analog interface
	analog_init();

	// set up temperature inputs
	temp_init();

	// enable interrupts
	enable_irq();

	// reset watchdog
	wd_reset();

	// say hi to host
	serial_writestr_P(PSTR("start\nok\n"));

}
Esempio n. 3
0
/// Startup code, run when we come out of reset
void init(void) {
	// set up watchdog
	wd_init();

	// set up serial
	serial_init();

	// set up G-code parsing
	gcode_init();

	// set up inputs and outputs
	io_init();

	// set up timers
	timer_init();

	// read PID settings from EEPROM
	heater_init();

	// set up dda
	dda_init();

	// start up analog read interrupt loop,
	// if any of the temp sensors in your config.h use analog interface
	analog_init();

	// set up temperature inputs
	temp_init();

	// enable interrupts
	sei();

	// reset watchdog
	wd_reset();

  // prepare the power supply
  power_init();

	// say hi to host
	serial_writestr_P(PSTR("start\nok\n"));

}
Esempio n. 4
0
void BezierPath::const_iterator::flatten(BezierPath::vertices& v,
					 Coord flat) const
{
  unsigned int subdivisions;
  vector2d<BezierPath::Coord> d1, d2, d3;

  v.push_back(control_[0]);
  switch(type()) {
  case move:
    return;
  case line:
  case close:
    v.push_back(control_[1]);
    return;
  case parabolic:{
    BezierPath::Point p1,p2;
    p1.x() = (2*control_[1].x() + control_[0].x())/3.;
    p1.y() = (2*control_[1].y() + control_[0].y())/3.;

    p2.x() = (2*control_[1].x() + control_[2].x())/3.;
    p2.y() = (2*control_[1].y() + control_[2].y())/3.;

    subdivisions = compute_subdivisions(control_[0], p1,
					p2, control_[2],
					flat);
    dda_init(control_[0], p1, p2, control_[2],
	     subdivisions, d1, d2, d3);

    /*
    subdivisions = compute_subdivisions(control_[0], control_[1],
					control_[1], control_[2],
					flat);
    dda_init(control_[0], control_[1], control_[1], control_[2],
	     subdivisions, d1, d2, d3);
    */
  }
    break;
  case cubic:
    subdivisions = compute_subdivisions(control_[0], control_[1],
					control_[2], control_[3],
					flat);
    dda_init(control_[0], control_[1], control_[2], control_[3],
	     subdivisions, d1, d2, d3);
        break;
  default:
    assert(type() == line ||
	   type() == move ||
	   type() == parabolic ||
	   type() == cubic);
    return;
  }
  int size = 1 << subdivisions;
  v.reserve(v.size()+size);
  point2d<BezierPath::Coord> c(control_[0].x(), control_[0][y_dimension]);
  Point p;

  for (int i = 0; i < (size-1); i++) {
    c += d1;
    p.x() = Coord(c.x());
    p.y() = Coord(c.y());
    v.push_back(p);
#ifdef FLATTEN_COUNT
    ++flatten_count;
#endif
    d1 += d2;
    d2 += d3;
  }
  v.push_back(control_[count()-1]);
}