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

C++ scale_surface函数代码示例

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

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



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

示例1: image_fg

void mouse_action::set_terrain_mouse_overlay(editor_display& disp, const t_translation::t_terrain & fg,
		const t_translation::t_terrain & bg)
{
	surface image_fg(image::get_image(disp.get_map().get_terrain_info(fg).editor_image()));
	surface image_bg(image::get_image(disp.get_map().get_terrain_info(bg).editor_image()));

	if (image_fg == nullptr || image_bg == nullptr) {
		ERR_ED << "Missing terrain icon" << std::endl;
		disp.set_mouseover_hex_overlay(nullptr);
		return;
	}

	// Create a transparent surface of the right size.
	surface image = create_neutral_surface(image_fg->w, image_fg->h);

	// For efficiency the size of the tile is cached.
	// We assume all tiles are of the same size.
	// The zoom factor can change, so it's not cached.
	// NOTE: when zooming and not moving the mouse, there are glitches.
	// Since the optimal alpha factor is unknown, it has to be calculated
	// on the fly, and caching the surfaces makes no sense yet.
	static const fixed_t alpha = 196;
	static const int size = image_fg->w;
	static const int half_size = size / 2;
	static const int quarter_size = size / 4;
	static const int offset = 2;
	static const int new_size = half_size - 2;

	// Blit left side
	image_fg = scale_surface(image_fg, new_size, new_size);
	SDL_Rect rcDestLeft = sdl::create_rect(offset, quarter_size, 0, 0);
	blit_surface ( image_fg, nullptr, image, &rcDestLeft );

	// Blit right side
	image_bg = scale_surface(image_bg, new_size, new_size);
	SDL_Rect rcDestRight = sdl::create_rect(half_size, quarter_size, 0, 0);
	blit_surface ( image_bg, nullptr, image, &rcDestRight );

	//apply mask so the overlay is contained within the mouseover hex
	image = mask_surface(image, image::get_hexmask());

	// Add the alpha factor
	image = adjust_surface_alpha(image, alpha);

	// scale the image
	const int zoom = disp.hex_size();
	if (zoom != game_config::tile_size) {
		image = scale_surface(image, zoom, zoom);
	}

	// Set as mouseover
	disp.set_mouseover_hex_overlay(image);
}
开发者ID:CliffsDover,项目名称:wesnoth,代码行数:53,代码来源:mouse_action.cpp


示例2: image_fg

void mouse_action::set_terrain_mouse_overlay(editor_display& disp, t_translation::t_terrain fg,
		t_translation::t_terrain bg)
{
	surface image_fg(image::get_image("terrain/"
		+ disp.get_map().get_terrain_info(fg).editor_image() + ".png"));
	surface image_bg(image::get_image("terrain/"
		+ disp.get_map().get_terrain_info(bg).editor_image() + ".png"));

	if (image_fg == NULL || image_bg == NULL) {
		ERR_ED << "Missing terrain icon\n";
		disp.set_mouseover_hex_overlay(NULL);
		return;
	}

	// Create a transparent surface of the right size.
	surface image = create_compatible_surface(image_fg, image_fg->w, image_fg->h);
	SDL_FillRect(image,NULL,SDL_MapRGBA(image->format,0,0,0, 0));

	// For efficiency the size of the tile is cached.
	// We assume all tiles are of the same size.
	// The zoom factor can change, so it's not cached.
	// NOTE: when zooming and not moving the mouse, there are glitches.
	// Since the optimal alpha factor is unknown, it has to be calculated
	// on the fly, and caching the surfaces makes no sense yet.
	static const Uint8 alpha = 196;
	static const int size = image_fg->w;
	static const int half_size = size / 2;
	static const int quarter_size = size / 4;
	static const int offset = 2;
	static const int new_size = half_size - 2;
	const int zoom = static_cast<int>(size * disp.get_zoom_factor());

	// Blit left side
	image_fg = scale_surface(image_fg, new_size, new_size);
	SDL_Rect rcDestLeft = { offset, quarter_size, 0, 0 };
	SDL_BlitSurface ( image_fg, NULL, image, &rcDestLeft );

	// Blit left side
	image_bg = scale_surface(image_bg, new_size, new_size);
	SDL_Rect rcDestRight = { half_size, quarter_size, 0, 0 };
	SDL_BlitSurface ( image_bg, NULL, image, &rcDestRight );

	//apply mask so the overlay is contained within the mouseover hex
	surface mask(image::get_image("terrain/alphamask.png"));
	image = mask_surface(image, mask);

	// Add the alpha factor and scale the image
	image = scale_surface(adjust_surface_alpha(image, alpha), zoom, zoom);

	// Set as mouseover
	disp.set_mouseover_hex_overlay(image);
}
开发者ID:Yossarian,项目名称:WesnothAddonServer,代码行数:52,代码来源:mouse_action.cpp


示例3: map

void terrain_palette::draw_item(const t_translation::t_terrain& terrain,
		surface& image, std::stringstream& tooltip_text) {

	const t_translation::t_terrain base_terrain =
			map().get_terrain_info(terrain).default_base();

	//Draw default base for overlay terrains
	if(base_terrain != t_translation::NONE_TERRAIN) {
		const std::string base_filename = map().get_terrain_info(base_terrain).editor_image();
		surface base_image(image::get_image(base_filename));

		if(base_image == nullptr) {
			tooltip_text << "BASE IMAGE NOT FOUND\n";
			ERR_ED << "image for terrain : '" << base_filename << "' not found" << std::endl;
			base_image = image::get_image(game_config::images::missing);
			if (base_image == nullptr) {
				ERR_ED << "Placeholder image not found" << std::endl;
				return;
			}
		}

		if(base_image->w != item_size_ || base_image->h != item_size_) {
			base_image.assign(scale_surface(base_image,
					item_size_, item_size_));
		}
	}

	const std::string filename = map().get_terrain_info(terrain).editor_image();
	image = image::get_image(filename);
	if(image == nullptr) {
		tooltip_text << "IMAGE NOT FOUND\n";
		ERR_ED << "image for terrain: '" << filename << "' not found" << std::endl;
		image = image::get_image(game_config::images::missing);
		if (image == nullptr) {
			ERR_ED << "Placeholder image not found" << std::endl;
			return;
		}
	}

	if(image->w != item_size_ || image->h != item_size_) {
		image.assign(scale_surface(image,
				item_size_, item_size_));
	}

	tooltip_text << map().get_terrain_editor_string(terrain);
	if (gui_.get_draw_terrain_codes()) {
		tooltip_text << " " + utils::unicode_em_dash + " " << terrain;
	}
}
开发者ID:shikadilord,项目名称:wesnoth,代码行数:49,代码来源:terrain_palettes.cpp


示例4: scale_surface

floating_image::render_input floating_image::get_render_input(double xscale, double yscale, SDL_Rect& dst_rect) const
{
	render_input ri = {
		{0,0,0,0},
		file_.empty() ? nullptr : image::get_image(file_)
	};

	if(!ri.image.null()) {
		if(autoscaled_) {
			ri.image = scale_surface(
				ri.image,
				static_cast<int>(ri.image->w * xscale),
				static_cast<int>(ri.image->h * yscale)
			);
		}

		ri.rect.x = static_cast<int>(x_*xscale) + dst_rect.x;
		ri.rect.y = static_cast<int>(y_*yscale) + dst_rect.y;
		ri.rect.w = ri.image->w;
		ri.rect.h = ri.image->h;

		if(centered_) {
			ri.rect.x -= ri.rect.w / 2;
			ri.rect.y -= ri.rect.h / 2;
		}
	}
	return ri;
}
开发者ID:shikadilord,项目名称:wesnoth,代码行数:28,代码来源:part.cpp


示例5: draw_item

void item_palette::draw_item(const overlay& item, surface& image, std::stringstream& tooltip_text)
{
	std::stringstream filename;
	filename << item.image;
	if(item.image.empty()) {
		filename << item.halo;
	}

	image = image::get_image(filename.str());
	if(image == nullptr) {
		tooltip_text << "IMAGE NOT FOUND\n";
		ERR_ED << "image for item type: '" << filename.str() << "' not found" << std::endl;
		image = image::get_image(game_config::images::missing);
		if(image == nullptr) {
			ERR_ED << "Placeholder image not found" << std::endl;
			return;
		}
	}

	if(image->w != item_size_ || image->h != item_size_) {
		image.assign(scale_surface(image, item_size_, item_size_));
	}

	tooltip_text << item.name;
}
开发者ID:fluffbeast,项目名称:wesnoth-old,代码行数:25,代码来源:item_palette.cpp


示例6: draw_image

/* @brief Draw an image at the given offset.
 *
 * @param cr A cairo context for drawing to the screen.
 * @param file The image to be drawn.
 * @return The advance in the x direction.
 */
static uint32_t draw_image(cairo_t *cr, const char *file, offset_t offset) {
  wordexp_t expanded_file;
  if (wordexp(file, &expanded_file, 0)) {
    fprintf(stderr, "Error expanding file %s\n", file);
  } else {
    file = expanded_file.we_wordv[0];
  }

  if (access(file, F_OK) == -1) {
    fprintf(stderr, "Cannot open image file %s\n", file);
    return 0;
  }

  cairo_surface_t *img;
  img = cairo_image_surface_create_from_png(file);
  int w = cairo_image_surface_get_width(img);
  int h = cairo_image_surface_get_height(img);
  int neww = (int)(((float)(settings.height) * ((float)(w) / (float)(h))) + 0.49999999);
  img = scale_surface (img, w, h, neww, settings.height);
  h = settings.height;
  w = neww;
  /* Attempt to center the image if it is not the height of the line. */ 
  int image_offset = (h - settings.height) / 2;
  cairo_set_source_surface(cr, img, offset.x, offset.image_y - h + image_offset);
  cairo_mask_surface(cr, img, offset.x, offset.image_y - h + image_offset);

  return w;
}
开发者ID:infokiller,项目名称:lighthouse,代码行数:34,代码来源:lighthouse.c


示例7: cairo_image_surface_create_from_png

/* Load a file image in the window. */
static void
load_file               ()
{
  if (background_data->background_cr)
    {
      cairo_surface_t *surface = cairo_image_surface_create_from_png (background_data->background_image);
      cairo_t *cr = cairo_create (surface);

      gtk_window_set_opacity (GTK_WINDOW (background_data->background_window), 1.0);
	
      gint new_height = 0;
      gint new_width = 0;
      new_height = gdk_window_get_height (gtk_widget_get_window (background_data->background_window));
      new_width = gdk_window_get_width (gtk_widget_get_window (background_data->background_window));

      cairo_surface_t *scaled_surface = scale_surface (surface, new_width, new_height );
	
      cairo_surface_destroy (surface);
	
      cairo_destroy (cr);
	
      cairo_set_source_surface (background_data->background_cr, scaled_surface, 0.0, 0.0);
	
      cairo_paint (background_data->background_cr);
      cairo_stroke (background_data->background_cr);
	
      cairo_surface_destroy (scaled_surface);
	
#ifndef _WIN32
      gtk_widget_input_shape_combine_region (background_data->background_window, NULL);
#endif
    }
}
开发者ID:vulpineblaze,项目名称:cpe190_csus_f14,代码行数:34,代码来源:background_window.c


示例8: temp_image

surface campaign::create_image_surface(const SDL_Rect& image_rect)
{
	surface temp_image(
		image::get_image(image::locator(image_label_)));

	return scale_surface(temp_image, image_rect.w, image_rect.h);
}
开发者ID:RolandHoGH,项目名称:wesnoth,代码行数:7,代码来源:create_engine.cpp


示例9: image

void unit_palette::draw_item(SDL_Rect& dstrect, const unit_type& u, std::stringstream& tooltip_text) {

	surface screen = gui_.video().getSurface();

	const std::string filename = u.image();
	surface image(image::get_image(filename));
	if(image == NULL) {
		tooltip_text << "IMAGE NOT FOUND\n";
		ERR_ED << "image for terrain: '" << filename << "' not found\n";
		image = image::get_image(game_config::images::missing);
		if (image == NULL) {
			ERR_ED << "Placeholder image not found\n";
			return;
		}
	}

	if(image->w != item_size_ || image->h != item_size_) {
		image.assign(scale_surface(image,
				item_size_, item_size_));
	}

	sdl_blit(image, NULL, screen, &dstrect);

	tooltip_text << u.type_name();
}
开发者ID:ehsan,项目名称:wesnoth,代码行数:25,代码来源:unit_palette.cpp


示例10: return

surface scale_function::operator()(const surface& src) const
{
	const int old_w = src->w;
	const int old_h = src->h;
	int w = w_;
	int h = h_;

	if(w <= 0) {
		if(w < 0) {
			ERR_DP << "width of SCALE is negative - resetting to original width\n";
		}
		w = old_w;
	}
	if(h <= 0) {
		if(h < 0) {
			ERR_DP << "height of SCALE is negative - resetting to original height\n";
		}
		h = old_h;
	}

	return(
		(w != old_w || h != old_h) ?
		scale_surface(src, w, h) :
		src
	);
}
开发者ID:hyrio,项目名称:War-Of-Kingdom,代码行数:26,代码来源:image_function.cpp


示例11: blur_area

void part_ui::render_story_box_borders(SDL_Rect& update_area)
{
    const part::BLOCK_LOCATION tbl = p_.story_text_location();

    if(has_background_) {
        surface border_top = NULL;
        surface border_bottom = NULL;

        if(tbl == part::BLOCK_BOTTOM || tbl == part::BLOCK_MIDDLE) {
            border_top = image::get_image(storybox_top_border_path);
        }

        if(tbl == part::BLOCK_TOP || tbl == part::BLOCK_MIDDLE) {
            border_bottom = image::get_image(storybox_bottom_border_path);
        }

        //
        // If one of those are null at this point, it means that either we
        // don't need that border pic, or it is missing (in such case get_image()
        // would report).
        //

        if(border_top.null() != true) {
            if((border_top = scale_surface(border_top, screen_area().w, border_top->h)).null()) {
                WARN_NG << "storyscreen got a null top border surface after rescaling\n";
            }
            else {
                update_area.y -= border_top->h;
                update_area.h += border_top->h;
                blur_area(video_, update_area.y, border_top->h);
                video_.blit_surface(0, update_area.y, border_top);
            }
        }

        if(border_bottom.null() != true) {
            if((border_bottom = scale_surface(border_bottom, screen_area().w, border_bottom->h)).null()) {
                WARN_NG << "storyscreen got a null bottom border surface after rescaling\n";
            }
            else {
                blur_area(video_, update_area.h, border_bottom->h);
                video_.blit_surface(0, update_area.y+update_area.h, border_bottom);
                update_area.h += border_bottom->h;
            }
        }
    }
}
开发者ID:KylePoole,项目名称:wesnoth_ios,代码行数:46,代码来源:render.cpp


示例12: get_surface_from_pixbuf

static cairo_surface_t *
get_surface_from_pixbuf (GdkPixbuf         *pixbuf,
                         MetaImageFillType  fill_type,
                         gdouble            width,
                         gdouble            height,
                         gboolean           vertical_stripes,
                         gboolean           horizontal_stripes)
{
  gdouble pixbuf_width;
  gdouble pixbuf_height;
  cairo_surface_t *surface;
  cairo_content_t content;
  cairo_surface_t *copy;
  cairo_t *cr;

  pixbuf_width = gdk_pixbuf_get_width (pixbuf);
  pixbuf_height = gdk_pixbuf_get_height (pixbuf);
  surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, 1, NULL);

  if (pixbuf_width == width && pixbuf_height == height)
    {
      return surface;
    }

  if (fill_type != META_IMAGE_FILL_TILE)
    {
      cairo_surface_t *scaled;

      scaled = scale_surface (surface, pixbuf_width, pixbuf_height,
                              width, height, vertical_stripes,
                              horizontal_stripes);

      cairo_surface_destroy (surface);
      surface = scaled;
    }

  content = CAIRO_CONTENT_COLOR_ALPHA;
  width = ceil (width);
  height = ceil (height);

  copy = cairo_surface_create_similar (surface, content, width, height);
  cr = cairo_create (copy);

  cairo_set_source_surface (cr, surface, 0, 0);

  if (fill_type == META_IMAGE_FILL_TILE ||
      vertical_stripes || horizontal_stripes)
    {
      cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT);
    }

  cairo_paint (cr);
  cairo_destroy (cr);

  cairo_surface_destroy (surface);

  return copy;
}
开发者ID:GNOME,项目名称:metacity,代码行数:58,代码来源:meta-draw-op.c


示例13: widget

button::button(CVideo& video, const std::string& label, button::TYPE type,
               std::string button_image_name, SPACE_CONSUMPTION spacing, const bool auto_join)
	: widget(video, auto_join), type_(type), label_(label),
	  image_(NULL), pressedImage_(NULL), activeImage_(NULL), pressedActiveImage_(NULL),
	  button_(true), state_(NORMAL), pressed_(false),
	  spacing_(spacing), base_height_(0), base_width_(0)
{
	if(button_image_name.empty() && type == TYPE_PRESS) {
		button_image_name = "button";
	} else if(button_image_name.empty() && type == TYPE_CHECK) {
		button_image_name = "checkbox";
	}

	const std::string button_image_file = "buttons/" + button_image_name + ".png";
	surface button_image(image::get_image(button_image_file));
	surface pressed_image(image::get_image("buttons/" + button_image_name + "-pressed.png"));
	surface active_image(image::get_image("buttons/" + button_image_name + "-active.png"));
	surface pressed_active_image;

	if (pressed_image.null())
		pressed_image.assign(button_image);

	if (active_image.null())
		active_image.assign(button_image);

	if (type == TYPE_CHECK) {
		pressed_active_image.assign(image::get_image("buttons/" + button_image_name + "-active-pressed.png"));
		if (pressed_active_image.null())
			pressed_active_image.assign(pressed_image);
	}

	if (button_image.null()) {
		ERR_DP << "error initializing button!\n";
		throw error();
	}

	base_height_ = button_image->h;
	base_width_ = button_image->w;

	if (type_ != TYPE_IMAGE){
		set_label(label);
	}

	if(type == TYPE_PRESS) {
		image_.assign(scale_surface(button_image,location().w,location().h));
		pressedImage_.assign(scale_surface(pressed_image,location().w,location().h));
		activeImage_.assign(scale_surface(active_image,location().w,location().h));
	} else {
		image_.assign(scale_surface(button_image,button_image->w,button_image->h));
		pressedImage_.assign(scale_surface(pressed_image,button_image->w,button_image->h));
		activeImage_.assign(scale_surface(active_image,button_image->w,button_image->h));
		if (type == TYPE_CHECK)
			pressedActiveImage_.assign(scale_surface(pressed_active_image, button_image->w, button_image->h));
	}

	if (type_ == TYPE_IMAGE){
		calculate_size();
	}
}
开发者ID:RushilPatel,项目名称:BattleForWesnoth,代码行数:59,代码来源:button.cpp


示例14: scale_surface

surface light_modification::operator()(const surface& src) const {
	if(src == NULL) { return NULL; }

	//light_surface wants a neutral surface having same dimensions
	surface nsurf;
	if(surf_->w != src->w || surf_->h != src->h)
		nsurf = scale_surface(surf_, src->w, src->h, false);
	else
		nsurf = make_neutral_surface(surf_);
	return light_surface(src, nsurf);;
}
开发者ID:AG-Dev,项目名称:wesnoth_ios,代码行数:11,代码来源:image_modifications.cpp


示例15: scale_surface

void mouse_action_starting_position::set_mouse_overlay(editor_display& disp)
{
	surface image = image::get_image("editor/tool-overlay-starting-position.png");
	Uint8 alpha = 196;
	int size = image->w;
	int zoom = static_cast<int>(size * disp.get_zoom_factor());

	// Add the alpha factor and scale the image
	image = scale_surface(adjust_surface_alpha(image, alpha), zoom, zoom);
	disp.set_mouseover_hex_overlay(image);
}
开发者ID:Yossarian,项目名称:WesnothAddonServer,代码行数:11,代码来源:mouse_action.cpp


示例16: top_image

void dialog_frame::draw_border()
{
	if(have_border_ == false) {
		return;
	}

	surface top_image(scale_surface(top_, dim_.interior.w, top_->h));

	if(top_image != NULL) {
		video_.blit_surface(dim_.interior.x, dim_.exterior.y, top_image);
	}

	surface bot_image(scale_surface(bot_, dim_.interior.w, bot_->h));

	if(bot_image != NULL) {
		video_.blit_surface(dim_.interior.x, dim_.interior.y + dim_.interior.h, bot_image);
	}

	surface left_image(scale_surface(left_, left_->w, dim_.interior.h));

	if(left_image != NULL) {
		video_.blit_surface(dim_.exterior.x, dim_.interior.y, left_image);
	}

	surface right_image(scale_surface(right_, right_->w, dim_.interior.h));

	if(right_image != NULL) {
		video_.blit_surface(dim_.interior.x + dim_.interior.w, dim_.interior.y, right_image);
	}

	update_rect(dim_.exterior);

	if(top_left_ == NULL || bot_left_ == NULL || top_right_ == NULL || bot_right_ == NULL) {
		return;
	}

	video_.blit_surface(dim_.interior.x - left_->w, dim_.interior.y - top_->h, top_left_);
	video_.blit_surface(dim_.interior.x - left_->w, dim_.interior.y + dim_.interior.h + bot_->h - bot_left_->h, bot_left_);
	video_.blit_surface(dim_.interior.x + dim_.interior.w + right_->w - top_right_->w, dim_.interior.y - top_->h, top_right_);
	video_.blit_surface(dim_.interior.x + dim_.interior.w + right_->w - bot_right_->w, dim_.interior.y + dim_.interior.h + bot_->h - bot_right_->h, bot_right_);
}
开发者ID:CliffsDover,项目名称:wesnoth_ios,代码行数:41,代码来源:show_dialog.cpp


示例17: scale_surface

floating_image::render_input floating_image::get_render_input(double xscale, double yscale, SDL_Rect& dst_rect) const
{
#ifdef SDL_GPU
	render_input ri = {
		{0,0,0,0},
		file_.empty() ? sdl::timage() : image::get_texture(file_)
	};

	if(!ri.image.null()) {
		if(autoscaled_) {
			ri.image.set_scale(xscale, yscale);
		}

		ri.rect.x = static_cast<int>(x_*xscale) + dst_rect.x;
		ri.rect.y = static_cast<int>(y_*yscale) + dst_rect.y;
		ri.rect.w = ri.image.width();
		ri.rect.h = ri.image.height();

		if(centered_) {
			ri.rect.x -= ri.rect.w / 2;
			ri.rect.y -= ri.rect.h / 2;
		}
	}
	return ri;
#else
	render_input ri = {
		{0,0,0,0},
		file_.empty() ? nullptr : image::get_image(file_)
	};

	if(!ri.image.null()) {
		if(autoscaled_) {
			ri.image = scale_surface(
				ri.image,
				static_cast<int>(ri.image->w * xscale),
				static_cast<int>(ri.image->h * yscale)
			);
		}

		ri.rect.x = static_cast<int>(x_*xscale) + dst_rect.x;
		ri.rect.y = static_cast<int>(y_*yscale) + dst_rect.y;
		ri.rect.w = ri.image->w;
		ri.rect.h = ri.image->h;

		if(centered_) {
			ri.rect.x -= ri.rect.w / 2;
			ri.rect.y -= ri.rect.h / 2;
		}
	}
	return ri;
#endif
}
开发者ID:jamesp-,项目名称:wesnoth,代码行数:52,代码来源:part.cpp


示例18: scale

static void
scale(surface& surf, const std::string& parameters)
{
	unsigned width, height;
	const int count = sscanf(parameters.c_str(), "%u,%u", &width, &height);

	if(count != 2) {
		std::cerr << "Error: Arguments to scale »"
				<< parameters
				<< "« are not compatible.\n";
		throw texit(EXIT_FAILURE);
	}

	surf = scale_surface(surf, width, height);
}
开发者ID:ArtBears,项目名称:wesnoth,代码行数:15,代码来源:filter.cpp


示例19: scale_surface

void tcontrol::set_surface(const surface& surf, int w, int h)
{
	size_t count = canvas_.size();

	surfs_.clear();
	surfs_.resize(count);
	if (!surf || !count) {
		return;
	}

	surface normal = scale_surface(surf, w, h);
	for (size_t n = 0; n < count; n ++) {
		surfs_[n] = normal;
	}

	set_dirty();
}
开发者ID:suxinde2009,项目名称:Rose,代码行数:17,代码来源:control.cpp


示例20: scale_surface

void menu::imgsel_style::draw_row_bg(menu& menu_ref, const size_t row_index, const SDL_Rect& rect, ROW_TYPE type)
{
	if(type == SELECTED_ROW && has_background_ && !load_failed_) {
		if(bg_cache_.width != rect.w || bg_cache_.height != rect.h)
		{
			//draw scaled background image
			//scale image each time (to prevent loss of quality)
			bg_cache_.surf = scale_surface(img_map_["background"], rect.w, rect.h);
			bg_cache_.width = rect.w;
			bg_cache_.height = rect.h;
		}
		SDL_Rect clip = rect;
		menu_ref.video().blit_surface(rect.x,rect.y,bg_cache_.surf,nullptr,&clip);
	}
	else {
		style::draw_row_bg(menu_ref, row_index, rect, type);
	}
}
开发者ID:fluffbeast,项目名称:wesnoth-old,代码行数:18,代码来源:menu_style.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ scaledFontPixelSize函数代码示例发布时间:2022-05-30
下一篇:
C++ scaleRect函数代码示例发布时间: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