本文整理汇总了C++中gdiplus::Bitmap::GetWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ Bitmap::GetWidth方法的具体用法?C++ Bitmap::GetWidth怎么用?C++ Bitmap::GetWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gdiplus::Bitmap
的用法示例。
在下文中一共展示了Bitmap::GetWidth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convertGdiplusBitmap
Surface8u convertGdiplusBitmap( Gdiplus::Bitmap &bitmap )
{
Gdiplus::BitmapData bitmapData;
Gdiplus::Rect rect( 0, 0, bitmap.GetWidth(), bitmap.GetHeight() );
Gdiplus::PixelFormat requestedFormat = bitmap.GetPixelFormat();
SurfaceChannelOrder sco;
bool premult;
gdiplusPixelFormatToSurfaceChannelOrder( requestedFormat, &sco, &premult );
if( sco == SurfaceChannelOrder::UNSPECIFIED ) {
UINT flags = bitmap.GetFlags();
sco = ( flags & Gdiplus::ImageFlagsHasAlpha ) ? SurfaceChannelOrder::BGRA : SurfaceChannelOrder::BGR;
requestedFormat = ( flags & Gdiplus::ImageFlagsHasAlpha ) ? PixelFormat32bppARGB : PixelFormat24bppRGB;
}
bitmap.LockBits( &rect, Gdiplus::ImageLockModeRead, requestedFormat, &bitmapData );
Surface8u result( bitmap.GetWidth(), bitmap.GetHeight(), sco.hasAlpha(), sco );
const uint8_t *srcDataBase = (uint8_t*)bitmapData.Scan0;
int32_t width = bitmap.GetWidth();
for( uint32_t y = 0; y < bitmap.GetHeight(); ++y ) {
memcpy( result.getData( Vec2i( 0, y ) ), srcDataBase + y * bitmapData.Stride, width * result.getPixelInc() );
}
bitmap.UnlockBits( &bitmapData );
return result;
}
示例2: DrawTexturedRect
void GDIPlus::DrawTexturedRect( Gwen::Texture* pTexture, Gwen::Rect pTargetRect, float u1, float v1, float u2, float v2 )
{
Gdiplus::Bitmap* pImage = (Gdiplus::Bitmap*) pTexture->data;
// Missing image, not loaded properly?
if ( !pImage || pImage->GetType() == Gdiplus::ImageTypeUnknown )
return DrawMissingImage( pTargetRect );
Translate( pTargetRect );
Gdiplus::RectF TargetRect( pTargetRect.x, pTargetRect.y, pTargetRect.w, pTargetRect.h );
// Convert UV to pixel coords
float fW = pImage->GetWidth();
float fH = pImage->GetHeight();
u1 *= fW;
v1 *= fH;
u2 *= fW;
u2 -= u1;
v2 *= fH;
v2 -= v1;
graphics->DrawImage( pImage, TargetRect, u1, v1, u2, v2, Gdiplus::UnitPixel );
}
示例3: convertGdiplusBitmap
Surface8u convertGdiplusBitmap( Gdiplus::Bitmap &bitmap, bool premultiplied )
{
Gdiplus::BitmapData bitmapData;
Gdiplus::Rect rect( 0, 0, bitmap.GetWidth(), bitmap.GetHeight() );
bitmap.LockBits( &rect, Gdiplus::ImageLockModeRead, (premultiplied) ? PixelFormat32bppPARGB : PixelFormat32bppARGB, &bitmapData );
Surface8u result( bitmap.GetWidth(), bitmap.GetHeight(), true, SurfaceChannelOrder::BGRA );
const uint8_t *srcDataBase = (uint8_t*)bitmapData.Scan0;
int32_t width = bitmap.GetWidth();
for( uint32_t y = 0; y < bitmap.GetHeight(); ++y ) {
memcpy( result.getData( Vec2i( 0, y ) ), srcDataBase + y * bitmapData.Stride, width * 4 );
}
bitmap.UnlockBits( &bitmapData );
return result;
}
示例4: Gdip_RemoveAlpha
// hack for stupid GDIplus
void Gdip_RemoveAlpha(Gdiplus::Bitmap& source, Gdiplus::Color color )
{
using namespace Gdiplus;
Rect r( 0, 0, source.GetWidth(),source.GetHeight() );
BitmapData bdSrc;
source.LockBits( &r, ImageLockModeRead , PixelFormat32bppARGB,&bdSrc);
BYTE* bpSrc = (BYTE*)bdSrc.Scan0;
//bpSrc += (int)sourceChannel;
for ( int i = r.Height * r.Width; i > 0; i-- )
{
BGRA_COLOR * c = (BGRA_COLOR *)bpSrc;
if(c->a!=255)
{
//c = 255;
DWORD * d= (DWORD*)bpSrc;
*d= color.ToCOLORREF();
c ->a= 255;
}
bpSrc += 4;
}
source.UnlockBits( &bdSrc );
}
示例5: getImagePropertiesHelper
static void getImagePropertiesHelper(vl::ImageShape & shape, Gdiplus::Bitmap & bitmap)
{
bool grayscale = (bitmap.GetFlags() & ImageFlagsColorSpaceGRAY) ;
shape.width = bitmap.GetWidth() ;
shape.height = bitmap.GetHeight() ;
shape.depth = grayscale ? 1 : 3 ;
}
示例6: GetIconicRepresentation
HBITMAP TaskbarWnd::GetIconicRepresentation(int nWidth, int nHeight, int scale )
{
HRESULT hr = E_FAIL;
Gdiplus::Bitmap* src = Gdiplus::Bitmap::FromHBITMAP( hbm_cached_,0);
// scale
Gdiplus::Bitmap dest( nWidth, nHeight, PixelFormat32bppARGB);
{
Gdiplus::RectF rDest(0,0,(Gdiplus::REAL)nWidth, (Gdiplus::REAL)nHeight );
Gdiplus::Graphics gScale( &dest );
if ( scale != 1 )
{
nWidth = std::min(nWidth*scale, (int)src->GetWidth());
nHeight = std::min(nHeight*scale, (int)src->GetHeight());
}
gScale.DrawImage( src, rDest,0,0,(Gdiplus::REAL)nWidth,(Gdiplus::REAL)nHeight, Gdiplus::UnitPixel, NULL, NULL, NULL );
}
delete src;
// retval and cleanup
HBITMAP hBitmap = 0;
dest.GetHBITMAP(Gdiplus::Color::Black, &hBitmap);
return hBitmap;
}
示例7: LoadTexture
void GDIPlus::LoadTexture( gwen::Texture* pTexture )
{
Gdiplus::Bitmap* pImage = new Gdiplus::Bitmap( pTexture->name.GetUnicode().c_str() );
pTexture->data = pImage;
pTexture->width = pImage->GetWidth();
pTexture->height = pImage->GetHeight();
}
示例8: MakeIcon
void MakeIcon(HICON icon, char* path) {
Gdiplus::Bitmap* bitmap = Gdiplus::Bitmap::FromFile(ToWChar(path));
if (bitmap->GetWidth()) {
bitmap->GetHICON(&icon);
delete bitmap;
}
}
示例9: get_img_size
void gdiplus_container::get_img_size( litehtml::uint_ptr img, litehtml::size& sz )
{
Gdiplus::Bitmap* bmp = (Gdiplus::Bitmap*) img;
if(bmp)
{
sz.width = bmp->GetWidth();
sz.height = bmp->GetHeight();
}
}
示例10: ExtractBitmap
Bitmap CanvasGdiplus::ExtractBitmap() const
{
DCHECK(!mem_bitmap_.IsNull());
// 生成一个位图, 绘制画布内容到其中并返回.
Gdiplus::Bitmap* bitmap = mem_bitmap_.GetNativeBitmap();
Gdiplus::Rect rc_bitmap(0, 0, bitmap->GetWidth(), bitmap->GetHeight());
return Bitmap(bitmap->Clone(rc_bitmap, bitmap->GetPixelFormat()));
}
示例11: OnFileNameChange
//-------------------------------------------------------------------------------------
void DlgOpenImage::OnFileNameChange()
{
m_thumb.ApplyEffect (FCEffectFillColor(FCColor(255,255,255))) ;
CString szFile = GetPathName() ;
FCImageProperty prop ;
CSize sizeImage (0,0) ;
if (PathFileExists(szFile))
{
IMAGE_TYPE imgType = FCImageCodecFactory::GetTypeByFileExt(szFile) ;
if ( (imgType == IMG_JPG) ||
(imgType == IMG_BMP) ||
(imgType == IMG_PNG) ||
(imgType == IMG_TIF) ||
(imgType == IMG_GIF) )
{
Gdiplus::Bitmap bmp (szFile) ;
if (bmp.GetLastStatus() == Gdiplus::Ok)
{
sizeImage = CSize (bmp.GetWidth(), bmp.GetHeight()) ;
FCImageCodec_Gdiplus::GetPropertyFromBitmap(bmp, prop) ;
// calculate thumb size
CRect rc (0, 0, m_thumb.Width(), m_thumb.Height()) ;
rc = FCObjGraph::CalcFitWindowSize (sizeImage, rc) ;
FCImageDrawDC memDC (m_thumb) ;
Gdiplus::Graphics(memDC).DrawImage (&bmp, rc.left, rc.top, rc.Width(), rc.Height()) ;
}
}
}
// update size
CString s ;
if (sizeImage.cx && sizeImage.cy)
{
s.Format(L"%d x %d", sizeImage.cx, sizeImage.cy) ;
s = L"Size :" + s ;
}
SetDlgItemText(IDC_SIZE_VALUE, s) ;
// update date
s = L"" ;
if (prop.m_ExifDTOrig.length())
{
s = L"Date :" + CString(prop.m_ExifDTOrig.c_str()) ;
}
SetDlgItemText(IDC_DATE_VALUE, s) ;
m_ctrl.Invalidate() ;
}
示例12: read
view::pixel_t* read(wchar_t *filename){
Gdiplus::Bitmap *bmp = Gdiplus::Bitmap::FromFile(filename);
if (bmp->GetLastStatus() != Gdiplus::Ok) return 0;
Gdiplus::Rect r;
r.X = 0;
r.Y = 0;
r.Width = bmp->GetWidth();
r.Height = bmp->GetHeight();
Gdiplus::BitmapData data;
bmp->LockBits(&r, Gdiplus::ImageLockModeRead, PixelFormat32bppARGB, &data);
return (view::pixel_t*)data.Scan0;
}
示例13: CLOG
Meter::Meter(std::wstring bitmapName, int x, int y, int units) :
_value(0.0f),
_drawnValue(-1.0f),
_units(units),
_drawnUnits(-1) {
_rect.X = x;
_rect.Y = y;
Gdiplus::Bitmap *bmp = Gdiplus::Bitmap::FromFile(
bitmapName.c_str(), false);
CLOG(L"Loading meter bitmap: %s\nStatus: %d",
bitmapName.c_str(), bmp->GetLastStatus());
_bitmap = bmp;
_rect.Width = bmp->GetWidth();
_rect.Height = bmp->GetHeight();
}
示例14: GetCharMaxX
int DxFont::GetCharMaxX(Gdiplus::Bitmap & charBitmap)
{
int width = charBitmap.GetWidth( );
int height = charBitmap.GetHeight( );
for(int x = width - 1; x >= 0; --x )
{
for(int y = 0; y < height; ++y)
{
Gdiplus::Color color;
charBitmap.GetPixel(x, y, &color);
if( color.GetAlpha() > 0)
return x;
}
}
return width - 1;
}
示例15: GetCharMaxX
//---------------------------------------------------------------------------
int GetCharMaxX(Gdiplus::Bitmap& charBitmap)
{
using namespace Gdiplus;
int width = charBitmap.GetWidth();
int height = charBitmap.GetHeight();
for(int x = width-1; x >= 0; --x)
{
for(int y = 0; y < height; ++y)
{
Color color;
charBitmap.GetPixel(x, y, &color);
if(color.GetAlpha() > 0)
{
return x;
}
}
}
return width-1;
}