本文整理汇总了C++中gdiplus::Image::GetWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ Image::GetWidth方法的具体用法?C++ Image::GetWidth怎么用?C++ Image::GetWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gdiplus::Image
的用法示例。
在下文中一共展示了Image::GetWidth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ChangeSubPic
BOOL COBSButton::ChangeSubPic(STATE index, LPCTSTR lpszImage)
{
if (m_hWnd == NULL || lpszImage == NULL)
{
return FALSE;
}
Gdiplus::Image* pImage = Gdiplus::Image::FromFile(lpszImage);
if ((pImage == NULL) || (pImage->GetLastStatus() != Gdiplus::Ok))
{
if (pImage)
{
delete pImage;
pImage = NULL;
}
return FALSE;
}
int nPos = pImage->GetWidth()*index;//¼ÆËã4ÕÅͼƬÐèÒª¶àÉÙÏñËØ
Gdiplus::Graphics graph(m_hdcMemory);
graph.SetSmoothingMode(Gdiplus::SmoothingModeNone);
graph.DrawImage(pImage, nPos, 0, pImage->GetWidth(), pImage->GetHeight());
return TRUE;
}
示例2:
// description: load image from file using gdi+
NaImage * NaImage::Load(const wchar_t * filename)
{
NaImage *pImage = new NaImage;
HDC hDC = NaScreenModule::GetDesktopDC();
pImage->m_hMemoryDC = ::CreateCompatibleDC(hDC);
// initialize gdi+
Gdiplus::GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
// load image
Gdiplus::Image* pGdiImage = new Gdiplus::Image(filename);
// converting to bitmap
Gdiplus::Bitmap* pGdiBitmap = static_cast<Gdiplus::Bitmap*>(pGdiImage);
pGdiBitmap->GetHBITMAP(Gdiplus::Color(0, 0, 0), &pImage->m_hBitmap);
pImage->m_rc.left = 0;
pImage->m_rc.top = 0;
pImage->m_rc.right = pGdiImage->GetWidth();
pImage->m_rc.bottom = pGdiImage->GetHeight();
// shutdown gdi+
delete pGdiImage;
Gdiplus::GdiplusShutdown(gdiplusToken);
return pImage;
}
示例3: BlendSelSign
/**
Blend 'A''B''C''D' sign onto the image.
*/
static void BlendSelSign( Gdiplus::Graphics *g, const Gdiplus::RectF &render_rect, int sel )
{
CFileListManager &file_manager = GetInst( CFileListManager );
Gdiplus::Image *img = CreateImgFromBuffer( file_manager.GetSelSign( sel ) );
Gdiplus::PointF render_pos = GetRandPosInULRect( img->GetWidth(), img->GetHeight(), render_rect );
img_alpha( g, img, render_pos.X, render_pos.Y, 255 );
delete img;
}
示例4: LoadImage
BOOL LoadImage(const HINSTANCE& inst, DWORD res, const TCHAR* name, IMGINFO* img_info, const HDC* mdc)
{
HRSRC src = FindResource(inst, MAKEINTRESOURCE(res), name);
if (src == NULL)
return FALSE;
DWORD len = SizeofResource(inst, src);
BYTE* byte = (BYTE*)LoadResource(inst, src);
if (byte == NULL)
return FALSE;
HGLOBAL global = GlobalAlloc(GMEM_FIXED, len);
BYTE* mem = (BYTE*)GlobalLock(global);
CopyMemory(mem, byte, len);
IStream* stream = NULL;
Gdiplus::Image* image = NULL;
HRESULT hr = CreateStreamOnHGlobal(mem, FALSE, &stream);
if (SUCCEEDED(hr))
{
image = Gdiplus::Image::FromStream(stream);
img_info->hdc = CreateCompatibleDC(*mdc);
HBITMAP hbitmap = CreateCompatibleBitmap(*mdc, image->GetWidth(), image->GetHeight());
SelectObject(img_info->hdc, hbitmap);
Gdiplus::Graphics graphics(img_info->hdc);
Gdiplus::Rect rect;
rect.X = 0.0F;
rect.Y = 0.0F;
rect.Width = image->GetWidth();
rect.Height = image->GetHeight();
Gdiplus::Status s = graphics.DrawImage(image, rect);
DeleteObject(hbitmap);
img_info->image = image;
}
GlobalUnlock(mem);
SAFE_RELEASE(stream);
FreeResource(byte);
if (SUCCEEDED(hr))
return TRUE;
else
return FALSE;
}
示例5: BrouseFile
// ôóíêöèÿ îòêðûòèÿ ôàéëà äëÿ ïðîñìîòðà ñ âõîäÿùèì ïàðàìåòðîì - èìåíåì îòêðûâàåìîãî ãðàôè÷åñêîãî ôàéëà
void BrouseFile(AnsiString FN)
{ float ho=0;
float wo;
if (FN!=""){//åñëè èìÿ ôàéëà óêàçàíî òî âûïîëíèòü äåéñòâèÿ
Form1->Image1->Align=alClient;//ðàçâîðà÷èâàåì îáëàñòü ïðîñìîòðà íà âñþ äîñòóïíþ ïëîùàäü
Form1->Image1->Picture->Assign(0);//î÷èùàåì îáëàñòü ïðîñìîòðà
WCHAR buff[10001];
Graphics::TBitmap *Buf = new Graphics::TBitmap();//ñîçäàåì îáúåêò êëàññà TBitmap
Gdiplus::Image *image =new Gdiplus::Image (FN.WideChar(buff,10000)); //ñîçäàåì îáúåêò êëàññà Gdiplus::Image è çàãðóæàåì â íåãî èçîáðàæåíèå èç âûáðàííîãî ôàéëà
Buf->Width=image->GetWidth();//óêàçûâàåì øèðèíó è âûñîòó èçîáðàæåíèÿ
Buf->Height=image->GetHeight();
Gdiplus::Graphics graphics(Buf->Canvas->Handle);//ïåðåäàåì óêàçàòåëü íà îáúåêò Buf
graphics.DrawImage(image, 0, 0, image->GetWidth(), image->GetHeight());
//ïðîðèñîâûâàåì âçÿòîå èç ôàéëà èçîáðàæåíèå â îáúåêòå Buf
Form1->Image1->Picture->Assign(Buf);//âûâîäì ïðîðèñîâàííîå èçîáðàæåíèå â îáëàñòü ïðîñìîòðà
Form1->ScrollBox1->Refresh();//îáíîâëÿåì ðàçìåðíîñòü îáëàñòè ïðîñìîòðà
z_min=1;//èíèöèàëèçèðåì ïåðåìåííûå ìàñøàáèðîâàíèÿ
z_max=1;
Form1->StatusBar1->Panels->Items[1]->Text="Ôàéë - "+Form1->FileListBox1->Items->Strings[Form1->FileListBox1->ItemIndex];//âûâîäèì ñëóæåáíóþ èíôîðìàöèþ
Form1->StatusBar1->Panels->Items[2]->Text="Ðàçìåð - "+IntToStr(image->GetWidth())+"x"+IntToStr(image->GetHeight());
//
B->Assign(0);//î÷èùàåì ðåçåðâíûé îáúåêò êëàññà TBitmap
B->Width=Form1->Image1->Picture->Bitmap->Width;//çàäàåì ðàçìåðû ðåçåðâíîãî îáúåêòà
B->Height=Form1->Image1->Picture->Bitmap->Height;
B->Canvas->Draw(0,0,Form1->Image1->Picture->Bitmap);//ïðîðèñîâûâàåì èçîáðàæåíèå â ðåçåðâíîì îáúåêòå èç îáëàñòè ïðîñìîòðà
//åñëè êàðòèíêà èçíà÷àëüíî áîëüøå îáëàñòè ïðîñìîòðà
//òî îíà áóäåò àâòîìàòè÷åñêè óìåíüøåíà
//äàëåå îïðåäåëÿåì êîýô. óìåíüøåíèÿ
if ((B->Height>Form1->Image1->Height)||(B->Width>Form1->Image1->Width)) //åñëè ïàðìåòðû êàðòèíêè ïðåâûøàþò ïàðàìåòðû îáëàñòè
{
ho=float(Form1->Image1->Height)/float(B->Height); //âû÷èñëÿåì ñîîòíîøåíèÿ âåëè÷èí
wo=float(Form1->Image1->Width)/float(B->Width);
if (ho>wo) //îïåðåäåëÿåì áîëüøóþ èç âåëè÷èí, ÷òîáû èçîáðàæåíèå ïîìåñòèëîñü â îáëàñòè ïðîñìîòðà
{z_min=1+ho;} //óñòàíàâëèâàåì êîýô.
else {z_min=1+wo;}
}
delete image;//î÷èùàåì ïàìÿòü
delete Buf;
}
}
示例6: GetImageSize
cgSize cgGdiplusRender::GetImageSize( cgID image )
{
cgSize size;
Gdiplus::Image* pkImage = m_kImageStorage.Find(image);
if (pkImage)
{
size.w = pkImage->GetWidth();
size.h = pkImage->GetHeight();
}
return size;
}
示例7: GenSmallImage
/**
generate some small images and render them on the backgroun.
*/
static void GenSmallImage( int img_count, Gdiplus::Graphics *g, const Gdiplus::RectF &render_rect, int sel )
{
#define RAND_ALPHA ( 100 + random( 55 ) )
if( img_count < 1 )
{
return;
}
CFileListManager &file_manager = GetInst( CFileListManager );
// render without alpha value
Gdiplus::Image *img = CreateImgFromBuffer( file_manager.GetRandSmall() );
Gdiplus::PointF render_pos = GetRandPosInULRect( img->GetWidth(), img->GetHeight(), render_rect );
Gdiplus::RectF img_rect( render_pos.X, render_pos.Y, (float)img->GetWidth(), (float)img->GetHeight() );
img_alpha( g, img, render_pos.X, render_pos.Y, img_count == 1 ? 255 : RAND_ALPHA );
delete img;
// render with random alpha value and random rotation degree
g->SetClip( img_rect );
for( int i = 1; i < img_count; ++ i )
{
img = CreateImgFromBuffer( file_manager.GetRandSmall() );
img_rotate( g, img, render_pos.X, render_pos.Y, img->GetWidth() / 2, img->GetHeight() / 2,
random( 360 ), // [0-360)
RAND_ALPHA ); // [100-155)
delete img;
}
g->ResetClip();
// blend a 'X' sign onto the picture if it's not the answer
if( img_count > 1 )
{
//BlendXSign( g, img_rect );
}
// blend 'A''B''C''D' sign.
BlendSelSign( g, img_rect, sel );
}
示例8: SetAspectRatio
void SetAspectRatio(Gdiplus::Image &image, RECT &rc)
{
double dWidth = (rc.right - rc.left);
double dHeight = (rc.bottom - rc.top);
double dAspectRatio = dWidth / dHeight;
double dImageWidth = image.GetWidth();
double dImageHeight = image.GetHeight();
double dImageAspectRatio = dImageWidth / dImageHeight;
if (dImageAspectRatio > dAspectRatio) {
double nNewHeight = (dWidth / dImageWidth*dImageHeight);
double nCenteringFactor = (dHeight - nNewHeight) / 2;
SetRect(&rc, 0, (int)nCenteringFactor, (int)dWidth, (int)(nNewHeight + nCenteringFactor));
} else if (dImageAspectRatio < dAspectRatio) {
double nNewWidth = (dHeight / dImageHeight*dImageWidth);
double nCenteringFactor = (dWidth - nNewWidth) / 2;
SetRect(&rc, (int)nCenteringFactor, 0, (int)(nNewWidth + nCenteringFactor), (int)(dHeight));
}
}
示例9: Create
BOOL COBSButton::Create(LPCTSTR lpszCaption, const RECT& rect, HWND hParentWnd, \
UINT nID, LPCTSTR lpszImage,int nSubPic)
{
if (m_hWnd)
return FALSE;
if (nSubPic>4||nSubPic<=0)
{
return FALSE;
}
m_hWnd = CreateWindow(TEXT("BUTTON"), lpszCaption, \
WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_OWNERDRAW, \
rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, \
hParentWnd, (HMENU)nID, NULL, NULL);
if (NULL == m_hWnd)
{
goto CREATE_FAIL;
}
SendMessage(m_hWnd, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), TRUE);
m_OldProc = (WNDPROC)SetWindowLong(m_hWnd, GWLP_WNDPROC /*GWL_WNDPROC*/, (LONG)ButtonProc);
SetWindowLong(m_hWnd, GWLP_USERDATA, (LONG)this);
m_hFont = CreateFont(16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, DEFAULT_CHARSET, \
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, TEXT("Arial"));
Gdiplus::Image* pImage = NULL;
//¼ÓÔØͼƬ
if (lpszImage != NULL)
{
pImage = Gdiplus::Image::FromFile(lpszImage);
if ((pImage == NULL) || (pImage->GetLastStatus() != Gdiplus::Ok))
{
if (pImage)
{
delete pImage;
pImage = NULL;
}
return FALSE;
}
RECT windowRect;
GetWindowRect(m_hWnd, &windowRect);
SIZE sizeWindow;
sizeWindow.cx = (pImage->GetWidth() / nSubPic)*4;//¼ÆËã4ÕÅͼƬÐèÒª¶àÉÙÏñËØ
sizeWindow.cy = pImage->GetHeight();
HDC hDC = GetDC(m_hWnd);
m_hdcMemory = CreateCompatibleDC(hDC);
if (m_hdcMemory == NULL) return FALSE;
m_hFourStateBitmap = CreateCompatibleBitmap(hDC, sizeWindow.cx, sizeWindow.cy);
if (m_hFourStateBitmap == NULL) return FALSE;
m_hOldBmp = (HBITMAP)::SelectObject(m_hdcMemory, m_hFourStateBitmap);
if (m_hOldBmp == NULL) return FALSE;
Gdiplus::Graphics graph(m_hdcMemory);
graph.SetSmoothingMode(Gdiplus::SmoothingModeNone);
graph.DrawImage(pImage, 0, 0, sizeWindow.cx, sizeWindow.cy);
if (NULL == m_hFourStateBitmap)
{
goto CREATE_FAIL;
}
}
if (pImage)
{
delete pImage;
pImage = NULL;
}
return TRUE;
CREATE_FAIL:
if (m_hFourStateBitmap)
{
DeleteObject(m_hFourStateBitmap);
}
return FALSE;
}
示例10: GetWidth
int Image::GetWidth() {
Gdiplus::Image* gdiImage = reinterpret_cast<Gdiplus::Image*>(_private);
return gdiImage->GetWidth();
}
示例11: assert
static Image *ReadEMFImage(const ImageInfo *image_info,
ExceptionInfo *exception)
{
Gdiplus::Bitmap
*bitmap;
Gdiplus::BitmapData
bitmap_data;
Gdiplus::GdiplusStartupInput
startup_input;
Gdiplus::Graphics
*graphics;
Gdiplus::Image
*source;
Gdiplus::Rect
rect;
GeometryInfo
geometry_info;
Image
*image;
MagickStatusType
flags;
register Quantum
*q;
register ssize_t
x;
ssize_t
y;
ULONG_PTR
token;
unsigned char
*p;
wchar_t
fileName[MagickPathExtent];
assert(image_info != (const ImageInfo *) NULL);
assert(image_info->signature == MagickSignature);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
image=AcquireImage(image_info,exception);
if (Gdiplus::GdiplusStartup(&token,&startup_input,NULL) !=
Gdiplus::Status::Ok)
ThrowReaderException(CoderError, "GdiplusStartupFailed");
MultiByteToWideChar(CP_UTF8,0,image->filename,-1,fileName,MagickPathExtent);
source=Gdiplus::Image::FromFile(fileName);
if (source == (Gdiplus::Image *) NULL)
{
Gdiplus::GdiplusShutdown(token);
ThrowReaderException(FileOpenError,"UnableToOpenFile");
}
image->resolution.x=source->GetHorizontalResolution();
image->resolution.y=source->GetVerticalResolution();
image->columns=(size_t) source->GetWidth();
image->rows=(size_t) source->GetHeight();
if (image_info->density != (char *) NULL)
{
flags=ParseGeometry(image_info->density,&geometry_info);
image->resolution.x=geometry_info.rho;
image->resolution.y=geometry_info.sigma;
if ((flags & SigmaValue) == 0)
image->resolution.y=image->resolution.x;
if ((image->resolution.x > 0.0) && (image->resolution.y > 0.0))
{
image->columns=(size_t) floor((Gdiplus::REAL) source->GetWidth() /
source->GetHorizontalResolution() * image->resolution.x + 0.5);
image->rows=(size_t)floor((Gdiplus::REAL) source->GetHeight() /
source->GetVerticalResolution() * image->resolution.y + 0.5);
}
}
bitmap=new Gdiplus::Bitmap((INT) image->columns,(INT) image->rows,
PixelFormat32bppARGB);
graphics=Gdiplus::Graphics::FromImage(bitmap);
graphics->SetInterpolationMode(Gdiplus::InterpolationModeHighQualityBicubic);
graphics->SetSmoothingMode(Gdiplus::SmoothingModeHighQuality);
graphics->SetTextRenderingHint(Gdiplus::TextRenderingHintClearTypeGridFit);
graphics->Clear(Gdiplus::Color((BYTE) ScaleQuantumToChar(
image->background_color.alpha),(BYTE) ScaleQuantumToChar(
image->background_color.red),(BYTE) ScaleQuantumToChar(
image->background_color.green),(BYTE) ScaleQuantumToChar(
image->background_color.blue)));
graphics->DrawImage(source,0,0,(INT) image->columns,(INT) image->rows);
delete graphics;
//.........这里部分代码省略.........
示例12: DrawImage
void Graphics::DrawImage(Image* image, const Rect& rc, const ImageAttributes* attr) {
Gdiplus::Graphics* g = reinterpret_cast<Gdiplus::Graphics*>(_private);
Gdiplus::Image* gdiImage = reinterpret_cast<Gdiplus::Image*>(image->_private);
if(attr!=0) {
Gdiplus::ImageAttributes* ia = reinterpret_cast<Gdiplus::ImageAttributes*>(attr->_private);
g->DrawImage(gdiImage, Gdiplus::Rect(rc.GetLeft(), rc.GetTop(), rc.GetWidth(), rc.GetHeight()), 0, 0, gdiImage->GetWidth(), gdiImage->GetHeight(), Gdiplus::UnitPixel, ia);
}
else {
g->DrawImage(gdiImage, ToGDIRect<Rect, Gdiplus::Rect>(rc));
}
}
示例13: scaledImage
int DrawSdk::Image::WriteScaledImageFile(WCHAR* scaledImageName, float scaleX, float scaleY, const WCHAR* format)
{
int hr = S_OK;
// // Starting the Gdiplus machine should be executed outside of this method
// Gdiplus::GdiplusStartupInput gdiplusStartupInput;
// ULONG_PTR gdiplusToken;
// Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
Gdiplus::ImageCodecInfo *pImageCodecInfo = NULL;
CLSID *pClsid = NULL;
HDC hdc = CreateCompatibleDC(NULL);
// Get the encoder CLSID depending on the image format (image/jpeg, image/gif, image/png)
UINT num = 0;
UINT size = 0;
Gdiplus::GetImageEncodersSize(&num, &size);
if (size == 0)
hr = -1; // Failure
if (SUCCEEDED(hr))
{
pImageCodecInfo = (Gdiplus::ImageCodecInfo*)(malloc(size));
if (pImageCodecInfo == NULL)
hr = -1; // Failure
}
if (SUCCEEDED(hr))
{
Gdiplus::GetImageEncoders(num, size, pImageCodecInfo);
for(int j = 0; j < num; ++j)
{
if( wcscmp(pImageCodecInfo[j].MimeType, format) == 0 )
{
pClsid = &pImageCodecInfo[j].Clsid;
break; // Success
}
}
if (pClsid == NULL)
hr = -1; // Failure
}
// Bugfix 5301:
// If 'gdipImage_' is NULL then it was not kept in memory and therefore
// a temporary Gdiplus::Image object is created for the rescaling.
// This avoids having too much image data in the memory.
Gdiplus::Image *tmpImage = NULL;
if (SUCCEEDED(hr) && gdipImage_ == NULL) {
// convert char-String in WCHAR-String
int iStringLength = _tcslen(imageName_) + 1;
WCHAR *wcFilename = (WCHAR *)malloc(iStringLength*sizeof(WCHAR));
#ifdef _UNICODE
wcscpy(wcFilename, imageName_);
#else
MultiByteToWideChar( CP_ACP, 0, imageName, iStringLength,
wcFilename, iStringLength);
#endif
tmpImage = new Gdiplus::Image(wcFilename, FALSE);
if (wcFilename)
free(wcFilename);
} else {
tmpImage = gdipImage_;
}
if (SUCCEEDED(hr) && tmpImage != NULL)
{
// Resize the image by scaling factors
Gdiplus::REAL destWidth = scaleX * this->GetWidth();
Gdiplus::REAL destHeight = scaleY * this->GetHeight();
// If no correct size is defined in the object queue, use the real image size instead
if ( (this->GetWidth() <= 0.0f) && (this->GetHeight() <= 0.0f) )
{
destWidth = scaleX * tmpImage->GetWidth();
destHeight = scaleY * tmpImage->GetHeight();
}
// At least we have to write one pixel
if (destWidth < 1.0f)
destWidth = 1.0f;
if (destHeight < 1.0f)
destHeight = 1.0f;
Gdiplus::Bitmap scaledImage((int)(destWidth + 0.5f), (int)(destHeight + 0.5f));
scaledImage.SetResolution(tmpImage->GetHorizontalResolution(),
tmpImage->GetVerticalResolution());
Gdiplus::Graphics grPhoto(&scaledImage);
grPhoto.SetCompositingQuality(Gdiplus::CompositingQualityHighSpeed);
grPhoto.SetCompositingMode(Gdiplus::CompositingModeSourceOver);
//.........这里部分代码省略.........
示例14: drawServent
//.........这里部分代码省略.........
);
} else if (chanHit.version_vp){
sprintf(tmp, "VP%04d - %d/%d - %s(%s)",
chanHit.version_vp,
totalListeners,
totalRelays,
host1,
hostname.cstr()
);
} else {
sprintf(tmp, "(-----) - %d/%d - %s(%s)",
totalListeners,
totalRelays,
host1,
hostname.cstr()
);
}
} else {
sprintf(tmp, "(-----) - %d/%d - %s(%s)",
totalListeners,
totalRelays,
host1,
hostname.cstr()
);
}
_bstr_t bstr1(tmp);
// ステータス表示
Gdiplus::Image *img = NULL;
unsigned int nowTime = sys->getTime();
switch(getStatus()){
case Servent::S_CONNECTING:
img = img_connect;
break;
case Servent::S_CONNECTED:
if (lastSkipTime + 120 > nowTime){
if (chanHit.relay){
img = img_conn_ok_skip;
} else {
if (chanHit.numRelays){
img = img_conn_full_skip;
} else {
img = img_conn_over_skip;
}
}
} else {
if (chanHit.relay){
img = img_conn_ok;
} else {
if (chanHit.numRelays){
img = img_conn_full;
} else {
img = img_conn_over;
}
}
}
break;
default:
break;
}
// 文字描画範囲指定
RectF r1(origin.X + img->GetWidth() + 2, origin.Y, 800.0f, 13.0f);
RectF r2;
StringFormat format;
format.SetAlignment(StringAlignmentNear);
g->MeasureString(bstr1, -1, &font, r1, &format, &r2);
w = (INT)r2.Width + img->GetWidth() + 2;
// ServentData表示部の背景を塗る
if (getSelected()){
// 選択中
SolidBrush b(Color(160,49,106,197));
g->FillRectangle(&b, x, y, w, 13);
} else {
// 非選択
SolidBrush b(Color(160,200,200,200));
g->FillRectangle(&b, x, y, w, 13);
}
// ステータス表示位置
Rect img_rect((INT)origin.X, (INT)origin.Y+1, img ? img->GetWidth() : 12, 12);
// ステータス描画
ImageAttributes att;
// att.SetColorKey(Color::White, Color::White, ColorAdjustTypeBitmap);
g->DrawImage(img, img_rect, 0, 0, img_rect.Width, 12, UnitPixel, &att);
// 次の基点
origin.X += 12;
g->DrawString(bstr1, -1, &font, r2, &format, strBrush);
// 次の基点
origin.X += r2.Width;
origin.Y += 13;
setWidth((int)origin.X-posX);
setHeight((int)origin.Y - posY);
::delete strBrush;
return 0;
}
示例15: drawChannel
int ChannelData::drawChannel(Graphics *g, int x, int y){
REAL xx = x * 1.0f;
REAL yy = y * 1.0f;
ServentData* sd;
// 位置を保存
posX = x;
posY = y;
int w/*,h*/;
if (getWidth() == 0){
if (gW){
w = gW;
} else {
w = 400;
}
} else {
w = getWidth();
gW = w;
}
// チャンネル表示部の背景を塗る
if (isSelected()){
// 選択中
SolidBrush b(Color(160,49,106,197));
g->FillRectangle(&b, x, y, w, 14);
} else {
// 非選択
SolidBrush b(Color(160,255,255,255));
g->FillRectangle(&b, x, y, w, 14);
}
// ステータス表示
Gdiplus::Image *img = NULL;
unsigned int nowTime = sys->getTime();
if (this->type != Servent::T_COUT)
{
// COUT以外
Channel *ch = chanMgr->findChannelByChannelID(this->channel_id);
switch(this->getStatus()){
case Channel::S_IDLE:
img = img_idle;
break;
case Channel::S_SEARCHING:
case Channel::S_CONNECTING:
img = img_connect;
break;
case Channel::S_RECEIVING:
if ((skipCount > 2) && (lastSkipTime + 120 > nowTime)){
if (chDisp.relay){
img = img_conn_ok_skip;
} else {
if (chDisp.numRelays){
img = img_conn_full_skip;
} else {
img = img_conn_over_skip;
}
}
} else {
if (chDisp.relay){
img = img_conn_ok;
} else {
if (chDisp.numRelays){
img = img_conn_full;
} else {
img = img_conn_over;
}
}
}
break;
case Channel::S_BROADCASTING:
img = img_broad_ok;
break;
case Channel::S_ERROR:
// bump時にエラーが表示されるのを防止
if (ch && ch->bumped)
{
img = img_connect;
} else
{
img = img_error;
}
break;
default:
img = img_idle;
break;
}
} else
{
// COUT用
img = img_broad_ok;
}
// 描画基点
PointF origin(xx, yy);
// ステータス表示位置
Rect img_rect((INT)origin.X, (INT)origin.Y + 1, img ? img->GetWidth() : 12, 12);
// ステータス描画
ImageAttributes att;
//.........这里部分代码省略.........