本文整理汇总了C++中gdiplus::Color::GetA方法的典型用法代码示例。如果您正苦于以下问题:C++ Color::GetA方法的具体用法?C++ Color::GetA怎么用?C++ Color::GetA使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gdiplus::Color
的用法示例。
在下文中一共展示了Color::GetA方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ColorsEqual
bool ColorsEqual(Gdiplus::Color a, Gdiplus::Color b)
{
return a.GetR() == b.GetR() &&
a.GetG() == b.GetG() &&
a.GetB() == b.GetB() &&
a.GetA() == b.GetA();
}
示例2: Extrude
void OutlineText::Extrude(
Gdiplus::Color color,
int nThickness,
Gdiplus::Point ptOffset)
{
ExtrudeStrategy* pStrat = new ExtrudeStrategy();
pStrat->Init(Gdiplus::Color(0,0,0,0),color,nThickness,ptOffset.X,ptOffset.Y);
m_clrShadow = color;
if(m_pFontBodyShadow)
delete m_pFontBodyShadow;
ExtrudeStrategy* pFontBodyShadow = new ExtrudeStrategy();
pFontBodyShadow->Init(Gdiplus::Color(color.GetA(),255,255),Gdiplus::Color(0,0,0,0),0,ptOffset.X,ptOffset.Y);
m_pFontBodyShadow = pFontBodyShadow;
if(m_pShadowStrategy)
delete m_pShadowStrategy;
m_ptShadowOffset = ptOffset;
m_pShadowStrategy = pStrat;
m_bExtrudeShadow = true;
m_bDiffuseShadow = false;
m_nShadowThickness = nThickness;
}
示例3: PixelColour
Gwen::Color GDIPlus::PixelColour( Gwen::Texture* pTexture, unsigned int x, unsigned int y, const Gwen::Color& col_default )
{
Gdiplus::Bitmap* pImage = (Gdiplus::Bitmap*) pTexture->data;
if ( !pImage ) return col_default;
Gdiplus::Color c;
pImage->GetPixel( x, y, &c );
return Gwen::Color( c.GetR(), c.GetG(), c.GetB(), c.GetA() );
}
示例4: LoadPixel
//===============================================
void LoadPixel(UINT ofs, BYTE* rgba)
//===============================================
{
// get pixel of current image by offset ofs
UINT x,y;
Gdiplus::Color col;
PixelToCoord(ofs, &x, &y);
img->GetPixel(x,y, &col);
rgba[0] = col.GetR();
rgba[1] = col.GetG();
rgba[2] = col.GetB();
rgba[3] = col.GetA();
}
示例5: Init
void CSurface::Init(char* filename)
{
Gdiplus::GdiplusStartupInput startupInput;
ULONG_PTR token;
GdiplusStartup(&token, &startupInput, NULL);
int len = strlen(filename);
wchar_t* temp = new wchar_t[len + 1];
for (int i = 0; i < len; i++)
{
temp[i] = filename[i];
}
temp[len] = '\0';
Gdiplus::Bitmap bitmap(temp);
Gdiplus::Color pixel;
if (bitmap.GetWidth() <= 0)
return;
if (bitmap.GetHeight() <= 0)
return;
m_width = bitmap.GetWidth();
m_height = bitmap.GetHeight();
m_pPixels = new CVector4[m_width * m_height];
for (int x = 0; x < m_width; x++)
{
for (int y = 0; y < m_height; y++)
{
bitmap.GetPixel(x, y, &pixel);
m_pPixels[x + y * m_width] = CVector4(pixel.GetR(), pixel.GetG(), pixel.GetB(), pixel.GetA());
}
}
if (!m_pPixels)
return;
STRING::Copy(m_pFilename, filename);
}
示例6: Load
//----------------------------------------------------------------------------------
//
//----------------------------------------------------------------------------------
bool PngTextureLoader::Load(void* data, int32_t size, bool rev)
{
#if __PNG_DDI
auto global = GlobalAlloc(GMEM_MOVEABLE,size);
auto buf = GlobalLock(global);
CopyMemory(buf, data, size);
GlobalUnlock(global);
LPSTREAM stream = NULL;
CreateStreamOnHGlobal( global, false, &stream);
Gdiplus::Bitmap* bmp = Gdiplus::Bitmap::FromStream(stream);
ES_SAFE_RELEASE(stream);
GlobalFree(global);
if( bmp != NULL && bmp->GetLastStatus() == Gdiplus::Ok )
{
textureWidth = bmp->GetWidth();
textureHeight = bmp->GetHeight();
textureData.resize(textureWidth * textureHeight * 4);
if(rev)
{
for(auto y = 0; y < textureHeight; y++ )
{
for(auto x = 0; x < textureWidth; x++ )
{
Gdiplus::Color color;
bmp->GetPixel(x, textureHeight - y - 1, &color);
textureData[(x + y * textureWidth) * 4 + 0] = color.GetR();
textureData[(x + y * textureWidth) * 4 + 1] = color.GetG();
textureData[(x + y * textureWidth) * 4 + 2] = color.GetB();
textureData[(x + y * textureWidth) * 4 + 3] = color.GetA();
}
}
}
else
{
for(auto y = 0; y < textureHeight; y++ )
{
for(auto x = 0; x < textureWidth; x++ )
{
Gdiplus::Color color;
bmp->GetPixel(x, y, &color);
textureData[(x + y * textureWidth) * 4 + 0] = color.GetR();
textureData[(x + y * textureWidth) * 4 + 1] = color.GetG();
textureData[(x + y * textureWidth) * 4 + 2] = color.GetB();
textureData[(x + y * textureWidth) * 4 + 3] = color.GetA();
}
}
}
return true;
}
else
{
ES_SAFE_DELETE(bmp);
return false;
}
#else
uint8_t* data_ = (uint8_t*) data;
/* pngアクセス構造体を作成 */
png_structp png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
/* リードコールバック関数指定 */
png_set_read_fn(png, &data_, &PngReadData);
/* png画像情報構造体を作成 */
png_infop png_info = png_create_info_struct(png);
/* エラーハンドリング */
if (setjmp(png_jmpbuf(png)))
{
png_destroy_read_struct(&png, &png_info, NULL);
return false;
}
/* IHDRチャンク情報を取得 */
png_read_info(png, png_info);
png_uint_32 width, height;
int bit_depth, color_type, interlace_type, comp_type, filter_type;
png_get_IHDR(png, png_info, &width, &height, &bit_depth, &color_type, &interlace_type,
&comp_type, &filter_type);
/* RGBA8888フォーマットに変換する */
if (bit_depth < 8)
{
png_set_packing(png);
}
else if (bit_depth == 16)
{
png_set_strip_16(png);
}
uint32_t pixelBytes = 4;
//.........这里部分代码省略.........
示例7: myToString
inline std::string myToString(const Gdiplus::Color& value)
{
char buffer[30];
sprintf(buffer,"rgba(%d,%d,%d,%1.4f)", (int)value.GetR(), (int)value.GetG(), (int)value.GetB(), (float)(value.GetA()/255.0));
return buffer;
}
示例8: rc
void CSkinButton2::DrawFrame(Gdiplus::Graphics& gdi,CRect& rect)
{
if( m_enmuDrawType == NO_FRAME )
{
Gdiplus::Pen pen1( m_colFrame1 );
gdi.DrawLine( &pen1, rect.left+1, rect.top, rect.right-2, rect.top );
gdi.DrawLine( &pen1, rect.left+1, rect.bottom-1, rect.right-2, rect.bottom-1 );
gdi.DrawLine( &pen1, rect.left, rect.top+1, rect.left, rect.bottom-2 );
gdi.DrawLine( &pen1, rect.right-1, rect.top+1, rect.right-1, rect.bottom-2 );
Gdiplus::Color colpix;
pen1.GetColor( &colpix );
colpix.SetValue( Gdiplus::Color::MakeARGB(colpix.GetA()/2,colpix.GetR(),colpix.GetG(),colpix.GetB() ) );
Gdiplus::Pen penPix1( colpix );
gdi.DrawLine( &penPix1, rect.left, rect.top, rect.left+1, rect.top );
gdi.DrawLine( &penPix1, rect.right-1, rect.top, rect.right-1, rect.top+1 );
gdi.DrawLine( &penPix1, rect.right-1, rect.bottom-1, rect.right-2, rect.bottom-1 );
gdi.DrawLine( &penPix1, rect.left, rect.bottom-1, rect.left+1, rect.bottom-1 );
CRect rect2 = rect;
::InflateRect( &rect2, -1,-1 );
if( !m_bMouseDown )
{
Gdiplus::Pen pen2(m_colFrame2);
if( m_bMouseDown )
pen2.SetColor(m_colFrame1);
else
pen2.SetColor(m_colFrame2);
gdi.DrawLine( &pen2, rect2.left+1, rect2.top, rect2.right-2, rect2.top );
gdi.DrawLine( &pen2, rect2.left+1, rect2.bottom-1, rect2.right-2, rect2.bottom-1 );
gdi.DrawLine( &pen2, rect2.left, rect2.top+1, rect2.left, rect2.bottom-2 );
gdi.DrawLine( &pen2, rect2.right-1, rect2.top+1, rect2.right-1, rect2.bottom-2 );
Gdiplus::Color colpix2;
pen2.GetColor( &colpix2 );
colpix2.SetValue( Gdiplus::Color::MakeARGB(colpix2.GetA()/2,colpix2.GetR(),colpix2.GetG(),colpix2.GetB() ) );
Gdiplus::Pen penPix2( colpix2 );
gdi.DrawLine( &penPix2, rect2.left, rect2.top, rect2.left+1, rect2.top );
gdi.DrawLine( &penPix2, rect2.right-1, rect2.top, rect2.right-1, rect2.top+1 );
gdi.DrawLine( &penPix2, rect2.right-1, rect2.bottom-1, rect2.right-2, rect2.bottom-1 );
gdi.DrawLine( &penPix2, rect2.left, rect2.bottom-1, rect2.left+1, rect2.bottom-1 );
}
if( m_bMouseDown )
{
Gdiplus::RectF rc( rect2.left, rect2.top, rect2.Width(), rect2.Height()/3 );
Gdiplus::Color colBrush1,colBrush2;
colBrush1.SetValue( Gdiplus::Color::MakeARGB(15,1,1,1) );
colBrush2.SetValue( Gdiplus::Color::MakeARGB(0,1,1,1) );
LinearGradientBrush brush( rc, colBrush1, colBrush2,LinearGradientModeVertical );
gdi.FillRectangle( &brush, rc );
}
else
{
Gdiplus::RectF rc( rect2.left, rect2.top, rect2.Width(), rect2.Height()/2 );
rc.Inflate(-1,-1);
LinearGradientBrush brush( rc, m_colBrush1, m_colBrush2,LinearGradientModeVertical );
gdi.FillRectangle( &brush, rc );
}
return;
}
else if( m_enmuDrawType == NO_FRAME_SELECT )
{
Gdiplus::Pen pen1( m_colFrame1 );
gdi.DrawLine( &pen1, rect.left+1, rect.top, rect.right-2, rect.top );
gdi.DrawLine( &pen1, rect.left+1, rect.bottom-1, rect.right-2, rect.bottom-1 );
gdi.DrawLine( &pen1, rect.left, rect.top+1, rect.left, rect.bottom-2 );
gdi.DrawLine( &pen1, rect.right-1, rect.top+1, rect.right-1, rect.bottom-2 );
Gdiplus::Color colpix;
pen1.GetColor( &colpix );
colpix.SetValue( Gdiplus::Color::MakeARGB(colpix.GetA()/2,colpix.GetR(),colpix.GetG(),colpix.GetB() ) );
Gdiplus::Pen penPix1( colpix );
gdi.DrawLine( &penPix1, rect.left, rect.top, rect.left+1, rect.top );
gdi.DrawLine( &penPix1, rect.right-1, rect.top, rect.right-1, rect.top+1 );
gdi.DrawLine( &penPix1, rect.right-1, rect.bottom-1, rect.right-2, rect.bottom-1 );
gdi.DrawLine( &penPix1, rect.left, rect.bottom-1, rect.left+1, rect.bottom-1 );
CRect rect2 = rect;
::InflateRect( &rect2, -1,-1 );
if( !m_bMouseDown )
{
Gdiplus::Pen pen2(m_colFrame2);
if( m_bMouseDown )
pen2.SetColor(m_colFrame1);
else
pen2.SetColor(m_colFrame2);
gdi.DrawLine( &pen2, rect2.left+1, rect2.top, rect2.right-2, rect2.top );
gdi.DrawLine( &pen2, rect2.left+1, rect2.bottom-1, rect2.right-2, rect2.bottom-1 );
gdi.DrawLine( &pen2, rect2.left, rect2.top+1, rect2.left, rect2.bottom-2 );
gdi.DrawLine( &pen2, rect2.right-1, rect2.top+1, rect2.right-1, rect2.bottom-2 );
Gdiplus::Color colpix2;
pen2.GetColor( &colpix2 );
colpix2.SetValue( Gdiplus::Color::MakeARGB(colpix2.GetA()/2,colpix2.GetR(),colpix2.GetG(),colpix2.GetB() ) );
Gdiplus::Pen penPix2( colpix2 );
//.........这里部分代码省略.........
示例9: SavePngFile
BOOL SavePngFile(HICON hIcon, LPCSTR strPngFile,int iOutWith = -1,int iOutHeight = -1)
{
if (hIcon == NULL)
return FALSE;
ICONINFO icInfo = { 0 };
if (!::GetIconInfo(hIcon, &icInfo))
return FALSE;
BITMAP bitmap;
GetObject(icInfo.hbmColor, sizeof(BITMAP), &bitmap);
Bitmap* pBitmap = NULL;
Bitmap* pWrapBitmap = NULL;
if (bitmap.bmBitsPixel != 32)
{
pBitmap = Bitmap::FromHICON(hIcon);
}
else
{
pWrapBitmap = Bitmap::FromHBITMAP(icInfo.hbmColor, NULL);
BitmapData bitmapData;
Rect rcImage(0,0, pWrapBitmap->GetWidth(), pWrapBitmap->GetHeight());
pWrapBitmap->LockBits(&rcImage, ImageLockModeRead, pWrapBitmap->GetPixelFormat(), &bitmapData);
pBitmap = new Bitmap(bitmapData.Width, bitmapData.Height, bitmapData.Stride,
PixelFormat32bppARGB, (BYTE*)bitmapData.Scan0);
pWrapBitmap->UnlockBits(&bitmapData);
Gdiplus::Color Bmpcolor;
BOOL BmpcolorTag=TRUE;
for (UINT bmpx=0;bmpx<pBitmap->GetWidth();bmpx++)
{
for (UINT bmpy=0;bmpy<pBitmap->GetHeight();bmpy++)
{
pBitmap->GetPixel(bmpx,bmpy,&Bmpcolor);
if(Bmpcolor.GetA()!=0)
{
BmpcolorTag=FALSE;
break;
}
}
if (BmpcolorTag==FALSE)
break;
}
if (BmpcolorTag==TRUE)
{
delete pWrapBitmap;
pWrapBitmap = NULL;
delete pBitmap;
pBitmap = NULL;
pBitmap = Gdiplus::Bitmap::FromHICON(hIcon);
}
}
DeleteObject(icInfo.hbmColor);
DeleteObject(icInfo.hbmMask);
static bool GetPngCode = false;
static CLSID pngid;
if (!GetPngCode)
{
GetPngCode = true;
GetEncoderClsid(L"image/png", &pngid);
}
if (iOutWith !=-1 && iOutHeight!=-1)
{
Bitmap *pStretched = StretchBitmap(pBitmap,128,128);
if (pStretched)
{
delete pBitmap;
pBitmap = pStretched;
}
}
_bstr_t bstr(strPngFile);
wstring wstrPng = (WCHAR*)bstr;
Gdiplus::Status s = pBitmap->Save(wstrPng.c_str(),&pngid,NULL);
delete pBitmap;
if (pWrapBitmap)
delete pWrapBitmap;
DeleteObject(icInfo.hbmColor);
DeleteObject(icInfo.hbmMask);
if (s==Gdiplus::Ok)
return TRUE;
return FALSE;
}
示例10: GetColor
Color Pen::GetColor() const {
Gdiplus::Pen* gdiPen = reinterpret_cast<Gdiplus::Pen*>(_private);
Gdiplus::Color gdiColor;
gdiPen->GetColor(&gdiColor);
return Color(gdiColor.GetA(), gdiColor.GetR(), gdiColor.GetG(), gdiColor.GetB());
}