本文整理汇总了C++中gdiplus::Color::GetR方法的典型用法代码示例。如果您正苦于以下问题:C++ Color::GetR方法的具体用法?C++ Color::GetR怎么用?C++ Color::GetR使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gdiplus::Color
的用法示例。
在下文中一共展示了Color::GetR方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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() );
}
示例3: 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();
}
示例4: drawGridLine
void PointGridIndex::drawGridLine(Gdiplus::Color color, MapDrawer& md)
{
//////////////////////////////////////////////////////////////////////////
///在图片上画出网格线
//////////////////////////////////////////////////////////////////////////
Gdiplus::ARGB argb = Gdiplus::Color::MakeARGB(90, color.GetR(), color.GetG(), color.GetB());
color.SetValue(argb);
double delta = 0.0000001;
for (int i = 0; i < gridHeight; i++)
{
double lat = area->minLat + gridSizeDeg * i;
md.drawLine(color, lat, area->minLon + delta, lat, area->maxLon - delta);
}
for (int i = 0; i < gridWidth; i++)
{
double lon = area->minLon + gridSizeDeg * i;
md.drawLine(color, area->minLat + delta, lon, area->maxLat - delta, lon);
}
}
示例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: FillPolygonTexturedNormalMapped
//.........这里部分代码省略.........
// Work out the lighting colour of the current pixel.
//float lightR = (_scanlines[y].redStart + ((redColorDiff / diff) * offset)) / 180.0f;
//float lightG = (_scanlines[y].greenStart + ((greenColorDiff / diff) * offset)) / 180.0f;
//float lightB = (_scanlines[y].blueStart + ((blueColorDiff / diff) * offset)) / 180.0f;
// Using the UV coordinate work out which pixel in the texture to use to draw this pixel.
int pixelIndex = (int)vCoord * textureWidth + (int)uCoord;
if (pixelIndex >= textureWidth * textureWidth || pixelIndex < 0)
{
pixelIndex = (textureWidth * textureWidth) - 1;
}
int paletteOffset = texture[pixelIndex];
if (paletteOffset >= 255)
paletteOffset = 255;
Gdiplus::Color textureColor = palette[paletteOffset];
// Work out the pixel colour of the normalmap.
pixelIndex = (int)vCoord * textureWidth + (int)uCoord;
if (pixelIndex >= textureWidth * textureWidth || pixelIndex < 0)
{
pixelIndex = (textureWidth * textureWidth) - 1;
}
paletteOffset = normalTexture[pixelIndex];
if (paletteOffset >= 255)
paletteOffset = 255;
Gdiplus::Color normalTextureColor = normalPalette[paletteOffset];
// Calculate normal lighting for the pixel.
Vector3D heightMapVector = Vector3D(normalTextureColor.GetR() / 180.0f, normalTextureColor.GetG() / 180.0f, normalTextureColor.GetB() / 180.0f);
heightMapVector = Vector3D((heightMapVector.GetX() - 0.5f) * 2.0f, (heightMapVector.GetY() - 0.5f) * 2.0f, (heightMapVector.GetZ() - 0.5f) * 2.0f);
// Work out he pixels normal and position.
Vector3D pixelNormal = Vector3D(xNormal, yNormal, zNormal);//;Vector3D(heightMapVector.GetX(), heightMapVector.GetY(), heightMapVector.GetZ());
Vertex pixelPosition = Vertex(pixelX, pixelY, pixelZ, 1, Gdiplus::Color::White, Vector3D(0, 0, 0), 0);
heightMapVector = Vector3D((pixelNormal.GetX() * heightMapVector.GetX()) ,
(pixelNormal.GetY() * heightMapVector.GetY()) ,
(pixelNormal.GetZ() * heightMapVector.GetZ()) );
// Calculate the sum dot product of all lighting vectors for this pixel and divide by the number
// of lights.
float lightDot = 0.0f;
int count = 0;
for (unsigned int j = 0; j < pointLights.size(); j++)
{
PointLight* light = pointLights[j];
if (light->GetEnabled() == false)
continue;
// Work out vector to light source.
Vector3D lightVector = Vertex::GetVector(pixelPosition, light->GetPosition());
float distance = lightVector.GetLength();
lightVector.Normalize();
// Work out dot product.
lightDot += Vector3D::DotProduct(heightMapVector, lightVector);
count++;
}
for (unsigned int j = 0; j < directionalLights.size(); j++)
{
DirectionalLight* light = directionalLights[j];
示例9: FillPolygonTextured
// Fills a polygon using a texture and gouraud shading given 3 points and a color.
void Rasterizer::FillPolygonTextured(Vertex v1, Vertex v2, Vertex v3, Gdiplus::Color color, Model3D& model)
{
ScanLine* _scanlines = new ScanLine[_height];
BYTE* texture;
Gdiplus::Color* palette;
int textureWidth;
// Get the texture properties of the model.
model.GetTexture(&texture, &palette, &textureWidth);
// Set the scanlines to very high and very low values so
// they will be set on the first set of interpolation.
for (unsigned int i = 0; i < _height; i++)
{
_scanlines[i].xStart = 99999;
_scanlines[i].xEnd = -99999;
}
// Interpolates between each of the vertexs of the polygon and sets the start
// and end values for each of the scanlines it comes in contact with.
InterpolateScanline(_scanlines, v1, v2);
InterpolateScanline(_scanlines, v2, v3);
InterpolateScanline(_scanlines, v3, v1);
// Go through each scanline and each pixel in the scanline and
// sets its color.
for (unsigned int y = 0; y < _height; y++)
{
// Work out the color and UV differences between the start and end of the scanline.
float redColorDiff = (_scanlines[y].redEnd - _scanlines[y].redStart);
float greenColorDiff = (_scanlines[y].greenEnd - _scanlines[y].greenStart);
float blueColorDiff = (_scanlines[y].blueEnd - _scanlines[y].blueStart);
float uCoordDiff = _scanlines[y].uEnd - _scanlines[y].uStart;
float vCoordDiff = _scanlines[y].vEnd - _scanlines[y].vStart;
float zCoordDiff = _scanlines[y].zEnd - _scanlines[y].zStart;
float diff = (_scanlines[y].xEnd - _scanlines[y].xStart) + 1;
for (int x = (int)_scanlines[y].xStart; x <= (int)_scanlines[y].xEnd; x++)
{
if (x < 0 || x >= (int)_width)
continue;
int offset = (int)(x - _scanlines[y].xStart);
// Work out the UV coordinate of the current pixel.
float uCoord = _scanlines[y].uStart + ((uCoordDiff / diff) * offset);
float vCoord = _scanlines[y].vStart + ((vCoordDiff / diff) * offset);
float zCoord = _scanlines[y].zStart + ((zCoordDiff / diff) * offset);
uCoord /= zCoord;
vCoord /= zCoord;
// Work out the lighting colour of the current pixel.
float lightR = (_scanlines[y].redStart + ((redColorDiff / diff) * offset)) / 180.0f;
float lightG = (_scanlines[y].greenStart + ((greenColorDiff / diff) * offset)) / 180.0f;
float lightB = (_scanlines[y].blueStart + ((blueColorDiff / diff) * offset)) / 180.0f;
// Using the UV coordinate work out which pixel in the texture to use to draw this pixel.
int pixelIndex = (int)vCoord * textureWidth + (int)uCoord;
if (pixelIndex >= textureWidth * textureWidth || pixelIndex < 0)
{
pixelIndex = (textureWidth * textureWidth) - 1;
}
int paletteOffset = texture[pixelIndex];
if (paletteOffset >= 255)
paletteOffset = 255;
Gdiplus::Color textureColor = palette[paletteOffset];
// Apply the lighting value to the texture colour and use the result to set the colour of the current pixel.
int finalR = (int)max(0, min(255, textureColor.GetR() * lightR));
int finalG = (int)max(0, min(255, textureColor.GetG() * lightG));
int finalB = (int)max(0, min(255, textureColor.GetB() * lightB));
WritePixel(x, y, Gdiplus::Color(finalR, finalG, finalB));
}
}
// Dispose of dynamic objects.
delete[] _scanlines;
_polygonsRendered++;
}
示例10: 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 );
//.........这里部分代码省略.........
示例11: Draw
void SelectionHandler::Draw(CDC& offscreenDC)
{
if (m_selectionState == selstateNoSelection) return;
COORD coordStart;
COORD coordEnd;
SHORT maxX = (m_consoleParams->dwBufferColumns > 0) ?
static_cast<SHORT>(m_consoleParams->dwBufferColumns - 1) :
static_cast<SHORT>(m_consoleParams->dwColumns - 1);
GetSelectionCoordinates(coordStart, coordEnd);
SMALL_RECT& srWindow = m_consoleInfo->csbi.srWindow;
if( coordEnd.Y < srWindow.Top ||
coordStart.Y > srWindow.Bottom ) return;
INT nXStart = (static_cast<INT>(coordStart.X) - static_cast<INT>(srWindow.Left)) * m_nCharWidth + m_nVInsideBorder;
INT nYStart = (static_cast<INT>(coordStart.Y) - static_cast<INT>(srWindow.Top) ) * m_nCharHeight + m_nHInsideBorder;
INT nXEnd = (static_cast<INT>( coordEnd.X) - static_cast<INT>(srWindow.Left)) * m_nCharWidth + m_nVInsideBorder;
INT nYEnd = (static_cast<INT>( coordEnd.Y) - static_cast<INT>(srWindow.Top) ) * m_nCharHeight + m_nHInsideBorder;
INT nXmin = (static_cast<INT>(0) - static_cast<INT>(srWindow.Left)) * m_nCharWidth + m_nVInsideBorder;
INT nXmax = (static_cast<INT>(maxX) - static_cast<INT>(srWindow.Left)) * m_nCharWidth + m_nVInsideBorder;
Gdiplus::Graphics gr(offscreenDC);
Gdiplus::Color selectionColor;
selectionColor.SetFromCOLORREF(g_settingsHandler->GetAppearanceSettings().stylesSettings.crSelectionColor);
Gdiplus::Pen pen (selectionColor);
Gdiplus::SolidBrush brush(Gdiplus::Color(64, selectionColor.GetR(), selectionColor.GetG(), selectionColor.GetB()));
Gdiplus::GraphicsPath gp;
if( nYStart == nYEnd )
{
Gdiplus::Rect rect(
nXStart,
nYStart,
(nXEnd - nXStart) + m_nCharWidth,
m_nCharHeight);
gp.AddRectangle(rect);
}
else
{
/*
2_________3
0______| |
| 1 5___|
|____________| 4
7 6
*/
Gdiplus::Point points[8];
points[0].X = nXmin;
points[0].Y = nYStart + m_nCharHeight;
points[1].X = nXStart;
points[1].Y = points[0].Y;
points[2].X = points[1].X;
points[2].Y = nYStart;
points[3].X = nXmax + m_nCharWidth;
points[3].Y = points[2].Y;
points[4].X = points[3].X;
points[4].Y = nYEnd;
points[5].X = nXEnd + m_nCharWidth;
points[5].Y = points[4].Y;
points[6].X = points[5].X;
points[6].Y = nYEnd + m_nCharHeight;
points[7].X = points[0].X;
points[7].Y = points[6].Y;
gp.AddPolygon(points, 8);
}
gr.FillPath(&brush, &gp);
gr.DrawPath(&pen, &gp);
}
示例12: 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());
}