本文整理汇总了C++中wxImage::GetHeight方法的典型用法代码示例。如果您正苦于以下问题:C++ wxImage::GetHeight方法的具体用法?C++ wxImage::GetHeight怎么用?C++ wxImage::GetHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxImage
的用法示例。
在下文中一共展示了wxImage::GetHeight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ImageDrawSelectionField
void ImageDrawSelectionField(wxImage& img, int x, int y, int width, int height, unsigned char red, unsigned char green, unsigned char blue) {
unsigned char* rawdata = img.GetData();
unsigned char* rawalpha = img.GetAlpha();
int thick = min(width,height)/100+1;
int i,j,posx,posy;
#define MACRO_SETPIXELCOLOR() \
rawdata[3*(posx+posy)] = red; \
rawdata[3*(posx+posy)+1] = green; \
rawdata[3*(posx+posy)+2] = blue; \
rawalpha[posx+posy] = 0xFF;
width--;
height--;
for (i=0;i<=width;i++) {
posx = (x+i)%img.GetWidth();
for (j=0;j<thick;j++) {
posy = ((y+j)%img.GetHeight())*img.GetWidth();
MACRO_SETPIXELCOLOR()
posy = ((y+height-j)%img.GetHeight())*img.GetWidth();
MACRO_SETPIXELCOLOR()
}
}
for (i=0;i<=height;i++) {
posy = (y+i)%img.GetHeight()*img.GetWidth();
for (j=0;j<thick;j++) {
posx = (x+j)%img.GetWidth();
MACRO_SETPIXELCOLOR()
posx = (x+width-j)%img.GetWidth();
MACRO_SETPIXELCOLOR()
}
}
}
示例2: stackImages
wxImage zen::stackImages(const wxImage& img1, const wxImage& img2, ImageStackLayout dir, ImageStackAlignment align, int gap)
{
assert(gap >= 0);
gap = std::max(0, gap);
const int img1Width = img1.GetWidth ();
const int img1Height = img1.GetHeight();
const int img2Width = img2.GetWidth ();
const int img2Height = img2.GetHeight();
int width = std::max(img1Width, img2Width);
int height = std::max(img1Height, img2Height);
switch (dir)
{
case ImageStackLayout::HORIZONTAL:
width = img1Width + gap + img2Width;
break;
case ImageStackLayout::VERTICAL:
height = img1Height + gap + img2Height;
break;
}
wxImage output(width, height);
output.SetAlpha();
::memset(output.GetAlpha(), wxIMAGE_ALPHA_TRANSPARENT, width * height);
auto calcPos = [&](int imageExtent, int totalExtent)
{
switch (align)
{
case ImageStackAlignment::CENTER:
return (totalExtent - imageExtent) / 2;
case ImageStackAlignment::LEFT:
return 0;
case ImageStackAlignment::RIGHT:
return totalExtent - imageExtent;
}
assert(false);
return 0;
};
switch (dir)
{
case ImageStackLayout::HORIZONTAL:
writeToImage(img1, output, wxPoint(0, calcPos(img1Height, height)));
writeToImage(img2, output, wxPoint(img1Width + gap, calcPos(img2Height, height)));
break;
case ImageStackLayout::VERTICAL:
writeToImage(img1, output, wxPoint(calcPos(img1Width, width), 0));
writeToImage(img2, output, wxPoint(calcPos(img2Width, width), img1Height + gap));
break;
}
return output;
}
示例3: Init
void ImageRoll::Init(RollType type, const wxImage &src, wxColour magicColor)
{
ImageArray images;
int i;
mType = type;
switch(mType) {
case HorizontalRoll:
images = SplitH(src, magicColor);
mMinSize.x = 0;
mMinSize.y = src.GetHeight();
mMaxSize.x = 9999;
mMaxSize.y = src.GetHeight();
for(i=0; i<(int)images.GetCount(); i++) {
if (images[i].Ok()) {
mPieces.Add(wxBitmap(images[i]));
mMinSize.x += mPieces[i].GetWidth();
}
else
mPieces.Add(wxBitmap());
}
break;
case VerticalRoll:
images = SplitV(src, magicColor);
mMinSize.x = src.GetWidth();
mMinSize.y = 0;
mMaxSize.x = src.GetWidth();
mMaxSize.y = 9999;
for(i=0; i<(int)images.GetCount(); i++) {
if (images[i].Ok()) {
mPieces.Add(wxBitmap(images[i]));
mMinSize.y += mPieces[i].GetHeight();
}
else
mPieces.Add(wxBitmap());
}
break;
case FixedImage:
mPieces.Add(wxBitmap(src));
mMinSize.x = src.GetWidth();
mMinSize.y = src.GetHeight();
mMaxSize.x = src.GetWidth();
mMaxSize.y = src.GetHeight();
break;
} // switch
}
示例4: wxAntiAlias2
// Suggestion by Carlos Moreno
wxImage wxAntiAlias2(const wxImage& image)
{
wxImage anti(image.GetWidth(), image.GetHeight());
/* This is quite slow, but safe. Use wxImage::GetData() for speed instead. */
for (int y = 1; y < image.GetHeight() - 1; y++)
for (int x = 1; x < image.GetWidth() - 1; x++)
{
long red =
((int) image.GetRed( x-1, y-1 )) * 1 +
((int) image.GetRed( x, y-1 )) * 4 +
((int) image.GetRed( x+1, y-1 )) * 1 +
((int) image.GetRed( x+1, y )) * 4 +
((int) image.GetRed( x+1, y+1 )) * 1 +
((int) image.GetRed( x, y+1 )) * 4 +
((int) image.GetRed( x-1, y+1 )) * 1 +
((int) image.GetRed( x-1, y )) * 4 +
((int) image.GetRed( x, y )) * 20 ;
red = red/40;
long green =
((int) image.GetGreen( x-1, y-1 )) * 1 +
((int) image.GetGreen( x, y-1 )) * 4 +
((int) image.GetGreen( x+1, y-1 )) * 1 +
((int) image.GetGreen( x+1, y )) * 4 +
((int) image.GetGreen( x+1, y+1 )) * 1 +
((int) image.GetGreen( x, y+1 )) * 4 +
((int) image.GetGreen( x-1, y+1 )) * 1 +
((int) image.GetGreen( x-1, y )) * 4 +
((int) image.GetGreen( x, y )) * 20 ;
green = green/40;
long blue =
((int) image.GetBlue( x-1, y-1 )) * 1 +
((int) image.GetBlue( x, y-1 )) * 4 +
((int) image.GetBlue( x+1, y-1 )) * 1 +
((int) image.GetBlue( x+1, y )) * 4 +
((int) image.GetBlue( x+1, y+1 )) * 1 +
((int) image.GetBlue( x, y+1 )) * 4 +
((int) image.GetBlue( x-1, y+1 )) * 1 +
((int) image.GetBlue( x-1, y )) * 4 +
((int) image.GetBlue( x, y )) * 20 ;
blue = blue/40;
anti.SetRGB( x, y, (wxChar) red, (wxChar) green, (wxChar) blue );
}
return anti;
}
示例5: BlendImage
/**
@brief Blends two images based on alpha channel present in foreground image.
@param foreground Foreground image, must have an alpha channel
@param background Background image, may have an alpha channel
@param blend_alpha Whether the returned image will have an alpha channel.
@return A copy of the background image with the foreground image blended on
top of it. The returned image will have an alpha channel iff the background
image has an alpha channel. In that case the alpha channel is blended
identical to the red/green/blue channels.
*/
wxImage BlendImage( const wxImage& foreground, const wxImage& background, bool blend_alpha )
{
if ( ( foreground.GetWidth() != background.GetWidth() ) || ( background.GetHeight() != foreground.GetHeight() ) )
{
wxLogDebugFunc(_T("size mismatch while blending"));
return background;
}
bool zhu = blend_alpha && background.HasAlpha();
if ( foreground.HasAlpha() )
{
wxImage ret( background.GetWidth(), foreground.GetHeight() );
const unsigned char* background_data = background.GetData();
const unsigned char* foreground_data = foreground.GetData();
const unsigned char* background_alpha = NULL;
const unsigned char* foreground_alpha = foreground.GetAlpha();
unsigned char* result_data = ret.GetData();
unsigned char* result_alpha = NULL;
unsigned int pixel_count = background.GetWidth() * background.GetHeight();
if ( zhu )
{
background_alpha = background.GetAlpha();
ret.InitAlpha();
result_alpha = ret.GetAlpha();
}
for ( unsigned int i = 0, i_a = 0; i < pixel_count * 3; i+=3, i_a++ )
{
unsigned char fore_alpha = foreground_alpha[i_a] ;
float back_blend_fac = ( 255 - fore_alpha)/255.0;
float fore_blend_fac = fore_alpha/255.0 ;
result_data[i] = foreground_data[i] * fore_blend_fac + background_data[i] * back_blend_fac ;
result_data[i+1] = foreground_data[i+1] * fore_blend_fac + background_data[i+1] * back_blend_fac ;
result_data[i+2] = foreground_data[i+2] * fore_blend_fac + background_data[i+2] * back_blend_fac ;
if ( zhu )
{
unsigned char back_alpha = background_alpha[i_a] ;
result_alpha[i_a] = fore_alpha * fore_blend_fac + back_alpha * back_blend_fac ;
}
}
return ret;
}
wxLogDebugFunc(_T("cannot blend without alpha"));
return background;
}
示例6: wxT
void BM2CMP_FRAME::ExportFile( FILE* aOutfile, OUTPUT_FMT_ID aFormat )
{
// Create a potrace bitmap
int h = m_NB_Image.GetHeight();
int w = m_NB_Image.GetWidth();
potrace_bitmap_t* potrace_bitmap = bm_new( w, h );
if( !potrace_bitmap )
{
wxString msg;
msg.Printf( wxT( "Error allocating memory for potrace bitmap" ) );
wxMessageBox( msg );
return;
}
/* fill the bitmap with data */
for( int y = 0; y < h; y++ )
{
for( int x = 0; x < w; x++ )
{
unsigned char pix = m_NB_Image.GetGreen( x, y );
BM_PUT( potrace_bitmap, x, y, pix ? 1 : 0 );
}
}
bitmap2component( potrace_bitmap, aOutfile, aFormat, m_imageDPI.x, m_imageDPI.y );
}
示例7: SetImage
void wxHtmlImageCell::SetImage(const wxImage& img)
{
#if !defined(__WXMSW__) || wxUSE_WXDIB
if ( img.IsOk() )
{
delete m_bitmap;
int ww, hh;
ww = img.GetWidth();
hh = img.GetHeight();
if ( m_bmpW == wxDefaultCoord)
m_bmpW = ww;
if ( m_bmpH == wxDefaultCoord)
m_bmpH = hh;
// Only scale the bitmap at the rendering stage,
// so we don't lose quality twice
/*
if ((m_bmpW != ww) || (m_bmpH != hh))
{
wxImage img2 = img.Scale(m_bmpW, m_bmpH);
m_bitmap = new wxBitmap(img2);
}
else
*/
m_bitmap = new wxBitmap(img);
}
#endif
}
示例8: tintImage
wxImage tintImage( wxImage to_colorize, wxColour col)
{
wxImage highlightIcon(to_colorize.GetWidth(),to_colorize.GetHeight());
bool do_alpha = false;
if(to_colorize.HasAlpha())
{
highlightIcon.InitAlpha();
do_alpha = true;
}
else if(to_colorize.HasMask())
{
highlightIcon.SetMaskFromImage(to_colorize,to_colorize.GetMaskRed(),to_colorize.GetMaskGreen(),to_colorize.GetMaskBlue());
}
for(int x = 0; x < highlightIcon.GetWidth(); x++)
{
for(int y = 0; y < highlightIcon.GetHeight(); y++)
{
to_colorize.GetData();
unsigned char srcR = to_colorize.GetRed(x,y);
unsigned char srcG = to_colorize.GetGreen(x,y);
unsigned char srcB = to_colorize.GetBlue(x,y);
highlightIcon.SetRGB(x,y,(srcR + col.Red())/2,(srcG + col.Green())/2, (srcB + col.Blue())/2);
if(do_alpha)
highlightIcon.SetAlpha(x,y,to_colorize.GetAlpha(x,y));
}
}
return highlightIcon;
}
示例9: AdjustAndSetBitmap
void AdjustAndSetBitmap(int size, wxImage &image, wxImage &dbl, wxBitmap&bitmap) {
#ifdef __WXOSX__
if (dbl.GetHeight() == (2 * size)) {
bitmap = wxBitmap(dbl, -1, 2.0);
} else if (dbl.GetHeight() > (2*size)) {
wxImage scaled = image.Scale(size*2, size*2, wxIMAGE_QUALITY_HIGH);
bitmap = wxBitmap(scaled, -1, 2.0);
} else
#endif
if (image.GetHeight() == size) {
bitmap = wxBitmap(image);
} else {
wxImage scaled = image.Scale(size, size, wxIMAGE_QUALITY_HIGH);
bitmap = wxBitmap(scaled);
}
}
示例10: wxT
void BM2CMP_FRAME::ExportFile( FILE* aOutfile, OUTPUT_FMT_ID aFormat )
{
// Create a potrace bitmap
int h = m_NB_Image.GetHeight();
int w = m_NB_Image.GetWidth();
potrace_bitmap_t* potrace_bitmap = bm_new( w, h );
if( !potrace_bitmap )
{
wxString msg;
msg.Printf( wxT( "Error allocating memory for potrace bitmap" ) );
wxMessageBox( msg );
return;
}
/* fill the bitmap with data */
for( int y = 0; y < h; y++ )
{
for( int x = 0; x < w; x++ )
{
unsigned char pix = m_NB_Image.GetGreen( x, y );
BM_PUT( potrace_bitmap, x, y, pix ? 1 : 0 );
}
}
// choices of m_radio_PCBLayer are expected to be in same order as
// BMP2CMP_MOD_LAYER. See bitmap2component.h
BMP2CMP_MOD_LAYER modLayer = MOD_LYR_FSILKS;
if( aFormat == PCBNEW_KICAD_MOD )
modLayer = (BMP2CMP_MOD_LAYER) m_radio_PCBLayer->GetSelection();
bitmap2component( potrace_bitmap, aOutfile, aFormat, m_imageDPI.x, m_imageDPI.y, modLayer );
}
示例11: GreyOutImage
void GreyOutImage(wxImage &img)
{
unsigned char *data = img.GetData();
unsigned char r,g,b;
unsigned char mr,mg,mb;
int i, tst;
int len = img.GetHeight()*img.GetWidth()*3;
if (img.HasMask())
{
mr = img.GetMaskRed();
mg = img.GetMaskGreen();
mb = img.GetMaskBlue();
}
tst=0;
for (i=0;i<len;i+=3)
{
r=data[i]; g=data[i+1]; b=data[i+2];
if (!img.HasMask() ||
r!=mr || g!=mg || b!=mb)
{
if (!tst)
{
tst=1;
}
r = (unsigned char)((230.0-r)*0.7+r);
g = (unsigned char)((230.0-g)*0.7+g);
b = (unsigned char)((230.0-b)*0.7+b);
data[i]=r; data[i+1]=g; data[i+2]=b;
}
}
}
示例12: CreateFromImage
bool wxBitmap::CreateFromImage(const wxImage& image, int depth)
{
UnRef();
wxCHECK_MSG( image.Ok(), FALSE, wxT("invalid image") )
wxCHECK_MSG( depth == -1 || depth == 1, FALSE, wxT("invalid bitmap depth") )
if (image.GetWidth() <= 0 || image.GetHeight() <= 0)
return false;
m_refData = new wxBitmapRefData();
if (depth == 1)
{
return CreateFromImageAsBitmap(image);
}
else
{
#ifdef __WXGTK20__
if (image.HasAlpha())
return CreateFromImageAsPixbuf(image);
#endif
return CreateFromImageAsPixmap(image);
}
}
示例13: GetSubImageWithAlpha
/// Gets a rectangle from within another image, INCLUDING the alpha channel
/// \bug in wxWidgets, wxImage::GetSubImage should do this itself.
wxImage GetSubImageWithAlpha( const wxImage & Src, const wxRect &rect )
{
//First part of this code is lifted from wxImage::GetSubImage() source code.
wxImage image;
wxCHECK_MSG( Src.Ok(), image, wxT("invalid image") );
wxCHECK_MSG( (rect.GetLeft()>=0) && (rect.GetTop()>=0) && (
rect.GetRight()<=Src.GetWidth()) && (rect.GetBottom()<=Src.GetHeight()),
image, wxT("invalid subimage size") );
int subwidth=rect.GetWidth();
const int subheight=rect.GetHeight();
image.Create( subwidth, subheight, false );
unsigned char *subdata = image.GetData(), *data=Src.GetData();
wxCHECK_MSG( subdata, image, wxT("unable to create image") );
// JKC: Quick hack - don't deal with masks - need to understand macro M_IMGDATA first.
// if (Src.M_IMGDATA->m_hasMask)
// image.SetMaskColour( Src.M_IMGDATA->m_maskRed, Src.M_IMGDATA->m_maskGreen, Src.M_IMGDATA->m_maskBlue );
int subleft=3*rect.GetLeft();
int width=3*Src.GetWidth();
subwidth*=3;
data+=rect.GetTop()*width+subleft;
for (long j = 0; j < subheight; ++j)
{
memcpy( subdata, data, subwidth);
subdata+=subwidth;
data+=width;
}
// OK, so we've copied the RGB data.
// Now do the Alpha channel.
wxASSERT( Src.HasAlpha() );
image.InitAlpha();
subleft/=3;
width/=3;
subwidth/=3;
data =Src.GetAlpha();
subdata =image.GetAlpha();
data+=rect.GetTop()*width+subleft;
for (long j = 0; j < subheight; ++j)
{
memcpy( subdata, data, subwidth);
subdata+=subwidth;
data+=width;
}
return image;
}
示例14: wxQtConvertImage
QImage wxQtConvertImage( const wxImage &image )
{
bool hasAlpha = image.HasAlpha();
bool hasMask = image.HasMask();
wxSize size ( image.GetWidth(), image.GetHeight() );
QImage qtImage( wxQtConvertSize( size ),
( (hasAlpha || hasMask ) ? QImage::Format_ARGB32 : QImage::Format_RGB32 ) );
unsigned char *data = image.GetData();
unsigned char *alpha = hasAlpha ? image.GetAlpha() : NULL;
QRgb colour;
QRgb maskedColour;
if ( hasMask )
{
unsigned char r, g, b;
image.GetOrFindMaskColour( &r, &g, &b );
maskedColour = ( r << 16 ) + ( g << 8 ) + b;
}
for (int y = 0; y < image.GetHeight(); y++)
{
for (int x = 0; x < image.GetWidth(); x++)
{
if (hasAlpha)
{
colour = alpha[0] << 24;
alpha++;
}
else
colour = 0;
colour += (data[0] << 16) + (data[1] << 8) + data[2];
if ( hasMask && colour != maskedColour )
colour += 0xFF000000; // 255 << 24
qtImage.setPixel(x, y, colour);
data += 3;
}
}
return qtImage;
}
示例15: convertWxImageToCVMat
void OpenCVHelper::convertWxImageToCVMat(const wxImage &img, cv::Mat &cvimg)
{
cvimg.create(img.GetHeight(), img.GetWidth(), CV_8UC3);
cv::Vec3b *cvPtr = cvimg.ptr<cv::Vec3b>(0);
unsigned char *wxPtr = img.GetData();
for(int y = 0; y < img.GetHeight(); y++)
{
for(int x = 0; x < img.GetWidth(); x++)
{
/* img_cv.at<cv::Vec3b>(y, x)[2] = localPreviewImage.GetRed(x, y);
img_cv.at<cv::Vec3b>(y, x)[1] = localPreviewImage.GetGreen(x, y);
img_cv.at<cv::Vec3b>(y, x)[0] = localPreviewImage.GetBlue(x, y);*/
(*cvPtr)[2] = *(wxPtr++); // OpenCV usually stores BGR, not RGB
(*cvPtr)[1] = *(wxPtr++);
(*cvPtr)[0] = *(wxPtr++);
cvPtr++;
}
}
}