• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ MID函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中MID函数的典型用法代码示例。如果您正苦于以下问题:C++ MID函数的具体用法?C++ MID怎么用?C++ MID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了MID函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: paCallback

//////////////////////
// PortAudio callback
int PortAudioPlayer::paCallback(void *inputBuffer, void *outputBuffer, unsigned long framesPerBuffer, PaTimestamp outTime, void *userData) {
	// Get provider
	PortAudioPlayer *player = (PortAudioPlayer *) userData;
	AudioProvider *provider = player->GetProvider();
	int end = 0;

	// Calculate how much left
	__int64 lenAvailable = player->endPos - player->playPos;
	uint64_t avail = 0;
	if (lenAvailable > 0) {
		avail = lenAvailable;
		if (avail > framesPerBuffer) {
			lenAvailable = framesPerBuffer;
			avail = lenAvailable;
		}
	}
	else {
		lenAvailable = 0;
		avail = 0;
	}

	// Play something
	if (lenAvailable > 0) {
		provider->GetAudio(outputBuffer,player->playPos,lenAvailable);
	}

	// Pad end with blank
	if (avail < (uint64_t) framesPerBuffer) {
		//provider->softStop = true;
	}

	// Set volume
	short *output = (short*) outputBuffer;
	for (unsigned int i=0;i<avail;i++) output[i] = MID(-(1<<15),int(output[i] * player->GetVolume()),(1<<15)-1);

	// Fill rest with blank
	for (unsigned int i=avail;i<framesPerBuffer;i++) output[i]=0;

	// Set play position (and real one)
	player->playPos += framesPerBuffer;
	player->realPlayPos = (__int64)(Pa_StreamTime(player->stream) - player->paStart) + player->startPos;

	// Cap to start if lower
	return end;
}
开发者ID:BackupTheBerlios,项目名称:aegisub-svn,代码行数:47,代码来源:audio_player_portaudio.cpp


示例2: getMaxScrollX

void Tabs::setScrollX(int scroll_x)
{
  int max_x = getMaxScrollX();

  scroll_x = MID(0, scroll_x, max_x);
  if (m_scrollX != scroll_x) {
    m_scrollX = scroll_x;
    calculateHot();
    invalidate();
  }

  // We need scroll buttons?
  if (max_x > 0) {
    // Add childs
    if (!HAS_ARROWS(this)) {
      addChild(m_button_left);
      addChild(m_button_right);
      invalidate();
    }

    /* disable/enable buttons */
    m_button_left->setEnabled(m_scrollX > 0);
    m_button_right->setEnabled(m_scrollX < max_x);

    /* setup the position of each button */
    {
      JRect rect = jwidget_get_rect(this);
      JRect box = jrect_new(rect->x2-ARROW_W*2, rect->y1,
                            rect->x2-ARROW_W, rect->y2-2);
      jwidget_set_rect(m_button_left, box);

      jrect_moveto(box, box->x1+ARROW_W, box->y1);
      jwidget_set_rect(m_button_right, box);

      jrect_free(box);
      jrect_free(rect);
    }
  }
  // Remove buttons
  else if (HAS_ARROWS(this)) {
    removeChild(m_button_left);
    removeChild(m_button_right);
    invalidate();
  }
}
开发者ID:optigon,项目名称:aseprite,代码行数:45,代码来源:tabs.cpp


示例3: Update

void Update(int u, int l, int r, int change)
{
    if(f[u].label == change) return ;
    if(l == f[u].l && r == f[u].r) {
        f[u].label = change;
        return ;
    }
    if(f[u].label) {
        put_down(u);
    }
    int mid = MID(f[u].l, f[u].r);
    if(r <= mid) Update(L(u), l, r, change);
    else if(mid < l) Update(R(u), l, r, change);
    else {
        Update(L(u), l, mid, change);
        Update(R(u), mid+1, r, change);
    }
}
开发者ID:keroro520,项目名称:ACM,代码行数:18,代码来源:A.cpp


示例4: Query

int Query(Tnode* T,int u,int l,int r)
{
    int delta = T[u].delta;
    if(T[u].l == l && T[u].r == r)
        return T[u].sum + delta*(r-l);
    T[L(u)].delta += delta;
    T[R(u)].delta += delta;
    T[u].sum += delta*(T[u].r-T[u].l);
    T[u].delta = 0;
    int mid = MID(T[u].l,T[u].r);
    if(l >= mid)
        return Query(T,R(u),l,r);
    else
        if(r <= mid)
            return Query(T,L(u),l,r);
        else
            return Query(T,L(u),l,mid) + Query(T,R(u),mid,r);
}
开发者ID:cxlove,项目名称:ACM_ICPC,代码行数:18,代码来源:hdoj_4267.cpp


示例5: window

void PasteTextCommand::onExecute(Context* ctx)
{
    Editor* editor = current_editor;
    if (editor == NULL)
        return;

    Preferences& pref = Preferences::instance();
    PasteTextWindow window(pref.textTool.fontFace(),
                           pref.textTool.fontSize(),
                           pref.colorBar.fgColor());

    window.userText()->setText(last_text_used);

    window.openWindowInForeground();
    if (window.getKiller() != window.ok())
        return;

    last_text_used = window.userText()->getText();

    std::string faceName = window.faceValue();
    int size = window.sizeValue();
    size = MID(1, size, 999);
    pref.textTool.fontFace(faceName);
    pref.textTool.fontSize(size);

    try {
        std::string text = window.userText()->getText();
        app::Color appColor = window.fontColor()->getColor();
        doc::color_t color = doc::rgba(appColor.getRed(),
                                       appColor.getGreen(),
                                       appColor.getBlue(),
                                       appColor.getAlpha());

        doc::ImageRef image(render_text(faceName, size, text, color));
        if (image) {
            editor->pasteImage(image.get());
        }
    }
    catch (const std::exception& ex) {
        ui::Alert::show(PACKAGE
                        "<<%s"
                        "||&OK", ex.what());
    }
}
开发者ID:ripesunflower,项目名称:aseprite,代码行数:44,代码来源:cmd_paste_text.cpp


示例6: Object

Sprite::Sprite(PixelFormat format, int width, int height, int ncolors)
  : Object(ObjectType::Sprite)
  , m_document(NULL)
  , m_format(format)
  , m_width(width)
  , m_height(height)
  , m_frames(1)
  , m_frameTags(this)
{
  ASSERT(width > 0 && height > 0);

  m_frlens.push_back(100);      // First frame with 100 msecs of duration
  m_folder = new LayerFolder(this);

  // Generate palette
  switch (format) {
    case IMAGE_GRAYSCALE: ncolors = 256; break;
    case IMAGE_BITMAP: ncolors = 2; break;
  }

  Palette pal(frame_t(0), ncolors);

  switch (format) {

    // For black and white images
    case IMAGE_GRAYSCALE:
    case IMAGE_BITMAP:
      for (int c=0; c<ncolors; c++) {
        int g = 255 * c / (ncolors-1);
        g = MID(0, g, 255);
        pal.setEntry(c, rgba(g, g, g, 255));
      }
      break;
  }

  // Initial RGB map
  m_rgbMap = NULL;

  // The transparent color for indexed images is 0 by default
  m_transparentColor = 0;

  setPalette(&pal, true);
}
开发者ID:airways,项目名称:aseprite,代码行数:43,代码来源:sprite.cpp


示例7: clearBlock

void flash25spi::clearSector(unsigned int addr) {
    if (_sectorSize == 0) {
        clearBlock(addr);
        return;
    }
        
    addr &= ~(_sectorSize-1);
 
    enableWrite();
    _enable->write(0);
    wait_us(1);
    _spi->write(0x20);
    _spi->write(HIGH(addr));
    _spi->write(MID(addr));
    _spi->write(LOW(addr));
    wait_us(1);
    _enable->write(1);
    waitForWrite();
}
开发者ID:HeydayGuan,项目名称:Nucleo_RemoteUpdate,代码行数:19,代码来源:flash25spi.cpp


示例8: _xwin_mousedrv_init

/* _xwin_mousedrv_init:
 *  Initializes the mickey-mode driver.
 */
static int _xwin_mousedrv_init(void)
{
   int num_buttons;
   unsigned char map[8];

   num_buttons = _xwin_get_pointer_mapping(map, sizeof(map));
   num_buttons = MID(2, num_buttons, 3);

   last_xspeed = -1;
   last_yspeed = -1;

   XLOCK();

   _xwin_mouse_interrupt = _xwin_mousedrv_handler;

   XUNLOCK();

   return num_buttons;
}
开发者ID:dodamn,项目名称:pkg-allegro4.2,代码行数:22,代码来源:xmouse.c


示例9: Object

Sprite::Sprite(PixelFormat format, int width, int height, int ncolors)
  : Object(OBJECT_SPRITE)
  , m_format(format)
  , m_width(width)
  , m_height(height)
  , m_frames(1)
{
  ASSERT(width > 0 && height > 0);

  m_frlens.push_back(100);      // First frame with 100 msecs of duration
  m_stock = new Stock(format);
  m_folder = new LayerFolder(this);

  // Generate palette
  Palette pal(FrameNumber(0), ncolors);

  switch (format) {

    // For colored images
    case IMAGE_RGB:
    case IMAGE_INDEXED:
      pal.resize(ncolors);
      break;

    // For black and white images
    case IMAGE_GRAYSCALE:
    case IMAGE_BITMAP:
      for (int c=0; c<ncolors; c++) {
        int g = 255 * c / (ncolors-1);
        g = MID(0, g, 255);
        pal.setEntry(c, rgba(g, g, g, 255));
      }
      break;
  }

  // Initial RGB map
  m_rgbMap = NULL;

  // The transparent color for indexed images is 0 by default
  m_transparentColor = 0;

  setPalette(&pal, true);
}
开发者ID:felipeita,项目名称:aseprite,代码行数:43,代码来源:sprite.cpp


示例10: sample_dither_filter

/* Dithering with noise shaping filter. Set shape = 0 for no shaping. */
static void sample_dither_filter(float *src, long size, float shape) {
	float r1 = 0, r2 = 0;
	float s1 = 0, s2 = 0; /* Feedback buffer */
	float o = 0.5f / 255;
	float tmp;
	int i;

	for (i = 0; i < size; i++) {
		r2 = r1;
		r1 = rand() / (float)RAND_MAX;

		tmp = src[i] + shape * (s1 + s1 - s2);
		src[i] = tmp + o * (r1 - r2);
		src[i] = MID(-1.0f, src[i], 1.0f);

		s2 = s1;
		s1 = tmp - src[i];
	}
	return;
}
开发者ID:AkumaKing,项目名称:Xeu,代码行数:21,代码来源:sample.c


示例11: layer_render

void layer_render(const Layer* layer, Image* image, int x, int y, FrameNumber frame)
{
  if (!layer->isVisible())
    return;

  switch (layer->type()) {

    case ObjectType::LayerImage: {
      const Cel* cel = static_cast<const LayerImage*>(layer)->getCel(frame);
      Image* src_image;

      if (cel) {
        ASSERT((cel->imageIndex() >= 0) &&
               (cel->imageIndex() < layer->sprite()->stock()->size()));

        src_image = cel->image();
        ASSERT(src_image != NULL);

        ASSERT(src_image->maskColor() == layer->sprite()->transparentColor());

        composite_image(image, src_image,
          cel->x() + x,
          cel->y() + y,
          MID(0, cel->opacity(), 255),
          static_cast<const LayerImage*>(layer)->getBlendMode());
      }
      break;
    }

    case ObjectType::LayerFolder: {
      LayerConstIterator it = static_cast<const LayerFolder*>(layer)->getLayerBegin();
      LayerConstIterator end = static_cast<const LayerFolder*>(layer)->getLayerEnd();

      for (; it != end; ++it)
        layer_render(*it, image, x, y, frame);

      break;
    }

  }
}
开发者ID:jjconti,项目名称:aseprite,代码行数:41,代码来源:layer.cpp


示例12: layer_render

void layer_render(const Layer* layer, Image* image, int x, int y, FrameNumber frame)
{
  if (!layer->isReadable())
    return;

  switch (layer->getType()) {

    case GFXOBJ_LAYER_IMAGE: {
      const Cel* cel = static_cast<const LayerImage*>(layer)->getCel(frame);
      Image* src_image;

      if (cel) {
        ASSERT((cel->getImage() >= 0) &&
               (cel->getImage() < layer->getSprite()->getStock()->size()));

        src_image = layer->getSprite()->getStock()->getImage(cel->getImage());
        ASSERT(src_image != NULL);

        src_image->mask_color = layer->getSprite()->getTransparentColor();

        image_merge(image, src_image,
                    cel->getX() + x,
                    cel->getY() + y,
                    MID (0, cel->getOpacity(), 255),
                    static_cast<const LayerImage*>(layer)->getBlendMode());
      }
      break;
    }

    case GFXOBJ_LAYER_FOLDER: {
      LayerConstIterator it = static_cast<const LayerFolder*>(layer)->getLayerBegin();
      LayerConstIterator end = static_cast<const LayerFolder*>(layer)->getLayerEnd();

      for (; it != end; ++it)
        layer_render(*it, image, x, y, frame);

      break;
    }

  }
}
开发者ID:bradparks,项目名称:aseprite,代码行数:41,代码来源:layer.cpp


示例13: delayed_free

static void
delayed_free(void *uptr, const char* file, int line)
{
    void *mptr;
    void *olduptr = free_delay[free_delay_pos];
    size_t nbytes;
    if ( uptr==NULL )
        return;
    mptr = user2malloc_(uptr);
    memory_check(uptr, MID(mptr), MFILE(mptr), MLINE(mptr), file, line);
    if ( olduptr!=NULL ) {
        actual_free(olduptr, file, line);
    }
    free_delay[free_delay_pos] = uptr;
    free_delay_pos++;
    free_delay_pos = free_delay_pos % MAX_FREE_DELAY_COUNT;
    nbytes = -user_nsize1_(uptr);
#ifdef FREED_CHAR
    (void)memset(uptr, FREED_CHAR, (size_t)nbytes);
#endif
}
开发者ID:4T-Shirt,项目名称:OpenJDK-Research,代码行数:21,代码来源:debug_malloc.c


示例14: debug_malloc_verify

void
debug_malloc_verify(const char *file, int line)
{
    void           *mptr;

#ifdef MAX_FREE_DELAY_COUNT
    delayed_free_all(file,line);
#endif

    if (!malloc_watch) {
        return;
    }
    mptr = first_warrant_mptr;
    if (mptr != NULL) {
        /* Check all this memory first */
        do {
            memory_check(malloc2user_(mptr), MID(mptr), MFILE(mptr), MLINE(mptr), file, line);
            mptr = warrant_link_(mptr);
        } while (mptr != NULL);
    }
}
开发者ID:4T-Shirt,项目名称:OpenJDK-Research,代码行数:21,代码来源:debug_malloc.c


示例15: Updata

void Updata(Tnode* T,int u,int l,int r,int up)
{
    if(T[u].l == l && T[u].r == r)
    {
        T[u].delta += up;
        return ;
    }
    else
        T[u].sum += up*(r-l);
    int mid = MID(T[u].l,T[u].r);
    if(l >= mid)
        Updata(T,R(u),l,r,up);
    else
        if(r <= mid)
            Updata(T,L(u),l,r,up);
        else
        {
            Updata(T,L(u),l,mid,up);
            Updata(T,R(u),mid,r,up);
        }
}
开发者ID:cxlove,项目名称:ACM_ICPC,代码行数:21,代码来源:hdoj_4267.cpp


示例16: traffic_load

int
traffic_load(struct request *rq)
{
    int		bytes, bw;
    int		gload = 0, iload = 0 ;
    struct group 	*group = NULL;
    ip_hash_entry_t	*he = NULL;

    if ( !rq ) return(0);
    if ( TEST(rq->flags, RQ_HAS_BANDWIDTH) ) group = rq_to_group(rq);
    if ( group && (bw = group->bandwidth) ) {
        bytes = MID(bytes);
        gload = (bytes*100)/bw;
    }
    if ( TEST(rq->flags, RQ_HAVE_PER_IP_BW) ) he = rq->ip_hash_ptr;
    if ( he && (bw = rq->per_ip_bw) ) {
        bytes = MID_IP(he);
        iload = (bytes*100)/bw;
    }
    return(MAX(gload,iload));
}
开发者ID:stiletto,项目名称:oops,代码行数:21,代码来源:statistics.c


示例17: actual_free

static void
actual_free(void *uptr, const char *file, int line)
{
    void *mptr;
    const char *mfile;
    int mline;
    int mid;
    if ( uptr == NULL )
        return;
    mptr = user2malloc_(uptr);
    memory_check(uptr, (mid=MID(mptr)), (mfile=MFILE(mptr)), (mline=MLINE(mptr)), file, line);
    if (malloc_watch && remove_warrant(mptr)==0 )
        memory_check(uptr, mid, mfile, mline, file, line);
#ifdef FREED_CHAR
    if ( mptr!=NULL ) {
        size_t nbytes = -nsize1_(mptr);
        /* LINTED */
        (void)memset(mptr, FREED_CHAR, rbytes_(nbytes));
    }
#endif
    free(mptr);
}
开发者ID:4T-Shirt,项目名称:OpenJDK-Research,代码行数:22,代码来源:debug_malloc.c


示例18: MID

int Entry::getCaretFromMouse(MouseMessage* mousemsg)
{
  base::utf8_const_iterator utf8_begin = base::utf8_const_iterator(getText().begin());
  base::utf8_const_iterator utf8_end = base::utf8_const_iterator(getText().end());
  int c, x, w, mx, caret = m_caret;
  int textlen = base::utf8_length(getText());

  mx = mousemsg->position().x;
  mx = MID(getBounds().x+this->border_width.l,
           mx,
           getBounds().x2()-this->border_width.r-1);

  x = getBounds().x + this->border_width.l;

  base::utf8_const_iterator utf8_it =
    (m_scroll < textlen ?
      utf8_begin + m_scroll:
      utf8_end);

  for (c=m_scroll; utf8_it != utf8_end; ++c, ++utf8_it) {
    w = getFont()->charWidth(*utf8_it);
    if (x+w >= getBounds().x2()-this->border_width.r)
      break;
    if ((mx >= x) && (mx < x+w)) {
      caret = c;
      break;
    }
    x += w;
  }

  if (utf8_it == utf8_end) {
    if ((mx >= x) &&
        (mx <= getBounds().x2()-this->border_width.r-1)) {
      caret = c;
    }
  }

  return caret;
}
开发者ID:bonacciahum,项目名称:aseprite,代码行数:39,代码来源:entry.cpp


示例19: enableWrite

bool flash25spi::writePage(unsigned int startAdr, unsigned int len, const char* data) {
    enableWrite();
 
    _enable->write(0);
    wait_us(1);
 
    _spi->write(0x02);
    _spi->write(HIGH(startAdr));
    _spi->write(MID(startAdr));
    _spi->write(LOW(startAdr));
 
    // do real write
    for (unsigned int i=0;i<len;i++) {
        _spi->write(data[i]);
    }
    wait_us(1);
    // disable to start physical write
    _enable->write(1);
    
    waitForWrite();
 
    return true;
}
开发者ID:HeydayGuan,项目名称:Nucleo_RemoteUpdate,代码行数:23,代码来源:flash25spi.cpp


示例20: Kickertest_Add

void Kickertest_Add( signed short val) {
	dbgu_GoToCursor( PARAM_COL, Kickertest_Row);
	switch( Kickertest_Row) {
	case BALL_X_ROW:
		Kickertest_element[KICKERTEST_BALL].x += val;
		dbgu_printf("%4d ", Kickertest_element[KICKERTEST_BALL].x);
		break;
	case BALL_Y_ROW:
		Kickertest_element[KICKERTEST_BALL].y += val;
		dbgu_printf("%4d ", Kickertest_element[KICKERTEST_BALL].y);
		break;
	case BALL_Z_ROW:
		Kickertest_element[KICKERTEST_BALL].z += val;
		dbgu_printf("%4d ", Kickertest_element[KICKERTEST_BALL].z);
		break;
	case TARGET_X_ROW:
		Kickertest_element[KICKERTEST_TARGET].x += val;
		dbgu_printf("%4d ", Kickertest_element[KICKERTEST_TARGET].x);
		break;
	case TARGET_Y_ROW:
		Kickertest_element[KICKERTEST_TARGET].y += val;
		dbgu_printf("%4d ", Kickertest_element[KICKERTEST_TARGET].y);
		break;
	case TARGET_Z_ROW:
		Kickertest_element[KICKERTEST_TARGET].z += val;
		dbgu_printf("%4d ", Kickertest_element[KICKERTEST_TARGET].z);
		break;
	case KICKTYPE_ROW:
		kickertest_type = MID(KICKER_TYPE_MINIMAL, kickertest_type + val, KICKER_TYPE_MAXIMAL);
		Kickertest_PrintKicktype();
		break;
	case FADE_ENABLE_ROW:
		kicker_fadeEnable = !kicker_fadeEnable;
		dbgu_printf("%d ", kicker_fadeEnable);
		break;
	}
}
开发者ID:rsmrafael,项目名称:DarwinWalking-Repository,代码行数:37,代码来源:kickertest.c



注:本文中的MID函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ MIDL_user_free函数代码示例发布时间:2022-05-30
下一篇:
C++ MHz函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap