当前位置: 首页>>代码示例>>C++>>正文


C++ bitmap_argb32::pix32方法代码示例

本文整理汇总了C++中bitmap_argb32::pix32方法的典型用法代码示例。如果您正苦于以下问题:C++ bitmap_argb32::pix32方法的具体用法?C++ bitmap_argb32::pix32怎么用?C++ bitmap_argb32::pix32使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bitmap_argb32的用法示例。


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

示例1: render_triangle

void ui_menu::render_triangle(bitmap_argb32 &dest, bitmap_argb32 &source, const rectangle &sbounds, void *param)
{
	int halfwidth = dest.width() / 2;
	int height = dest.height();
	int x, y;

	// start with all-transparent
	dest.fill(rgb_t(0x00,0x00,0x00,0x00));

	// render from the tip to the bottom
	for (y = 0; y < height; y++)
	{
		int linewidth = (y * (halfwidth - 1) + (height / 2)) * 255 * 2 / height;
		UINT32 *target = &dest.pix32(y, halfwidth);

		// don't antialias if height < 12
		if (dest.height() < 12)
		{
			int pixels = (linewidth + 254) / 255;
			if (pixels % 2 == 0) pixels++;
			linewidth = pixels * 255;
		}

		// loop while we still have data to generate
		for (x = 0; linewidth > 0; x++)
		{
			int dalpha;

			// first column we only consume one pixel
			if (x == 0)
			{
				dalpha = MIN(0xff, linewidth);
				target[x] = rgb_t(dalpha,0xff,0xff,0xff);
			}

			// remaining columns consume two pixels, one on each side
			else
			{
				dalpha = MIN(0x1fe, linewidth);
				target[x] = target[-x] = rgb_t(dalpha/2,0xff,0xff,0xff);
			}

			// account for the weight we consumed */
			linewidth -= dalpha;
		}
	}
}
开发者ID:toughkidcst,项目名称:mame,代码行数:47,代码来源:menu.cpp

示例2: SaveBitmap2

HRESULT SaveBitmap2(bitmap_argb32 &bitmap, const WCHAR *filename)
{
	HRESULT result;

	// Convert the bitmap into a form we understand and save it
	std::unique_ptr<UINT32> pBitmap(new UINT32[bitmap.width() * bitmap.height()]);
	for (int y = 0; y < bitmap.height(); y++)
	{
		UINT32* pRow = pBitmap.get() + (y * bitmap.width());
		for (int x = 0; x < bitmap.width(); x++)
		{
			UINT32 pixel = bitmap.pix32(y, x);
			pRow[x] = (pixel == 0xFFFFFFFF) ? rgb_t(0xFF, 0x00, 0x00, 0x00) : rgb_t(0xFF, 0xFF, 0xFF, 0xFF);
		}
	}

	ComPtr<IWICImagingFactory> wicFactory;
	HR_RETHR(CoCreateInstance(
		CLSID_WICImagingFactory,
		nullptr,
		CLSCTX_INPROC_SERVER,
		__uuidof(IWICImagingFactory),
		(void**)&wicFactory));

	// Save bitmap
	ComPtr<IWICBitmap> bmp2 = nullptr;
	wicFactory->CreateBitmapFromMemory(
		bitmap.width(),
		bitmap.height(),
		GUID_WICPixelFormat32bppRGBA,
		bitmap.width() * sizeof(UINT32),
		bitmap.width() * bitmap.height() * sizeof(UINT32),
		(BYTE*)pBitmap.get(),
		&bmp2);

	SaveBitmap(bmp2.Get(), GUID_WICPixelFormat32bppRGBA, filename);

	return S_OK;
}
开发者ID:RalfVB,项目名称:mame,代码行数:39,代码来源:font_dwrite.cpp

示例3: get_bitmap


//.........这里部分代码省略.........
		run.glyphAdvances = &advanceWidth;
		run.glyphOffsets = &offsets;

		auto baseline_origin = D2D1::Point2F(BITMAP_PAD + abc.abcA().Dips() + 1, BITMAP_PAD + ascent.Dips());
		target->DrawGlyphRun(
			baseline_origin,
			&run,
			pWhiteBrush.Get(),
			DWRITE_MEASURING_MODE_GDI_CLASSIC);

		HR_RET0(target->EndDraw());

#ifdef DWRITE_DEBUGGING
		// Save to file for debugging
		SaveBitmap(wicBitmap.Get(), GUID_WICPixelFormatBlackWhite, L"C:\\temp\\ddraw_step1.bmp");
#endif

		// characters are expected to be full-height
		rectangle actbounds;
		actbounds.min_y = BITMAP_PAD;
		actbounds.max_y = BITMAP_PAD + charHeight.Dips() - 1;

		// Lock the bitmap and get the data pointer
		WICRect rect = { 0, 0, bmwidth, bmheight };
		HR_RET0(wicBitmap->Lock(&rect, WICBitmapLockRead, lock.GetAddressOf()));
		HR_RET0(lock->GetDataPointer(&cbData, static_cast<BYTE**>(&pixels)));

		// determine the actual left of the character
		for (actbounds.min_x = 0; actbounds.min_x < bmwidth; actbounds.min_x++)
		{
			BYTE *offs = pixels + actbounds.min_x;
			UINT8 summary = 0;
			for (int y = 0; y < bmheight; y++)
				summary |= offs[y * bmwidth];
			if (summary != 0)
			{
				break;
			}
		}

		// determine the actual right of the character
		// Start from the right edge, and move in until we find a pixel
		for (actbounds.max_x = bmwidth - 1; actbounds.max_x >= 0; actbounds.max_x--)
		{
			BYTE *offs = pixels + actbounds.max_x;
			UINT8 summary = 0;

			// Go through the entire column and build a summary
			for (int y = 0; y < bmheight; y++)
				summary |= offs[y * bmwidth];
			if (summary != 0)
			{
				break;
			}
		}

		// allocate a new bitmap
		if (actbounds.max_x >= actbounds.min_x && actbounds.max_y >= actbounds.min_y)
		{
			bitmap.allocate(actbounds.max_x + 1 - actbounds.min_x, actbounds.max_y + 1 - actbounds.min_y);

			// copy the bits into it
			for (int y = 0; y < bitmap.height(); y++)
			{
				UINT32 *dstrow = &bitmap.pix32(y);
				UINT8 *srcrow = &pixels[(y + actbounds.min_y) * bmwidth];
				for (int x = 0; x < bitmap.width(); x++)
				{
					int effx = x + actbounds.min_x;
					dstrow[x] = rgb_t(srcrow[effx], 0xff, 0xff, 0xff);
				}
			}

			// set the final offset values
			xoffs = actbounds.min_x - (BITMAP_PAD + abc.abcA().Dips());
			yoffs = actbounds.max_y - (BITMAP_PAD + ascent.Dips());

#ifdef DWRITE_DEBUGGING
			SaveBitmap2(bitmap, L"C:\\temp\\dwrite_final.bmp");
#endif
		}

		BOOL success = bitmap.valid();

#ifdef DWRITE_DEBUGGING
		osd_printf_debug(
			"dwr: %s, c'%S' w%i x%i y%i asc%i dsc%i a%ib%ic%i\n",
			success ? "Success" : "Error",
			(WCHAR*)&chnum,
			width,
			xoffs,
			yoffs,
			ascent.Dips(),
			descent.Dips(),
			abc.abcA().Dips(),
			abc.abcB().Dips(),
			abc.abcC().Dips());
#endif
		return success;
	}
开发者ID:NULUSIOS,项目名称:mame,代码行数:101,代码来源:font_dwrite.cpp

示例4: pixel_is_set

inline int pixel_is_set(bitmap_argb32 &bitmap, int y, int x)
{
	return (bitmap.pix32(y, x) & 0xffffff) == 0;
}
开发者ID:ef1105,项目名称:mameplus,代码行数:4,代码来源:png2bdc.c

示例5: get_bitmap


//.........这里部分代码省略.........
    RGBQUAD col2 = info.bmiColors[1];
    col1.rgbBlue = col1.rgbGreen = col1.rgbRed = 0x00;
    col2.rgbBlue = col2.rgbGreen = col2.rgbRed = 0xff;

    // create a DIB to render to
    BYTE *bits;
    HBITMAP dib = CreateDIBSection(dummyDC, &info, DIB_RGB_COLORS, reinterpret_cast<VOID **>(&bits), NULL, 0);

    if (dib)
    {
        HGDIOBJ oldbitmap = SelectObject(dummyDC, dib);

        // clear the bitmap
        int rowbytes = bmwidth / 8;
        memset(bits, 0, rowbytes * bmheight);

        // now draw the character
        WCHAR tempchar = chnum;
        SetTextColor(dummyDC, RGB(0xff, 0xff, 0xff));
        SetBkColor(dummyDC, RGB(0x00, 0x00, 0x00));
        ExtTextOutW(dummyDC, 50 + abc.abcA, 50, ETO_OPAQUE, NULL, &tempchar, 1, NULL);

        // characters are expected to be full-height
        rectangle actbounds;
        actbounds.min_y = 50;
        actbounds.max_y = 50 + metrics.tmHeight - 1;

        // determine the actual left of the character
        for (actbounds.min_x = 0; actbounds.min_x < rowbytes; actbounds.min_x++)
        {
            BYTE *offs = bits + actbounds.min_x;
            UINT8 summary = 0;
            for (int y = 0; y < bmheight; y++)
                summary |= offs[y * rowbytes];
            if (summary != 0)
            {
                actbounds.min_x *= 8;
                if (!(summary & 0x80)) actbounds.min_x++;
                if (!(summary & 0xc0)) actbounds.min_x++;
                if (!(summary & 0xe0)) actbounds.min_x++;
                if (!(summary & 0xf0)) actbounds.min_x++;
                if (!(summary & 0xf8)) actbounds.min_x++;
                if (!(summary & 0xfc)) actbounds.min_x++;
                if (!(summary & 0xfe)) actbounds.min_x++;
                break;
            }
        }

        // determine the actual right of the character
        for (actbounds.max_x = rowbytes - 1; actbounds.max_x >= 0; actbounds.max_x--)
        {
            BYTE *offs = bits + actbounds.max_x;
            UINT8 summary = 0;
            for (int y = 0; y < bmheight; y++)
                summary |= offs[y * rowbytes];
            if (summary != 0)
            {
                actbounds.max_x *= 8;
                if (summary & 0x7f) actbounds.max_x++;
                if (summary & 0x3f) actbounds.max_x++;
                if (summary & 0x1f) actbounds.max_x++;
                if (summary & 0x0f) actbounds.max_x++;
                if (summary & 0x07) actbounds.max_x++;
                if (summary & 0x03) actbounds.max_x++;
                if (summary & 0x01) actbounds.max_x++;
                break;
            }
        }

        // allocate a new bitmap
        if (actbounds.max_x >= actbounds.min_x && actbounds.max_y >= actbounds.min_y)
        {
            bitmap.allocate(actbounds.max_x + 1 - actbounds.min_x, actbounds.max_y + 1 - actbounds.min_y);

            // copy the bits into it
            for (int y = 0; y < bitmap.height(); y++)
            {
                UINT32 *dstrow = &bitmap.pix32(y);
                UINT8 *srcrow = &bits[(y + actbounds.min_y) * rowbytes];
                for (int x = 0; x < bitmap.width(); x++)
                {
                    int effx = x + actbounds.min_x;
                    dstrow[x] = ((srcrow[effx / 8] << (effx % 8)) & 0x80) ? rgb_t(0xff, 0xff, 0xff, 0xff) : rgb_t(0x00, 0xff, 0xff, 0xff);
                }
            }

            // set the final offset values
            xoffs = actbounds.min_x - (50 + abc.abcA);
            yoffs = actbounds.max_y - (50 + metrics.tmAscent);
        }

        // de-select the font and release the DC
        SelectObject(dummyDC, oldbitmap);
        DeleteObject(dib);
    }

    SelectObject(dummyDC, oldfont);
    DeleteDC(dummyDC);
    return bitmap.valid();
}
开发者ID:hstampfl,项目名称:mame,代码行数:101,代码来源:font_windows.c


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