本文整理汇总了C++中wxImage::GetOptionInt方法的典型用法代码示例。如果您正苦于以下问题:C++ wxImage::GetOptionInt方法的具体用法?C++ wxImage::GetOptionInt怎么用?C++ wxImage::GetOptionInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxImage
的用法示例。
在下文中一共展示了wxImage::GetOptionInt方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wxBitmap
bool BM2CMP_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
{
// Prj().MaybeLoadProjectSettings();
m_BitmapFileName = aFileSet[0];
if( !m_Pict_Image.LoadFile( m_BitmapFileName ) )
{
// LoadFile has its own UI, no need for further failure notification here
return false;
}
m_Pict_Bitmap = wxBitmap( m_Pict_Image );
int h = m_Pict_Bitmap.GetHeight();
int w = m_Pict_Bitmap.GetWidth();
// Determine image resolution in DPI (does not existing in all formats).
// the resolution can be given in bit per inches or bit per cm in file
m_imageDPI.x = m_Pict_Image.GetOptionInt( wxIMAGE_OPTION_RESOLUTIONX );
m_imageDPI.y = m_Pict_Image.GetOptionInt( wxIMAGE_OPTION_RESOLUTIONY );
if( m_imageDPI.x > 1 && m_imageDPI.y > 1 )
{
if( m_Pict_Image.GetOptionInt( wxIMAGE_OPTION_RESOLUTIONUNIT ) == wxIMAGE_RESOLUTION_CM )
{
// When the initial resolution is given in bits per cm,
// experience shows adding 1.27 to the resolution converted in dpi
// before convert to int value reduce the conversion error
// but it is not perfect
m_imageDPI.x = m_imageDPI.x * 2.54 + 1.27;
m_imageDPI.y = m_imageDPI.y * 2.54 + 1.27;
}
}
else // fallback to the default value
m_imageDPI.x = m_imageDPI.y = DEFAULT_DPI;
// Display image info:
// We are using ChangeValue here to avoid generating a wxEVT_TEXT event.
m_DPIValueX->ChangeValue( wxString::Format( wxT( "%d" ), m_imageDPI.x ) );
m_DPIValueY->ChangeValue( wxString::Format( wxT( "%d" ), m_imageDPI.y ) );
updateImageInfo();
m_InitialPicturePanel->SetVirtualSize( w, h );
m_GreyscalePicturePanel->SetVirtualSize( w, h );
m_BNPicturePanel->SetVirtualSize( w, h );
m_Greyscale_Image.Destroy();
m_Greyscale_Image = m_Pict_Image.ConvertToGreyscale( );
if( m_rbOptions->GetSelection() > 0 )
NegateGreyscaleImage( );
m_Greyscale_Bitmap = wxBitmap( m_Greyscale_Image );
m_NB_Image = m_Greyscale_Image;
Binarize( (double) m_sliderThreshold->GetValue()/m_sliderThreshold->GetMax() );
return true;
}
示例2: InitFromImage
void wxCursor::InitFromImage( const wxImage & image )
{
const int w = image.GetWidth();
const int h = image.GetHeight();
const guchar* alpha = image.GetAlpha();
const bool hasMask = image.HasMask();
int hotSpotX = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X);
int hotSpotY = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y);
if (hotSpotX < 0 || hotSpotX > w) hotSpotX = 0;
if (hotSpotY < 0 || hotSpotY > h) hotSpotY = 0;
GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data(image.GetData(), GDK_COLORSPACE_RGB, false, 8, w, h, w * 3, NULL, NULL);
if (alpha || hasMask)
{
guchar r = 0, g = 0, b = 0;
if (hasMask)
{
r = image.GetMaskRed();
g = image.GetMaskGreen();
b = image.GetMaskBlue();
}
GdkPixbuf* pixbuf0 = pixbuf;
pixbuf = gdk_pixbuf_add_alpha(pixbuf, hasMask, r, g, b);
g_object_unref(pixbuf0);
if (alpha)
{
guchar* d = gdk_pixbuf_get_pixels(pixbuf);
const int stride = gdk_pixbuf_get_rowstride(pixbuf);
for (int j = 0; j < h; j++, d += stride)
for (int i = 0; i < w; i++, alpha++)
if (d[4 * i + 3])
d[4 * i + 3] = *alpha;
}
}
m_refData = new wxCursorRefData;
M_CURSORDATA->m_cursor = gdk_cursor_new_from_pixbuf(gtk_widget_get_display(wxGetRootWindow()), pixbuf, hotSpotX, hotSpotY);
g_object_unref(pixbuf);
}
示例3: CreateFromImage
void wxCursor::CreateFromImage(const wxImage & image)
{
m_refData = new wxCursorRefData;
int w = 16;
int h = 16;
int hotSpotX = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X);
int hotSpotY = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y);
int image_w = image.GetWidth();
int image_h = image.GetHeight();
wxASSERT_MSG( hotSpotX >= 0 && hotSpotX < image_w &&
hotSpotY >= 0 && hotSpotY < image_h,
_T("invalid cursor hot spot coordinates") );
wxImage image16(image); // final image of correct size
// if image is too small then place it in the center, resize it if too big
if ((w > image_w) && (h > image_h))
{
wxPoint offset((w - image_w)/2, (h - image_h)/2);
hotSpotX = hotSpotX + offset.x;
hotSpotY = hotSpotY + offset.y;
image16 = image.Size(wxSize(w, h), offset);
}
else if ((w != image_w) || (h != image_h))
{
hotSpotX = int(hotSpotX * double(w) / double(image_w));
hotSpotY = int(hotSpotY * double(h) / double(image_h));
image16 = image.Scale(w, h);
}
unsigned char * rgbBits = image16.GetData();
bool bHasMask = image16.HasMask() ;
#if 0
// monochrome implementation
M_CURSORDATA->m_hCursor = NewHandle( sizeof( Cursor ) ) ;
M_CURSORDATA->m_disposeHandle = true ;
HLock( (Handle) M_CURSORDATA->m_hCursor ) ;
CursPtr cp = *(CursHandle)M_CURSORDATA->m_hCursor ;
memset( cp->data , 0 , sizeof( Bits16 ) ) ;
memset( cp->mask , 0 , sizeof( Bits16 ) ) ;
unsigned char mr = image16.GetMaskRed() ;
unsigned char mg = image16.GetMaskGreen() ;
unsigned char mb = image16.GetMaskBlue() ;
for ( int y = 0 ; y < h ; ++y )
{
short rowbits = 0 ;
short maskbits = 0 ;
for ( int x = 0 ; x < w ; ++x )
{
long pos = (y * w + x) * 3;
unsigned char r = rgbBits[pos] ;
unsigned char g = rgbBits[pos+1] ;
unsigned char b = rgbBits[pos+2] ;
if ( bHasMask && r==mr && g==mg && b==mb )
{
// masked area, does not appear anywhere
}
else
{
if ( (int)r + (int)g + (int)b < 0x0200 )
{
rowbits |= ( 1 << (15-x) ) ;
}
maskbits |= ( 1 << (15-x) ) ;
}
}
cp->data[y] = rowbits ;
cp->mask[y] = maskbits ;
}
if ( !bHasMask )
{
memcpy( cp->mask , cp->data , sizeof( Bits16) ) ;
}
cp->hotSpot.h = hotSpotX ;
cp->hotSpot.v = hotSpotY ;
HUnlock( (Handle) M_CURSORDATA->m_hCursor ) ;
#else
PixMapHandle pm = (PixMapHandle) NewHandleClear( sizeof (PixMap)) ;
short extent = 16 ;
short bytesPerPixel = 1 ;
short depth = 8 ;
Rect bounds = { 0 , 0 , extent , extent } ;
CCrsrHandle ch = (CCrsrHandle) NewHandleClear ( sizeof( CCrsr ) ) ;
CTabHandle newColors = GetCTable( 8 ) ;
HandToHand((Handle *) &newColors);
// set the values to the indices
for ( int i = 0 ; i < (**newColors).ctSize ; ++i )
{
(**newColors).ctTable[i].value = i ;
}
HLock( (Handle) ch) ;
//.........这里部分代码省略.........