Beispiel #1
0
void Image::flipVertical()
{
    if(isCompressed(format_))
    {
        throw runtime_error("Cannot flip compressed image");
    }

    int stride = width_ * bitsPerPixel(format_) / 8;

    vector<uint8_t> rowBuf(stride);

    for(int y = 0; y < height_ / 2; y++)
    {
        memcpy(rowBuf.data(), data_.data() + y * stride, stride);
        memcpy(data_.data() + stride * y, data_.data() + (height_ - y - 1) * stride, stride);
        memcpy(data_.data() + (height_ - y - 1) * stride, rowBuf.data(), stride);
    }
}
Beispiel #2
0
void LpSub::constraint2row(
	ArrayBuffer<Constraint*> &cons,
	ArrayBuffer<Row*> &rows)
{
	int   conNnz;                      //!< number of nonzero elements in constraint
	Row   rowBuf(master_, sub_->nVar());  //!< dummy to generate row
	Row  *row;                         //!< pointer to the new row

	const int nCons = cons.size();

	for (int c = 0; c < nCons; c++) {
		conNnz = cons[c]->genRow(sub_->actVar(), rowBuf);
		row = new Row(master_, conNnz);
		row->copy(rowBuf);
		rows.push(row);
		rowBuf.clear();
	}
}