本文整理汇总了C++中Bitmap::GetSize方法的典型用法代码示例。如果您正苦于以下问题:C++ Bitmap::GetSize方法的具体用法?C++ Bitmap::GetSize怎么用?C++ Bitmap::GetSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bitmap
的用法示例。
在下文中一共展示了Bitmap::GetSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
float SquareMatrix::CalcFutureScore2( Bitmap const &bitmap, size_t startPos, size_t endPos ) const
{
const size_t notInGap= numeric_limits<size_t>::max();
float futureScore = 0.0f;
size_t startGap = bitmap.GetFirstGapPos();
if (startGap == NOT_FOUND) return futureScore; // everything filled
// start loop at first gap
size_t startLoop = startGap+1;
if (startPos == startGap) { // unless covered by phrase
startGap = notInGap;
startLoop = endPos+1; // -> postpone start
}
size_t lastCovered = bitmap.GetLastPos();
if (endPos > lastCovered || lastCovered == NOT_FOUND) lastCovered = endPos;
for(size_t currPos = startLoop; currPos <= lastCovered ; currPos++) {
// start of a new gap?
if(startGap == notInGap && bitmap.GetValue(currPos) == false && (currPos < startPos || currPos > endPos)) {
startGap = currPos;
}
// end of a gap?
else if(startGap != notInGap && (bitmap.GetValue(currPos) == true || (startPos <= currPos && currPos <= endPos))) {
futureScore += GetScore(startGap, currPos - 1);
startGap = notInGap;
}
}
// coverage ending with gap?
if (lastCovered != bitmap.GetSize() - 1) {
futureScore += GetScore(lastCovered+1, bitmap.GetSize() - 1);
}
return futureScore;
}
示例2: add
Bitmap add(const Bitmap& lhs, const Bitmap& rhs){
assert(lhs.GetSize() == rhs.GetSize());
Bitmap dst(lhs.GetSize());
for (int y = 0; y != lhs.m_h; y++){
for (int x = 0; x != lhs.m_w; x++){
put_pixel_raw(dst, x, y,
add(get_color_raw(lhs, x, y), get_color_raw(rhs, x, y)));
}
}
return dst;
}
示例3: inverted
void
Canvas::invert_stretch_transparent(const Bitmap &src, Color key)
{
assert(IsDefined());
assert(src.IsDefined());
HDC virtual_dc = GetCompatibleDC();
HBITMAP old = (HBITMAP)::SelectObject(virtual_dc, src.GetNative());
const PixelSize size = src.GetSize();
BufferCanvas inverted(*this, size.cx, size.cy);
::BitBlt(inverted, 0, 0, size.cx, size.cy,
virtual_dc, 0, 0, NOTSRCCOPY);
::SelectObject(virtual_dc, old);
#ifdef _WIN32_WCE
::TransparentImage(dc, 0, 0, get_width(), get_height(),
inverted, 0, 0, size.cx, size.cy,
key);
#else
::TransparentBlt(dc, 0, 0, get_width(), get_height(),
inverted, 0, 0, size.cx, size.cy,
key);
#endif
}
示例4: Apply
void Apply(Bitmap& bmp) const override{
// Fixme: Allocation, handle OOM
Bitmap bg(bmp.GetSize(), color_transparent_white);
for (int y = 1; y < bmp.m_h - 1; y++){
for (int x = 1; x < bmp.m_w - 1; x++){
Color current = get_color_raw(bmp, x, y);
Color right(get_color_raw(bmp, x + 1, y));
if (current.a == 0 && right.a != 0){
fill_ellipse_color(bg,
IntRect(IntPoint(x - 3, y - 3), IntSize(7,7)),
Color(0,0,0));
}
else if (current.a != 0 && right.a == 0){
fill_ellipse_color(bg,
IntRect(IntPoint(x - 3 + 1, y - 3), IntSize(7,7)),
Color(0,0,0));
}
Color down(get_color_raw(bmp, x, y + 1));
if (current.a == 0 && down.a != 0){
fill_ellipse_color(bg,
IntRect(IntPoint(x - 3, y - 3), IntSize(7,7)),
Color(0,0,0));
}
if (current.a != 0 && down.a == 0){
fill_ellipse_color(bg,
IntRect(IntPoint(x - 3, y - 3 + 1), IntSize(7,7)),
Color(0,0,0));
}
}
}
blit_masked(at_top_left(bmp), onto(bg), color_transparent_white);
bmp = bg;
}
示例5: test_scale_bilinear
void test_scale_bilinear(){
using namespace faint;
const Bitmap src = load_test_image(FileName("bicubic-source.png"));
const Bitmap key = load_test_image(FileName("bilinear-key.png"));
Bitmap dst = scale_bilinear(src, rounded(src.GetSize() * Scale(2.0, 3.0)));
VERIFY(dst == key);
}
示例6: pixelize
void pixelize(Bitmap& bmp, const pixelize_range_t& width){
static_assert(pixelize_range_t::min_allowed > 0,
"pixelize expects min bound > 0");
int w(width.GetValue());
IntSize sz(bmp.GetSize());
Bitmap bmp2(sz);
for (int y = 0; y < sz.h; y +=w){
for (int x = 0; x < sz.w; x +=w){
int r = 0;
int g = 0;
int b = 0;
int a = 0;
int count = 0;
for (int j = 0; y + j != sz.h && j != w; j++){
for (int i = 0; x + i != sz.w && i != w; i++){
Color c = get_color_raw(bmp, x + i, y + j);
r += c.r;
g += c.g;
b += c.b;
a += c.a;
count++;
}
}
Color c2(color_from_ints(r / count, g / count, b / count, a / count));
for (int j = 0; y + j < sz.h && j != w; j++){
for (int i = 0; x + i != sz.w && i != w; i++){
put_pixel_raw(bmp2, x + i, y + j, c2);
}
}
}
}
bmp = bmp2;
}
示例7: assert
void
Canvas::Stretch(const Bitmap &src)
{
assert(src.IsDefined());
const PixelSize size = src.GetSize();
Stretch(src, 0, 0, size.cx, size.cy);
}
示例8: desaturate_AlphaMap
// Fixme: Pass a channel_t instead, and quantize outside
static AlphaMap desaturate_AlphaMap(const Bitmap& bmp){
AlphaMap a(bmp.GetSize());
for (int y = 0; y != bmp.m_h; y++){
for (int x = 0; x != bmp.m_w; x++){
Color c(get_color_raw(bmp, x, y));
a.Set(x, y, static_cast<uchar>(sum_rgb(c) / 3));
}
}
return a;
}
示例9: assert
void
Brush::Set(const Bitmap &bitmap)
{
/* GDI works best when the bitmap is 8x8 - to avoid bad performance,
disallow using any other bitmap size */
assert(bitmap.GetSize().cx == 8);
assert(bitmap.GetSize().cy == 8);
Reset();
brush = ::CreatePatternBrush(bitmap.GetNative());
}
示例10: assert
void
Canvas::stretch(PixelScalar dest_x, PixelScalar dest_y,
UPixelScalar dest_width, UPixelScalar dest_height,
const Bitmap &src)
{
assert(src.IsDefined());
const PixelSize size = src.GetSize();
stretch(dest_x, dest_y, dest_width, dest_height,
src, 0, 0, size.cx, size.cy);
}
示例11: CalcFutureScore
float SquareMatrix::CalcFutureScore( Bitmap const &bitmap ) const
{
const size_t notInGap= numeric_limits<size_t>::max();
size_t startGap = notInGap;
float futureScore = 0.0f;
for(size_t currPos = 0 ; currPos < bitmap.GetSize() ; currPos++) {
// start of a new gap?
if(bitmap.GetValue(currPos) == false && startGap == notInGap) {
startGap = currPos;
}
// end of a gap?
else if(bitmap.GetValue(currPos) == true && startGap != notInGap) {
futureScore += GetScore(startGap, currPos - 1);
startGap = notInGap;
}
}
// coverage ending with gap?
if (startGap != notInGap) {
futureScore += GetScore(startGap, bitmap.GetSize() - 1);
}
return futureScore;
}
示例12: Update
void Texture::Update(Rectangle area, const Bitmap& bitmap)
{
if (m_handle == 0)
{
throw std::runtime_error("Texture::Update(Rectangle, const Bitmap&): uninitialized texture");
}
if (area.Size() != bitmap.GetSize() || !Rectangle(m_size).Contains(area))
{
throw std::runtime_error("Texture::Update(Rectangle, const Bitmap&): invalid area");
}
Bind();
glTexSubImage2D(GL_TEXTURE_2D, 0, area.left, area.top, area.width, area.height, color_format, GL_UNSIGNED_BYTE, (uint8_t*)bitmap.GetData());
}
示例13: sepia
void sepia(Bitmap& bmp, int intensity){
// Modified from:
// https://groups.google.com/forum/#!topic/comp.lang.java.programmer/nSCnLECxGdA
int depth = 20;
const IntSize sz = bmp.GetSize();
for (int y = 0; y != sz.h; y++){
for (int x = 0; x != sz.w; x++){
Color c = get_color_raw(bmp, x, y);
const int gray = (c.r + c.g + c.b) / 3;
const int r = std::min(gray + depth * 2, 255);
const int g = std::min(gray + depth, 255);
const int b = std::max(gray - intensity, 0);
put_pixel_raw(bmp, x, y, color_from_ints(r,g,b, c.a));
}
}
}
示例14: brightness_and_contrast
Bitmap brightness_and_contrast(const Bitmap& src, const brightness_contrast_t& v){
double scaledBrightness = v.brightness * 255.0;
Bitmap dst(src.GetSize());
for (int y = 0; y != src.m_h; y++){
for (int x = 0; x != src.m_w; x++){
const auto c = get_color_raw(src, x, y);
const auto c2 =
color_from_double(c.r * v.contrast + scaledBrightness,
c.g * v.contrast + scaledBrightness,
c.b * v.contrast + scaledBrightness,
c.a);
put_pixel_raw(dst, x, y, c2);
}
}
return dst;
}
示例15: HandleBitmap
void KJofol::HandleBitmap(string &oDir, char *name)
{
Bitmap *pBitmap;
string sname = name;
#ifdef WIN32
pBitmap = new Win32Bitmap(sname);
#elif defined(HAVE_GTK)
pBitmap = new GTKBitmap(sname);
#elif defined(__BEOS__)
pBitmap = new BeOSBitmap(sname);
#endif
string path = oDir + string(DIR_MARKER_STR) + string(name);
if (IsError(pBitmap->LoadBitmapFromDisk(path))) {
delete pBitmap;
return;
}
Color color;
Pos pos;
pos.x = 0;
pos.y = 0;
pBitmap->GetSize(pos);
bmp_sizes[name] = pos;
pos.x -= 2;
pos.y -= 2;
pBitmap->GetColor(pos, color);
char trans[32];
char outline[_MAX_PATH];
sprintf(trans, "#%02X%02X%02X", color.red, color.green, color.blue);
sprintf(outline, "<Bitmap Name=\"%s\" File=\"%s\" TransColor=\"%s\"/>\n",
name, name, trans);
Write(outline);
delete pBitmap;
}