本文整理汇总了C++中shrink函数的典型用法代码示例。如果您正苦于以下问题:C++ shrink函数的具体用法?C++ shrink怎么用?C++ shrink使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了shrink函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: render_scene
/* Function: render_scene
Scene should be assembled here. TODO: rework
Parameters:
counter - pointer to snapshot's point counter
*/
void render_scene(float y, float p, Snapshot *snap, uint32_t *counter)
{
uint32_t i;
uint32_t cnt = *counter;
clear_zbuffer();
clear_img(CLEAR_COLOR);
yaw = y;
pitch = p;
compute_yp();
/* render here */
render_cloud(&cloud,0,0,0,1);
/* end */
for (i=0; i<WIDTH*HEIGHT; i++) {
if (img[i] != CLEAR_COLOR) {
snap->x[cnt] = shrink(Xbuf[i], shrink_val);
snap->y[cnt] = shrink(Ybuf[i], shrink_val);
snap->z[cnt] = shrink(Zbuf[i], shrink_val);
snap->nx[cnt] = NXbuf[i];
snap->ny[cnt] = NYbuf[i];
snap->nz[cnt] = NZbuf[i];
snap->sh[cnt] = SHbuf[i];
snap->c[cnt] = true2high(img[i]);
cnt++; }
}
*counter = cnt;
}
示例2: GrResizeGrayMap
void GrResizeGrayMap(unsigned char *map,int pitch,int ow,int oh,int nw,int nh)
{
if(ow != nw) {
unsigned char *ptr = map;
int cnt = oh;
if((unsigned int)ow > (unsigned int)nw) do {
shrink(ptr,1,ow,nw);
ptr += pitch;
} while(--cnt > 0);
else do {
grow(ptr,1,ow,nw);
ptr += pitch;
} while(--cnt > 0);
}
if(oh != nh) {
int cnt = nw;
if((unsigned int)oh > (unsigned int)nh) do {
shrink(map,pitch,oh,nh);
map++;
} while(--cnt > 0);
else do {
grow(map,pitch,oh,nh);
map++;
} while(--cnt > 0);
}
}
示例3: im_shrink
/**
* im_shrink:
* @in: input image
* @out: output image
* @xshrink: horizontal shrink
* @yshrink: vertical shrink
*
* Shrink @in by a pair of factors with a simple box filter.
*
* You will get aliasing for non-integer shrinks. In this case, shrink with
* this function to the nearest integer size above the target shrink, then
* downsample to the exact size with im_affinei() and your choice of
* interpolator.
*
* im_rightshift_size() is faster for factors which are integer powers of two.
*
* See also: im_rightshift_size(), im_affinei().
*
* Returns: 0 on success, -1 on error
*/
int
im_shrink( IMAGE *in, IMAGE *out, double xshrink, double yshrink )
{
if( im_check_noncomplex( "im_shrink", in ) ||
im_check_coding_known( "im_shrink", in ) ||
im_piocheck( in, out ) )
return( -1 );
if( xshrink < 1.0 || yshrink < 1.0 ) {
im_error( "im_shrink",
"%s", _( "shrink factors should be >= 1" ) );
return( -1 );
}
if( xshrink == 1 && yshrink == 1 ) {
return( im_copy( in, out ) );
}
else if( in->Coding == IM_CODING_LABQ ) {
IMAGE *t[2];
if( im_open_local_array( out, t, 2, "im_shrink:1", "p" ) ||
im_LabQ2LabS( in, t[0] ) ||
shrink( t[0], t[1], xshrink, yshrink ) ||
im_LabS2LabQ( t[1], out ) )
return( -1 );
}
else if( shrink( in, out, xshrink, yshrink ) )
return( -1 );
return( 0 );
}
示例4: addWords
/* Takes an open file and adds all words from the file to words. */
int addWords(FILE* f, char** words) {
int p, q;
long long int num_words = 0;
char buffer[BUFFERSIZE+1];
int concat = 0;
int size, len;
unsigned long long int threshold = 4 * STARTTHRESHOLD;
int threshold_hit = 0;
while (!feof(f)) {
#ifdef SHRINK
if (num_words > threshold) { /* Whenever we've got more than THRESHOLD words */
/* fprintf(stderr, " *********************** Mini Shrinking, Threshold: %llu ***********************\n\n", threshold); */
num_words = shrink(words, num_words); /* Eliminate duplicates */
threshold_hit++;
if (threshold_hit > 2) {
threshold *= 2;
threshold_hit = 0;
}
}
#endif
if (fgets(buffer, BUFFERSIZE, f) != NULL) {
size = strlen(buffer)+1;
/* printf("%s\n", buffer); */
/* Insert each word into words */
p = q = 0;
while (p < size-1) {
while (q < size && isalnum(buffer[q++]));
/* printf("q: %d\n", q); */
if (q < size) { /* A non-alfanumeric char was found before end of buffer. */
buffer[q-1] = '\0'; /* Signal that the word ends at q */
}
if (!concat) {
len = insert(words, &num_words, buffer, p);
/* printf("Adicionada: %s\n", words[num_words-1]); */
}
else {
strcat(words[num_words-1], buffer+p);
/* printf("Concatenada: %s\n", words[num_words-1]); */
concat = 0;
}
if (q >= size && !len) { /* This means that '\0' was at the end off buffer, possible split word */
concat = 1;
p = q;
}
else {
while (q < size && !isalnum(buffer[q++]));
p = q-1;
q--;
}
}
}
}
#ifdef SHRINK
num_words = shrink(words, num_words); /* Eliminate duplicates */
#endif
return num_words;
}
示例5: stretch_order
tex::spec_t::spec_t(box_base_t *p)
{
stretch_order(this) = stretch_order(p);
shrink_order(this) = shrink_order(p);
glue_ref_count(this) = 0;
glue_width(this) = glue_width(p);
stretch(this) = stretch(p);
shrink(this) = shrink(p);
}
示例6: print_scaled
void tex::print_spec(ptr p, str s)
{
print_scaled(glue_width(p));
print(s);
if (stretch(p) != 0) {
print(" plus ");
print_glue(stretch(p), stretch_order(p), s);
}
if (shrink(p) != 0) {
print(" minus ");
print_glue(shrink(p), shrink_order(p), s);
}
}
示例7: SLOT
void burnDialog::on_FlashLoadButton_clicked()
{
QString fileName;
ui->BurnFlashButton->setDisabled(true);
ui->FWFileName->clear();
ui->DateField->clear();
ui->versionField->clear();
ui->ModField->clear();
ui->FramFWInfo->hide();
ui->SplashFrame->hide();
ui->BurnFlashButton->setDisabled(true);
ui->EEbackupCB->hide();
QTimer::singleShot(0, this, SLOT(shrink()));
if (hexType==FLASH_FILE_TYPE) {
fileName = QFileDialog::getOpenFileName(this, tr("Open Firmware File"), g.flashDir(), FLASH_FILES_FILTER);
if(fileName.isEmpty())
return;
checkFw(fileName);
}
else {
QString fileName = QFileDialog::getOpenFileName(this,tr("Choose Radio Backup file"), g.eepromDir(), tr(EXTERNAL_EEPROM_FILES_FILTER));
if (checkeEprom(fileName)) {
if (burnraw==false) {
ui->BurnFlashButton->setEnabled(true);
ui->profile_label->show();
ui->patchcalib_CB->show();
ui->patchhw_CB->show();
if (!IS_TARANIS(GetEepromInterface()->getBoard())) {
ui->EEpromCB->show();
}
else {
ui->EEpromCB->setChecked(false);
}
}
else {
ui->BurnFlashButton->setEnabled(true);
ui->profile_label->hide();
ui->patchcalib_CB->setChecked(false);
ui->patchhw_CB->setChecked(false);
ui->patchhw_CB->hide();
ui->patchcalib_CB->hide();
}
QTimer::singleShot(0, this, SLOT(shrink()));
}
}
updateUI();
}
示例8: lock
void Heap::destroy()
{
JSLock lock(SilenceAssertionsOnly);
if (!m_globalData)
return;
ASSERT(!m_globalData->dynamicGlobalObject);
ASSERT(m_operationInProgress == NoOperation);
// The global object is not GC protected at this point, so sweeping may delete it
// (and thus the global data) before other objects that may use the global data.
RefPtr<JSGlobalData> protect(m_globalData);
#if ENABLE(JIT)
m_globalData->jitStubs->clearHostFunctionStubs();
#endif
delete m_markListSet;
m_markListSet = 0;
clearMarks();
m_handleHeap.finalizeWeakHandles();
m_globalData->smallStrings.finalizeSmallStrings();
#if !ENABLE(JSC_ZOMBIES)
shrink();
ASSERT(!size());
#endif
m_globalData = 0;
}
示例9: sample
static inline float
sample(T scorefn, float x0, float w, common::rng_t &rng, unsigned m=10000, unsigned ntries=100)
{
const float y = logf(distributions::sample_unif01(rng)) + scorefn(x0);
const auto p = interval(scorefn, x0, y, w, rng, m);
return shrink(scorefn, x0, y, p.first, p.second, rng, ntries);
}
示例10: Q3MainWindow
Main::Main(QGraphicsScene& c, QWidget* parent, const char* name, Qt::WindowFlags f) :
Q3MainWindow(parent,name,f),
canvas(c)
{
editor = new FigureEditor(canvas,this);
QMenuBar* menu = menuBar();
Q3PopupMenu* file = new Q3PopupMenu( menu );
file->insertItem("&Fill canvas", this, SLOT(init()), Qt::CTRL+Qt::Key_F);
file->insertItem("&Erase canvas", this, SLOT(clear()), Qt::CTRL+Qt::Key_E);
file->insertItem("&New view", this, SLOT(newView()), Qt::CTRL+Qt::Key_N);
file->insertSeparator();
file->insertItem("&Print...", this, SLOT(print()), Qt::CTRL+Qt::Key_P);
file->insertSeparator();
file->insertItem("E&xit", qApp, SLOT(quit()), Qt::CTRL+Qt::Key_Q);
menu->insertItem("&File", file);
Q3PopupMenu* edit = new Q3PopupMenu( menu );
edit->insertItem("Add &Circle", this, SLOT(addCircle()), Qt::ALT+Qt::Key_C);
edit->insertItem("Add &Hexagon", this, SLOT(addHexagon()), Qt::ALT+Qt::Key_H);
edit->insertItem("Add &Polygon", this, SLOT(addPolygon()), Qt::ALT+Qt::Key_P);
edit->insertItem("Add Spl&ine", this, SLOT(addSpline()), Qt::ALT+Qt::Key_I);
edit->insertItem("Add &Text", this, SLOT(addText()), Qt::ALT+Qt::Key_T);
edit->insertItem("Add &Line", this, SLOT(addLine()), Qt::ALT+Qt::Key_L);
edit->insertItem("Add &Rectangle", this, SLOT(addRectangle()), Qt::ALT+Qt::Key_R);
edit->insertItem("Add &Sprite", this, SLOT(addSprite()), Qt::ALT+Qt::Key_S);
edit->insertItem("Create &Mesh", this, SLOT(addMesh()), Qt::ALT+Qt::Key_M );
edit->insertItem("Add &Alpha-blended image", this, SLOT(addButterfly()), Qt::ALT+Qt::Key_A);
menu->insertItem("&Edit", edit);
Q3PopupMenu* view = new Q3PopupMenu( menu );
view->insertItem("&Enlarge", this, SLOT(enlarge()), Qt::SHIFT+Qt::CTRL+Qt::Key_Plus);
view->insertItem("Shr&ink", this, SLOT(shrink()), Qt::SHIFT+Qt::CTRL+Qt::Key_Minus);
view->insertSeparator();
view->insertItem("&Rotate clockwise", this, SLOT(rotateClockwise()), Qt::CTRL+Qt::Key_PageDown);
view->insertItem("Rotate &counterclockwise", this, SLOT(rotateCounterClockwise()), Qt::CTRL+Qt::Key_PageUp);
view->insertItem("&Zoom in", this, SLOT(zoomIn()), Qt::CTRL+Qt::Key_Plus);
view->insertItem("Zoom &out", this, SLOT(zoomOut()), Qt::CTRL+Qt::Key_Minus);
view->insertItem("Translate left", this, SLOT(moveL()), Qt::CTRL+Qt::Key_Left);
view->insertItem("Translate right", this, SLOT(moveR()), Qt::CTRL+Qt::Key_Right);
view->insertItem("Translate up", this, SLOT(moveU()), Qt::CTRL+Qt::Key_Up);
view->insertItem("Translate down", this, SLOT(moveD()), Qt::CTRL+Qt::Key_Down);
view->insertItem("&Mirror", this, SLOT(mirror()), Qt::CTRL+Qt::Key_Home);
menu->insertItem("&View", view);
menu->insertSeparator();
Q3PopupMenu* help = new Q3PopupMenu( menu );
help->insertItem("&About", this, SLOT(help()), Qt::Key_F1);
help->setItemChecked(dbf_id, TRUE);
menu->insertItem("&Help",help);
statusBar();
setCentralWidget(editor);
printer = 0;
init();
}
示例11: step
void step()
{
ulen ind=random.select(Len);
if( ind<rec_len )
{
check(rec[ind]);
switch( random.select(3) )
{
case 0 :
{
free(ind);
}
break;
case 1 :
{
extend(rec[ind]);
}
break;
case 2 :
{
shrink(rec[ind]);
}
break;
}
}
else
{
alloc(random.select(0,MaxAllocLen));
}
}
示例12: erase
/* returns 0 if the function was successful, or -1 if there was an error */
int erase(vector* list, int first, int last) {
if ((first < 0) || (last <= 0)) {
#ifdef VECTOR_DEBUG
fprintf(stderr, "Error: index can't be negative.\n");
#endif
return -1;
}
if (first >= last) {
#ifdef VECTOR_DEBUG
fprintf(stderr, "Error: first index is higher than or equal to last index.\n");
#endif
return -1;
}
if ((first > list->elements) || (last > list->elements)) {
#ifdef VECTOR_DEBUG
fprintf(stderr, "Error: one of the arguments is too large.\n");
#endif
return -1;
}
int remove_length = last - first;
int new_size = list->elements - (last - first); // remove(0, 5) should remove 0..4, so 5 elements total
for (int i = first; i < new_size; i++) {
list->data[i] = list->data[i+remove_length];
}
if (new_size < (list->array_size) / 4) {
shrink(list);
}
list->elements = new_size;
return 0;
}
示例13: pop
static void pop(const gulong p)
{
--qnum;
if(qnum == 0) {
qstart = 0;
qend = -1;
} else if(p == qstart)
qstart = (qstart + 1) % qsz;
else {
gulong pi;
if((p >= qstart && p < qstart + qnum / 2) || (p < qstart && p < (qstart + qnum / 2) % qsz)) {
pi = p;
while(pi != qstart) {
const gulong pi_next = (pi == 0 ? qsz - 1 : pi - 1);
q[pi] = q[pi_next];
pi = pi_next;
}
qstart = (qstart + 1) % qsz;
} else {
pi = p;
while(pi != qend) {
const gulong pi_next = (pi + 1) % qsz;
q[pi] = q[pi_next];
pi = pi_next;
}
qend = (qend == 0 ? qsz - 1 : qend - 1);
}
}
shrink();
}
示例14: ymempool_shrink
int
ymempool_shrink(struct ymempool *mp, int margin) {
lock(mp);
shrink(mp, margin);
unlock(mp);
return 0;
}
示例15: shrink
int SrsConsumer::get_packets(int max_count, SrsSharedPtrMessage**& pmsgs, int& count)
{
int ret = ERROR_SUCCESS;
if (msgs.empty()) {
return ret;
}
if (paused) {
if ((int)msgs.size() >= PAUSED_SHRINK_SIZE) {
shrink();
}
return ret;
}
if (max_count == 0) {
count = (int)msgs.size();
} else {
count = srs_min(max_count, (int)msgs.size());
}
pmsgs = new SrsSharedPtrMessage*[count];
for (int i = 0; i < count; i++) {
pmsgs[i] = msgs[i];
}
if (count == (int)msgs.size()) {
msgs.clear();
} else {
msgs.erase(msgs.begin(), msgs.begin() + count);
}
return ret;
}