本文整理汇总了C++中row函数的典型用法代码示例。如果您正苦于以下问题:C++ row函数的具体用法?C++ row怎么用?C++ row使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了row函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: a
void quaterN::transition0(const quater& aa, const quater& bb, int duration)
{
quater a(aa);
quater b(bb);
quater qid;
qid.identity();
a.align(qid);
b.align(qid);
// kovar paper (prefer identity quaternion (more safe))
setSize(duration);
float totalTime=duration+1;
float currTime;
quater c, d, qi;
qi.identity();
for(int i=0; i<duration; i++)
{
currTime=(float)(i+1)/totalTime;
float t=-2.f*CUBIC(currTime)+3.f*SQR(currTime);
c.slerp(a, qi, t);
d.slerp(qi, b, t);
row(i).slerp(c, d, currTime);
}
}
开发者ID:VitorRetamal,项目名称:papercrop,代码行数:24,代码来源:quaterN.cpp
示例2: validate_regex
static void validate_regex( const music_details& desc, int bells )
{
static string allowed;
if ( allowed.empty() ) {
allowed.append( row(bells).print() );
allowed.append("*?[]");
}
string tok( desc.get() );
if ( tok.find_first_not_of( allowed ) != string::npos )
throw runtime_error( make_string() << "Illegal regular expression: "
<< tok );
bool inbrack(false);
for ( string::const_iterator i(tok.begin()), e(tok.end()); i!=e; ++i )
switch (*i) {
case '[':
if ( inbrack )
throw runtime_error( "Unexpected '[' in regular expressions" );
inbrack = true;
break;
case ']':
if ( !inbrack )
throw runtime_error( "Unexpected ']' in regular expressions" );
inbrack = false;
break;
case '*': case '?':
if ( inbrack )
throw runtime_error( "Cannot use '*' or '?' in a [] block "
"of a regular expression" );
break;
}
// TODO: Check for multiple occurances of the same bell
}
开发者ID:brucegentles,项目名称:ringinglib,代码行数:36,代码来源:expression.cpp
示例3: codec
void SubsetSingleBench::onDraw(int n, SkCanvas* canvas) {
// When the color type is kIndex8, we will need to store the color table. If it is
// used, it will be initialized by the codec.
int colorCount;
SkPMColor colors[256];
if (fUseCodec) {
for (int count = 0; count < n; count++) {
SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(fStream->duplicate()));
const SkImageInfo info = codec->getInfo().makeColorType(fColorType);
SkAutoTDeleteArray<uint8_t> row(new uint8_t[info.minRowBytes()]);
codec->startScanlineDecode(info, nullptr, colors, &colorCount);
SkBitmap bitmap;
SkImageInfo subsetInfo = info.makeWH(fSubsetWidth, fSubsetHeight);
alloc_pixels(&bitmap, subsetInfo, colors, colorCount);
codec->skipScanlines(fOffsetTop);
uint32_t bpp = info.bytesPerPixel();
for (uint32_t y = 0; y < fSubsetHeight; y++) {
codec->getScanlines(row.get(), 1, 0);
memcpy(bitmap.getAddr(0, y), row.get() + fOffsetLeft * bpp,
fSubsetWidth * bpp);
}
}
} else {
for (int count = 0; count < n; count++) {
SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(fStream));
int width, height;
decoder->buildTileIndex(fStream->duplicate(), &width, &height);
SkBitmap bitmap;
SkIRect rect = SkIRect::MakeXYWH(fOffsetLeft, fOffsetTop, fSubsetWidth,
fSubsetHeight);
decoder->decodeSubset(&bitmap, rect, fColorType);
}
}
}
开发者ID:picmonkey,项目名称:skia,代码行数:36,代码来源:SubsetSingleBench.cpp
示例4: itemAt
void EventView::mouseDoubleClickEvent(QMouseEvent *event)
{
QListWidgetItem *selectedItem = itemAt(event->pos());
if (selectedItem != NULL)
{
int selectedRow = row(selectedItem);
if (!item(selectedRow)->text().contains(QRegExp("^\\s*::")))
{
BaseEvent *eventToAdd = BaseEvent::browseEvents(currentEvent->getBaseType(), callerID, callerType);
if (eventToAdd != NULL)
{
int row = currentRow();
int eventsID = childEventIDAtRow(row);
int parentID = eventsParentIDAtRow(row);
int childTypeID = childEventTypeIDAtRow(row);
eventList[parentID]->addChildEvent(eventToAdd, eventsID, childTypeID);
updateView();
eventList.clear();
eventList = currentEvent->getEventPointers();
setCurrentRow(row);
}
}
}
}
开发者ID:timdetering,项目名称:openrpgmaker,代码行数:24,代码来源:eventview.cpp
示例5: row
void SolverFormulacaoPadrao::UpdateConsUpperBound(double upper) {
// constraint
ConstraintFormulacaoPadrao cons;
// variable
VariableFormulacaoPadrao var;
// creates the constraint
cons.reset();
cons.set_type(ConstraintFormulacaoPadrao::C_UPPER_BOUND);
ConstraintFormulacaoPadraoHash::iterator it = cHash_.find(cons);
if (it == cHash_.end()) {
cHash_[cons] = lp_->getNumRows();
int nnz = problem_data_->num_tasks();
OPT_ROW row(nnz, OPT_ROW::LESS, upper, (char*) cons.ToString().c_str());
// adds each variable
for (int i = 0; i < problem_data_->num_machines(); ++i) {
for (int j = 0; j < problem_data_->num_tasks(); ++j) {
var.reset();
var.set_type(VariableFormulacaoPadrao::X_ij);
var.set_machine(i);
var.set_task(j);
VariableFormulacaoPadraoHash::iterator vit = vHash_.find(var);
//CHECK_NE(vit, vHash_.end());
double cost = problem_data_->cost(i, j);
row.insert(vit->second, cost);
}
}
lp_->addRow(row);
} else {
lp_->chgRHS(it->second, upper);
}
}
开发者ID:danielamaral,项目名称:GAP,代码行数:36,代码来源:SolverFormulacaoPadrao.cpp
示例6: main
int main (int argc, char **argv){
int number;
int height;
int position = 2;
int space = 0;
int space2 =0;
int space3 = 0;
/*checking if there are arguments or if the argument is negative*/
if (argc == 1 || argv[1][0] == '-'){
return 0;
}
number = char_to_int(argv);
/*Iterating though the first part of the cross*/
for(height = 0; height < number/2; height ++){
space = spaces(space);
position = row(number, position);
space2 = spaces2(space2);
}
/*Printing an x in the middle if the number is odd*/
if (number % 2 != 0){
space = spaces(space);
write(1, "X", 1);
space2 = spaces2(space2);
space2 --;
}
space3 = space2;
/*This is done so that the spaces before the symbles start form the middle of the second part of the cross*/
space = number/2 - 1;
position -=1;
for(height = 0; height < number/2; height ++){
space = spaces(space) - 2;
position =row2(number, position);
space3 = spaces3(space3);
}
return 0;
}
开发者ID:stvngrcia,项目名称:holbertonschool-low_level_programming,代码行数:36,代码来源:main.c
示例7: test_math_matrix_mult_TCRRMV
void test_math_matrix_mult_TCRRMV(void)
{
T d1[M*N];
for(unsigned i=0; i<(M*N); ++i)
{
d1[i] = T(std::rand()%10000)/2;
}
T d2[N*K];
for(unsigned i=0; i<(N*K); ++i)
{
d2[i] = T(std::rand()%10000)/2;
}
auto m1 = eagine::math::matrix<T, N, M, RM1, V>::from(d1, M*N);
auto m2 = eagine::math::matrix<T, K, N, RM2, V>::from(d2, N*K);
eagine::math::matrix<T, K, M, RM1, V> m = multiply(m1, m2);
(void)m;
for(unsigned i=0; i<M; ++i)
for(unsigned j=0; j<K; ++j)
{
T e = T(0);
for(unsigned k=0; k<N; ++k)
{
e += row(m1, i)[k]*column(m2, j)[k];
}
BOOST_CHECK_EQUAL(get_cm(m, j, i), e);
BOOST_CHECK_EQUAL(get_rm(m, i, j), e);
}
}
开发者ID:deranen,项目名称:oglplu2,代码行数:36,代码来源:math_matrix_3_r.cpp
示例8: printline
void CUI_LoadMsg::draw(Drawable *S) {
int i;
char *str[] = { "Please wait, loading... |",
"Please wait, loading... /",
"Please wait, loading... -",
"Please wait, loading... \\"
};
if (S->lock()==0) {
S->fillRect(col(15),row(20),640-col(15)-1,row(25)-1,COLORS.Background);
printline(col(15),row(24),148,50,COLORS.Lowlight,S);
for (i=20;i<25;i++) {
printchar(col(15),row(i),145,COLORS.Highlight,S);
printchar(col(64),row(i),146,COLORS.Lowlight,S);
}
printline(col(15),row(20),143,50,COLORS.Highlight,S);
print(col(textcenter(str[strselect],40)),row(22),str[strselect],COLORS.Text,S);
S->unlock();
need_refresh = 0;
updated++;
}
}
开发者ID:cmicali,项目名称:ztracker,代码行数:23,代码来源:CUI_LoadMsg.cpp
示例9: CHECK_INVARIANT
PyObject *getEuclideanDistMat(python::object descripMat) {
// Bit of a pain involved here, we accept three types of PyObjects here
// 1. A Numeric Array
// - first find what 'type' of entry we have (float, double and int is all we recognize for now)
// - then point to contiguous piece of memory from the array that contains the data with a type*
// - then make a new type** pointer so that double index into this contiguous memory will work
// and then pass it along to the distance calculator
// 2. A list of Numeric Vector (or 1D arrays)
// - in this case wrap descripMat with a PySequenceHolder<type*> where type is the
// type of entry in vector (accepted types are int, double and float
// - Then pass the PySequenceHolder to the metrci calculator
// 3. A list (or tuple) of lists (or tuple)
// - In this case other than wrapping descripMat with a PySequenceHolder
// each of the indivual list in there are also wrapped by a PySequenceHolder
// - so the distance calculator is passed in a "PySequenceHolder<PySequenceHolder<double>>"
// - FIX: not that we always convert entry values to double here, even if we passed
// in a list of list of ints (or floats). Given that lists can be heterogeneous, I do not
// know how to ask a list what type of entries if contains.
//
// OK my brain is going to explode now
// first deal with situation where we have an Numeric Array
PyObject *descMatObj = descripMat.ptr();
PyArrayObject *distRes;
if (PyArray_Check(descMatObj)) {
// get the dimensions of the array
int nrows = ((PyArrayObject *)descMatObj)->dimensions[0];
int ncols = ((PyArrayObject *)descMatObj)->dimensions[1];
int i;
CHECK_INVARIANT((nrows > 0) && (ncols > 0), "");
npy_intp dMatLen = nrows*(nrows-1)/2;
// now that we have the dimensions declare the distance matrix which is always a
// 1D double array
distRes = (PyArrayObject *)PyArray_SimpleNew(1, &dMatLen, NPY_DOUBLE);
// grab a pointer to the data in the array so that we can directly put values in there
// and avoid copying :
double *dMat = (double *)distRes->data;
PyArrayObject *copy;
copy = (PyArrayObject *)PyArray_ContiguousFromObject(descMatObj,
((PyArrayObject *)descMatObj)->descr->type_num,
2,2);
// if we have double array
if (((PyArrayObject *)descMatObj)->descr->type_num == NPY_DOUBLE) {
double *desc = (double *)copy->data;
// REVIEW: create an adaptor object to hold a double * and support
// operator[]() so that we don't have to do this stuff:
// here is the 2D array trick this so that when the distance calaculator
// asks for desc2D[i] we basically get the ith row as double*
double **desc2D = new double*[nrows];
for (i = 0; i < nrows; i++) {
desc2D[i] = desc;
desc += ncols;
}
MetricMatrixCalc<double**, double*> mmCalc;
mmCalc.setMetricFunc(&EuclideanDistanceMetric<double *, double *>);
mmCalc.calcMetricMatrix(desc2D, nrows, ncols, dMat);
delete [] desc2D;
// we got the distance matrix we are happy so return
return PyArray_Return(distRes);
}
// if we have a float array
else if (((PyArrayObject *)descMatObj)->descr->type_num == NPY_FLOAT) {
float* desc = (float *)copy->data;
float **desc2D = new float*[nrows];
for (i = 0; i < nrows; i++) {
desc2D[i] = desc;
desc += ncols;
}
MetricMatrixCalc<float**, float*> mmCalc;
mmCalc.setMetricFunc(&EuclideanDistanceMetric<float *, float*>);
mmCalc.calcMetricMatrix(desc2D, nrows, ncols, dMat);
delete [] desc2D;
return PyArray_Return(distRes);
}
// if we have an interger array
else if (((PyArrayObject *)descMatObj)->descr->type_num == NPY_INT) {
int *desc = (int *)copy->data;
int **desc2D = new int*[nrows];
for (i = 0; i < nrows; i++) {
desc2D[i] = desc;
desc += ncols;
}
MetricMatrixCalc<int**, int*> mmCalc;
mmCalc.setMetricFunc(&EuclideanDistanceMetric<int *, int*>);
mmCalc.calcMetricMatrix(desc2D, nrows, ncols, dMat);
delete [] desc2D;
return PyArray_Return(distRes);
}
else {
// unreconiged type for the matrix, throw up
throw_value_error("The array has to be of type int, float, or double for GetEuclideanDistMat");
//.........这里部分代码省略.........
开发者ID:Jazzy2906,项目名称:rdkit,代码行数:101,代码来源:rdMetricMatrixCalc.cpp
示例10: art
void InfoShape::draw(const DrawBuf &buf) const
{
if( !pane ) return;
Smooth::DrawArt art(buf);
VColor text=enable?+cfg.text:+cfg.inactive;
Point space=+cfg.space;
// decor
{
MPane p(pane);
MCoord width=+cfg.width;
MCoord dx=Fraction(space.x)-width;
MCoord dy=Fraction(space.y)-width;
if( focus )
{
FigureBox fig(p.shrink(Fraction(space.x)/2,Fraction(space.y)/2));
fig.loop(art,width,+cfg.focus);
}
if( xoff>0 )
{
FigureLeftMark fig(p,dx);
fig.solid(art,text);
}
if( xoff<xoffMax )
{
FigureRightMark fig(p,dx);
fig.solid(art,text);
}
if( yoff>0 )
{
FigureUpMark fig(p,dy);
fig.solid(art,text);
}
if( yoff<yoffMax )
{
FigureDownMark fig(p,dy);
fig.solid(art,text);
}
}
// text
{
Pane inner=pane.shrink(space);
if( !inner ) return;
ulen count=info->getLineCount();
ulen index=yoff;
Font font=cfg.font.get();
FontSize fs=font->getSize();
DrawBuf tbuf=buf.cutRebase(inner);
Pane row(-xoff,0,IntAdd(xoff,inner.dx),fs.dy);
for(; index<count && row.y+row.dy<=inner.dy ;index++,row.y+=row.dy)
{
font->text(tbuf,row,TextPlace(AlignX_Left,AlignY_Top),info->getLine(index),text);
}
}
}
开发者ID:SergeyStrukov,项目名称:CCore-2-xx,代码行数:79,代码来源:ShapeLib.InfoShape.cpp
示例11: benchmark_spmv_ccsr
std::pair<double,double> benchmark_spmv_ccsr(
const vex::Context &ctx, vex::profiler<> &prof
)
{
// Construct matrix for 3D Poisson problem in cubic domain.
const uint n = 128;
const uint N = n * n * n;
const uint M = 1024;
double time_elapsed;
const real h2i = (n - 1) * (n - 1);
std::vector<size_t> idx;
std::vector<size_t> row(3);
std::vector<int> col(8);
std::vector<real> val(8);
std::vector<real> X(n * n * n, static_cast<real>(1e-2));
std::vector<real> Y(n * n * n, 0);
idx.reserve(n * n * n);
row[0] = 0;
row[1] = 1;
row[2] = 8;
col[0] = 0;
val[0] = 1;
col[1] = -static_cast<int>(n * n);
col[2] = -static_cast<int>(n);
col[3] = -1;
col[4] = 0;
col[5] = 1;
col[6] = n;
col[7] = (n * n);
val[1] = -h2i;
val[2] = -h2i;
val[3] = -h2i;
val[4] = h2i * 6;
val[5] = -h2i;
val[6] = -h2i;
val[7] = -h2i;
for(size_t k = 0; k < n; k++) {
for(size_t j = 0; j < n; j++) {
for(size_t i = 0; i < n; i++) {
if (
i == 0 || i == (n - 1) ||
j == 0 || j == (n - 1) ||
k == 0 || k == (n - 1)
)
{
idx.push_back(0);
} else {
idx.push_back(1);
}
}
}
}
size_t nnz = 6 * (n - 2) * (n - 2) * (n - 2) + n * n * n;
// Transfer data to compute devices.
vex::SpMatCCSR<real,int> A(ctx.queue(0), n * n * n, 2,
idx.data(), row.data(), col.data(), val.data());
std::vector<vex::command_queue> q1(1, ctx.queue(0));
vex::vector<real> x(q1, X);
vex::vector<real> y(q1, Y);
// Get timings.
y += A * x;
y = 0;
prof.tic_cpu("OpenCL");
for(size_t i = 0; i < M; i++)
y += A * x;
ctx.finish();
time_elapsed = prof.toc("OpenCL");
double gflops = (2.0 * nnz + N) * M / time_elapsed / 1e9;
double bwidth = M * (nnz * (2 * sizeof(real) + sizeof(int)) + 4 * N * sizeof(real)) / time_elapsed / 1e9;
std::cout
<< "SpMV (CCSR) (" << vex::type_name<real>() << ")\n"
<< " OpenCL"
<< "\n GFLOPS: " << gflops
<< "\n Bandwidth: " << bwidth
<< std::endl;
if (options.bm_cpu) {
prof.tic_cpu("C++");
for(size_t k = 0; k < M; k++)
for(size_t i = 0; i < N; i++) {
real s = 0;
for(size_t j = row[idx[i]]; j < row[idx[i] + 1]; j++)
s += val[j] * X[i + col[j]];
//.........这里部分代码省略.........
开发者ID:sd-omkar,项目名称:hpc_benchmarks,代码行数:101,代码来源:vector.cpp
示例12: row
Vector4T<T>& operator[](int i) { return row(i); }
开发者ID:enuuros,项目名称:multitude,代码行数:1,代码来源:Matrix4.hpp
示例13: name_col
OP_STATUS ExtensionsManagerListViewItem::ConstructItemWidget(QuickWidget** widget)
{
*widget = NULL;
// name_col
OpAutoPtr<QuickStackLayout> name_col(
OP_NEW(QuickStackLayout, (QuickStackLayout::VERTICAL)));
RETURN_OOM_IF_NULL(name_col.get());
name_col->SetPreferredWidth(WidgetSizes::Fill);
name_col->SetMinimumWidth(EXTENSION_NAME_MINIMUM_WIDTH);
m_extension_name = ConstructName();
RETURN_OOM_IF_NULL(m_extension_name);
RETURN_IF_ERROR(name_col->InsertWidget(m_extension_name));
m_author_version = ConstructAuthorAndVersion();
RETURN_OOM_IF_NULL(m_author_version);
RETURN_IF_ERROR(name_col->InsertWidget(m_author_version));
// name_and_buttons_row
OpAutoPtr<QuickStackLayout> name_and_buttons_row(
OP_NEW(QuickStackLayout, (QuickStackLayout::HORIZONTAL)));
RETURN_OOM_IF_NULL(name_and_buttons_row.get());
RETURN_IF_ERROR(name_and_buttons_row->InsertWidget(name_col.release()));
QuickStackLayout* control_buttons = ConstructControlButtons();
RETURN_OOM_IF_NULL(control_buttons);
RETURN_IF_ERROR(name_and_buttons_row->InsertWidget(control_buttons));
// main_col
OpAutoPtr<QuickStackLayout> main_col(
OP_NEW(QuickStackLayout, (QuickStackLayout::VERTICAL)));
RETURN_OOM_IF_NULL(main_col.get());
RETURN_IF_ERROR(main_col->InsertWidget(name_and_buttons_row.release()));
RETURN_IF_ERROR(main_col->InsertEmptyWidget(0, TEXT_SPACING, 0, TEXT_SPACING));
m_description = ConstructDescription();
RETURN_OOM_IF_NULL(m_description);
RETURN_IF_ERROR(main_col->InsertWidget(m_description));
QuickStackLayout* debug_buttons = ConstructDebugButtons();
if (debug_buttons)
{
RETURN_IF_ERROR(main_col->InsertWidget(debug_buttons));
}
// row_content
OpAutoPtr<QuickStackLayout> row_content(
OP_NEW(QuickStackLayout, (QuickStackLayout::HORIZONTAL)));
RETURN_OOM_IF_NULL(row_content.get());
RETURN_IF_ERROR(
row_content->InsertEmptyWidget(EXTENSION_ICON_PADDING, 0, EXTENSION_ICON_PADDING, 0));
m_icon = ConstructExtensionIcon();
RETURN_OOM_IF_NULL(m_icon);
RETURN_IF_ERROR(row_content->InsertWidget(m_icon));
RETURN_IF_ERROR(
row_content->InsertEmptyWidget(EXTENSION_ICON_PADDING, 0, EXTENSION_ICON_PADDING, 0));
RETURN_IF_ERROR(row_content->InsertWidget(main_col.release()));
if (debug_buttons)
{
RETURN_IF_ERROR(row_content->InsertEmptyWidget(2, 0, 2, 0));
}
// row
OpAutoPtr<QuickStackLayout> row(
OP_NEW(QuickStackLayout, (QuickStackLayout::VERTICAL)));
RETURN_OOM_IF_NULL(row.get());
RETURN_IF_ERROR(row->InsertEmptyWidget(0, ROW_ITEM_TOP_PADDING, 0,
ROW_ITEM_TOP_PADDING));
RETURN_IF_ERROR(row->InsertWidget(row_content.release()));
RETURN_IF_ERROR(row->InsertEmptyWidget(0, ROW_ITEM_BOTTOM_PADDING, 0,
ROW_ITEM_BOTTOM_PADDING));
QuickSkinElement *quick_skin_element =
QuickSkinWrap(row.release(), "Extensions Panel List Item Skin");
RETURN_OOM_IF_NULL(quick_skin_element);
quick_skin_element->GetOpWidget()->SetAlwaysHoverable(TRUE);
*widget = quick_skin_element;
UpdateControlButtonsState();
SetEnabled(!GetModelItem().IsDisabled());
return OpStatus::OK;
}
开发者ID:prestocore,项目名称:browser,代码行数:91,代码来源:ExtensionsManagerListView.cpp
示例14: c
const float4x4 float4x4::operator * (const float4x4& b) const
{
#if 1
// a textbook implementation...
float4x4 c;
const float4x4 &a = *this;
for (int i = 1; i <= 4; ++i)
{
for (int k = 1; k <= 4; ++k)
{
c(i, k) = a(i, 1) * b(1, k)
+ a(i, 2) * b(2, k)
+ a(i, 3) * b(3, k)
+ a(i, 4) * b(4, k);
}
}
return c;
#else
// assuredly slow, since row() does a lot of logic...
return make_matrix(dot(row(0), m.c1), dot(row(0), m.c2), dot(row(0), m.c3), dot(row(0), m.c4),
dot(row(1), m.c1), dot(row(1), m.c2), dot(row(1), m.c3), dot(row(1), m.c4),
dot(row(2), m.c1), dot(row(2), m.c2), dot(row(2), m.c3), dot(row(2), m.c4),
dot(row(3), m.c1), dot(row(3), m.c2), dot(row(3), m.c3), dot(row(3), m.c4));
#endif
}
开发者ID:Centril,项目名称:TDA361-Computer-Graphics,代码行数:27,代码来源:float4x4.cpp
示例15: SaveBitmapToFile
void SaveBitmapToFile( const char * fname, LVGrayDrawBuf * bmp )
{
if (!bmp)
return;
LVStreamRef stream = LVOpenFileStream(fname, LVOM_WRITE);
if (!stream)
return;
int rowsize = ((bmp->GetWidth()+1)/2);
int img_size = rowsize * bmp->GetHeight();
int padding = rowsize - rowsize;
BITMAPFILEHEADER fh;
struct {
BITMAPINFOHEADER hdr;
RGBQUAD colors[16];
} bmi;
memset(&fh, 0, sizeof(fh));
memset(&bmi, 0, sizeof(bmi));
fh.bfType = 0x4D42;
fh.bfSize = sizeof(fh) + sizeof(bmi) + img_size;
fh.bfOffBits = sizeof(fh) + sizeof(bmi);
bmi.hdr.biSize = sizeof(bmi.hdr);
bmi.hdr.biWidth = bmp->GetWidth();
bmi.hdr.biHeight = bmp->GetHeight();
bmi.hdr.biPlanes = 1;
bmi.hdr.biBitCount = 4;
bmi.hdr.biCompression = 0;
bmi.hdr.biSizeImage = img_size;
bmi.hdr.biXPelsPerMeter = 0xEC4;
bmi.hdr.biYPelsPerMeter = 0xEC4;
bmi.hdr.biClrUsed = 16;
bmi.hdr.biClrImportant = 16;
static lUInt8 gray[8] = { 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xAA, 0x55, 0x00 };
lUInt8 * pal = bmp->GetBitsPerPixel()==1?gray+0:gray+4;
for (int i=0; i<4; i++)
{
bmi.colors[i].rgbBlue = pal[i];
bmi.colors[i].rgbGreen = pal[i];
bmi.colors[i].rgbRed = pal[i];
}
stream->Write( &fh, sizeof(fh), NULL );
stream->Write( &bmi, sizeof(bmi), NULL );
static const lUInt8 dummy[3] = {0,0,0};
for (int y=0; y<bmp->GetHeight(); y++)
{
LVArray<lUInt8> row( (bmp->GetWidth()+1)/2, 0 );
for ( int x=0; x<bmp->GetWidth(); x++)
{
int cl = bmp->GetPixel(x, bmp->GetHeight()-1-y);
//int cl = (src[x/8] >> ((1-(x&3))*2)) & 3;
row[x/2] = row[x/2] | (cl << ((x&1)?0:4));
}
row[0] = 0x11;
row[1] = 0x11;
row[2] = 0x22;
row[3] = 0x22;
row[4] = 0x33;
row[5] = 0x33;
*stream << row;
if (padding)
stream->Write( dummy, padding, NULL );
}
}
开发者ID:thiensuhack,项目名称:TestCR,代码行数:62,代码来源:w32utils.cpp
示例16: row
void EffectRack::menuRequested(QListWidgetItem* it)/*{{{*/
{
if (it == 0 || track == 0)
return;
RackSlot* curitem = (RackSlot*) it;
Pipeline* epipe = track->efxPipe();
int idx = row(curitem);
QString name;
bool mute = false;
bool nativeGui = false;
Pipeline* pipe = track->efxPipe();
if (pipe)
{
name = pipe->name(idx);
mute = (pipe->isActive(idx) == false);
nativeGui = pipe->hasNativeGui(idx);
}
//enum { NEW, CHANGE, UP, DOWN, REMOVE, BYPASS, SHOW, SAVE };
enum
{
NEW, CHANGE, UP, DOWN, REMOVE, BYPASS, SHOW, SHOW_NATIVE, SAVE
};
QMenu* menu = new QMenu;
QAction* newAction = menu->addAction(tr("new"));
QAction* changeAction = menu->addAction(tr("change"));
QAction* upAction = menu->addAction(QIcon(*upIcon), tr("move up")); //, UP, UP);
QAction* downAction = menu->addAction(QIcon(*downIcon), tr("move down")); //, DOWN, DOWN);
QAction* removeAction = menu->addAction(tr("remove")); //, REMOVE, REMOVE);
QAction* bypassAction = menu->addAction(tr("bypass")); //, BYPASS, BYPASS);
QAction* showGuiAction = menu->addAction(tr("show gui")); //, SHOW, SHOW);
QAction* showNativeGuiAction = menu->addAction(tr("show native gui")); //, SHOW_NATIVE, SHOW_NATIVE);
QAction* saveAction = menu->addAction(tr("save preset"));
newAction->setData(NEW);
changeAction->setData(CHANGE);
upAction->setData(UP);
downAction->setData(DOWN);
removeAction->setData(REMOVE);
bypassAction->setData(BYPASS);
showGuiAction->setData(SHOW);
showNativeGuiAction->setData(SHOW_NATIVE);
saveAction->setData(SAVE);
bypassAction->setCheckable(true);
showGuiAction->setCheckable(true);
showNativeGuiAction->setCheckable(true);
bypassAction->setChecked(mute);
showGuiAction->setChecked(pipe->guiVisible(idx));
showNativeGuiAction->setEnabled(nativeGui);
if (nativeGui)
showNativeGuiAction->setChecked(pipe->nativeGuiVisible(idx));
if (pipe->empty(idx))
{
menu->removeAction(changeAction);
menu->removeAction(saveAction);
upAction->setEnabled(false);
downAction->setEnabled(false);
removeAction->setEnabled(false);
bypassAction->setEnabled(false);
showGuiAction->setEnabled(false);
showNativeGuiAction->setEnabled(false);
}
else
{
menu->removeAction(newAction);
if (idx == 0)
upAction->setEnabled(true);
if (idx == ((int)epipe->size() - 1))
downAction->setEnabled(false);
}
QPoint pt = QCursor::pos();
QAction* act = menu->exec(pt, 0);
//delete menu;
if (!act)
{
delete menu;
return;
}
int sel = act->data().toInt();
delete menu;
int pdepth = epipe->size();
switch (sel)
{
case NEW:
{
choosePlugin(it);
break;
}
case CHANGE:
{
//.........这里部分代码省略.........
开发者ID:bartart3d,项目名称:oom,代码行数:101,代码来源:EffectRack.cpp
示例17: fprintf
int
Image::write_png(char *file) const
{
if (_width == 0 || _height == 0 || _data == 0) {
fprintf(stderr,"Image::write_png: image has no data");
return 0;
} else if (_bpp < 1 || _bpp > 4) {
fprintf(stderr,"Image::write_png: unsupported number of bytes/pixel (%d)",
_bpp);
return 0;
}
FILE* fp;
if ((fp = fopen(file, "wb")) == 0) {
fprintf(stderr,"Image::write_png: can't open file %s", file);
return 0;
}
// Create and initialize the png_struct with the desired error handler
// functions. If you want to use the default stderr and longjump method,
// you can supply NULL for the last three parameters. We also check that
// the library version is compatible with the one used at compile time,
// in case we are using dynamically linked libraries. REQUIRED.
png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,0,0,0);
if (!png_ptr) {
fclose(fp);
fprintf(stderr,"Image::write_png: png_create_write_struct() failed");
return 0;
}
// Allocate/initialize the image information data. REQUIRED
png_infop info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr) {
fclose(fp);
png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
fprintf(stderr,"Image::write_png: png_create_info_struct() failed");
return 0;
}
// Set error handling
if (setjmp(png_ptr->jmpbuf)) {
// jump here from error encountered inside PNG code...
// free all memory associated with the png_ptr and info_ptr
fclose(fp);
png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
fprintf(stderr,"Image::write_png: error writing file %s", file);
return 0;
}
// Set up the input control (using standard C streams)
//
// see note re: C streams in read_png() above
//
png_init_io(png_ptr, fp);
// set the image information:
png_set_IHDR(png_ptr,
info_ptr,
_width,
_height,
8, // bit depth
((_bpp==4) ? PNG_COLOR_TYPE_RGB_ALPHA :
(_bpp==3) ? PNG_COLOR_TYPE_RGB :
(_bpp==2) ? PNG_COLOR_TYPE_GRAY_ALPHA :
PNG_COLOR_TYPE_GRAY),
PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_BASE,
PNG_FILTER_TYPE_BASE);
// set gamma
double gamma = getenv("JOT_GAMMA") ? atof(getenv("JOT_GAMMA")) : 0.45;
png_set_gAMA(png_ptr, info_ptr, gamma);
// write the file header information. REQUIRED
png_write_info(png_ptr, info_ptr);
// write the image data (inverted vertically):
for (int y=_height-1; y>=0; y--)
png_write_row(png_ptr, row(y));
// It is REQUIRED to call this to finish writing
png_write_end(png_ptr, info_ptr);
// clean up after the write, and free any memory allocated
png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
// close the file
fclose(fp);
return 1;
}
开发者ID:ccrma,项目名称:audicle,代码行数:92,代码来源:image.cpp
示例18: itemAt
void EffectRack::dropEvent(QDropEvent *event)/*{{{*/
{
event->accept();
QString text;
QListWidgetItem *i = itemAt(event->pos());
if (!i)
return;
int idx = row(i);
//qDebug("EffectRack::dropEvent: idx: %d", idx);
Pipeline* pipe = track->efxPipe();
if (pipe)
{
//int size = pipe->size();
/*if (idx < size)
{
QWidget *sw = event->source();
if (sw)
{
if (strcmp(sw->metaObject()->className(), "EffectRack") == 0)
{
EffectRack *ser = (EffectRack*) sw;
Pipeline* spipe = ser->getTrack()->efxPipe();
if (!spipe)
return;
QListWidgetItem *i = ser->itemAt(ser->getDragPos());
int idx0 = ser->row(i);
if (!(*spipe)[idx0] ||
(idx == idx0 && (ser == this || ser->getTrack()->name() == track->name())))
return;
}
}
if (QMessageBox::question(this, tr("Replace effect"), tr("Do you really want to replace the effect %1?").arg(pipe->name(idx)),
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) == QMessageBox::Yes)
{
audio->msgAddPlugin(track, idx, 0);
song->update(SC_RACK);
}
else
{
return;
}
}*/
if (event->mimeData()->hasFormat("text/x-oom-plugin"))
{
const QMimeData *md = event->mimeData();
QString outxml(md->data("text/x-oom-plugin"));
//qDebug("EffectRack::dropEvent Event data:\n%s", outxml.toUtf8().constData());
//Xml xml(event->mimeData()->data("text/x-oom-plugin").data());
QByteArray ba = outxml.toUtf8();
const char* data = ba.constData();
Xml xml(data);
initPlugin(xml, idx);
}
else if (event->mimeData()->hasUrls())
{
// Multiple urls not supported here. Grab the first one.
text = event->mimeData()->urls()[0].path();
if (text.endsWith(".pre", Qt::CaseInsensitive) ||
text.endsWith(".pre.gz", Qt::CaseInsensitive) ||
text.endsWith(".pre.bz2", Qt::CaseInsensitive))
{
//bool popenFlag = false;
bool popenFlag;
FILE* fp = fileOpen(this, text, ".pre", "r", popenFlag, false, false);
if (fp)
{
Xml xml(fp);
initPlugin(xml, idx);
if (popenFlag)
pclose(fp);
else
fclose(fp);
}
}
}
}
}/*}}}*/
开发者ID:bartart3d,项目名称:oom,代码行数:82,代码来源:EffectRack.cpp
示例19: switch
void NetPrefsServerView::MessageReceived(BMessage* msg)
{
switch (msg->what) {
case M_SERVER_ITEM_SELECTED: {
BRow* row(fServerList->CurrentSelection());
if (row) {
fEditButton->SetEnabled(true);
fRemoveButton->SetEnabled(true);
} else {
fEditButton->SetEnabled(false);
fRemoveButton->SetEnabled(false);
}
} break;
case M_SERVER_ADD_ITEM: {
BMessenger msgr(fEntryWin);
if (msgr.IsValid())
fEntryWin->Activate();
else {
fEntryWin = new ServerEntryWindow(this, new BMessage(M_SERVER_RECV_DATA), NULL, 0);
fEntryWin->Show();
}
} break;
case M_SERVER_EDIT_ITEM: {
BMessenger msgr(fEntryWin);
if (msgr.IsValid())
fEntryWin->Activate();
else {
BRow* row(fServerList->CurrentSelection());
if (!row) break;
int32 count(0);
ssize_t size(0);
type_code type;
fActiveNetwork->GetInfo("server", &type, &count);
const ServerData* compData;
for (int32 i = 0; i < count; i++) {
fActiveNetwork->FindData("server", B_RAW_TYPE, i,
reinterpret_cast<const void**>(&compData), &size);
if (!strcmp(compData->serverName, ((BStringField*)row->GetField(1))->String()))
break;
}
BMessage* invoke(new BMessage(M_SERVER_RECV_DATA));
invoke->AddBool("edit", true);
fEntryWin = new ServerEntryWindow(this, invoke, compData, size);
fEntryWin->Show();
}
} break;
case M_SERVER_REMOVE_ITEM: {
RemoveServer();
fNetWin.SendMessage(M_SERVER_DATA_CHANGED);
} break;
case M_SERVER_RECV_DATA: {
const ServerData* data;
ssize_t size;
Window()->DisableUpdates();
msg->FindData("server", B_RAW_TYPE, reinterpret_cast<const void**>(&data), &size);
if (msg->HasBool("edit")) RemoveServer();
UpdateNetworkData(data);
AddServer(data);
Window()->EnableUpdates();
fNetWin.SendMessage(M_SERVER_DATA_CHANGED);
} break;
default:
BView::MessageReceived(msg);
break;
}
}
开发者ID:carriercomm,项目名称:Vision,代码行数:71,代码来源:NetPrefsServerView.cpp
示例20: initialize_new_objects
void initialize_new_objects(mpi::communicator& world,
parameter_t const& P, directory_structure_t const& ds,
geometric_info_t const& gi, object_info_t& oi,
vector<std::vector<std::string> > const &seq, int tt,
vector<CImg<unsigned char> > const& images,
vector<matrix<float> > const& grd,
vector<matrix<float> >& detected_rects)
{
int Ncam = seq.size();
vector<object_trj_t> & trlet_list=oi.trlet_list;
int nobj = trlet_list.size();
int num_new_obj = detected_rects(0).size1();
int T = seq[0].size();
int np = oi.model.size();
int num_scales = P.scales.size();
//std::cout<<"detected_rects="<<detected_rects<<std::endl;
for(int oo=0; oo<num_new_obj; ++oo)
{
int nn = oi.curr_num_obj + oo;
trlet_list(nn).startt = tt;
trlet_list(nn).endt = tt;
trlet_list(nn).state = 1;
trlet_list(nn).trj = vector<matrix<float> >(Ncam);
for(int cam=0; cam<Ncam; ++cam)
{
trlet_list(nn).trj(cam) = scalar_matrix<float>(T, 4, 0);
}
trlet_list(nn).trj_3d = scalar_matrix<float>(T, 2, 0);
trlet_list(nn).hist_p = vector<matrix<float> >(Ncam);
trlet_list(nn).hist_q = vector<matrix<float> >(Ncam);
trlet_list(nn).fscores = vector<matrix<float> >(Ncam);
trlet_list(nn).scores = scalar_matrix<float>(Ncam, T, 0);
vector<candidate_array<Float> > cand_array(Ncam);
for(int cam=0; cam<Ncam; ++cam)
{
trlet_list(nn).fscores(cam) = scalar_matrix<float>(np*2, T, 0);
float w = detected_rects(cam)(oo, 2)-detected_rects(cam)(oo, 0);
float h = detected_rects(cam)(oo, 3)-detected_rects(cam)(oo, 1);
row(trlet_list(nn).trj(cam), tt) = row(detected_rects(cam), oo);
matrix<float> rects;
compute_part_rects(detected_rects(cam)(oo, 0), detected_rects(cam)(oo, 1),
w, h, oi.model, rects);
pmodel_t pmodel;
vector<float> br(row(detected_rects(cam), oo));
rects_to_pmodel_geom(br, gi.horiz_mean, pmodel);
oi.pmodel_list(cam, nn) = pmodel;
//collect_sift(grd(cam), );
matrix<float> hist_
|
请发表评论