本文整理汇总了C++中Bitmap::Height方法的典型用法代码示例。如果您正苦于以下问题:C++ Bitmap::Height方法的具体用法?C++ Bitmap::Height怎么用?C++ Bitmap::Height使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bitmap
的用法示例。
在下文中一共展示了Bitmap::Height方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//
// Create Bitmap
//
plMipmap *plBitmapCreator::ICreateBitmap(plBitmapData *bd)
{
hsGuardBegin("hsConverterUtils::CreateBitmap");
// Load the bitmap
BitmapInfo bi;
bi.SetName(bd->fileName.AsString().c_str());
#if 0 // This isn't really an issue since the textures are packed -Colin
const int kMaxFileNameLength = 30;
if (strlen(bi.Filename()) > kMaxFileNameLength)
{
// Allow to continue, But make it painful
char errStr[256];
sprintf(errStr, "File name longer than %d, won't burn to CD (%s)", kMaxFileNameLength, bi.Filename());//bitmapTex->GetName());
MessageBox(GetActiveWindow(), errStr, bd->fileName, MB_OK|MB_ICONEXCLAMATION);
}
#endif
bool notMipped = (bd->texFlags & plMipmap::kForceOneMipLevel) != 0;
float sigma = bd->sig;
// Load the bitmap
Bitmap *bm = TheManager->Load(&bi);
if (!bm)
{
// FIXME
/*
if (fErrorMsg->Set(!(fWarned & kWarnedNoMoreBitmapLoadErr),
"Error loading bitmap", pathName).CheckAskOrCancel())
{
fWarned |= kWarnedNoMoreBitmapLoadErr;
}
*/
return nil;
}
BitmapStorage *storage = bm->Storage();
BitmapInfo *bInfo = &storage->bi;
ICheckOutBitmap(bInfo, bm, bd->fileName);
//
// Create a plMipmap
//
plMipmap *hBitmap = new plMipmap;
if( (bm->Width() ^ (bm->Width() & -bm->Width()))
||(bm->Height() ^ (bm->Height() & -bm->Height())) )
{
IResampBitmap(bm, *hBitmap);
}
else if( ((bm->Width() >> 3) > bm->Height())||((bm->Height() >> 3) > bm->Width()) )
{
IResampBitmap(bm, *hBitmap);
}
else
{
示例2: rect
void
GUI::_DisplayStringCommon(const std::string& text,
uint16 x, uint16 y, bool centerString, uint32 time)
{
static uint32 sCurrentId = 0;
const Font* font = FontRoster::GetFont("TOOLFONT");
uint16 height;
uint16 stringWidth = font->StringWidth(text, &height);
Bitmap* bitmap = new Bitmap(stringWidth, height, 8);
bitmap->Clear(font->TransparentIndex());
//bitmap->SetColorKey(font->TransparentIndex());
// Pre-render the string to a bitmap
GFX::rect rect(0, 0, bitmap->Width(), bitmap->Height());
font->RenderString(text, 0, bitmap, rect);
// Set the position where to blit the bitmap
rect.x = x;
rect.y = y;
if (centerString) {
rect.x -= stringWidth / 2;
}
string_entry entry = { text, bitmap, rect, sCurrentId};
fTooltipList.push_back(entry);
long id = sCurrentId++;
Timer::AddOneShotTimer((uint32)time, DeleteStringEntry, (void*)id);
}
示例3: QuantizeToPalette
void ImageCompressorBlockPalette::QuantizeToPalette(const Bitmap &bmp, OutputDataStream &stream)
{
const UINT width = RoundDown(bmp.Width());
const UINT height = RoundDown(bmp.Height());
stream << width << height;
for(UINT x = 0; x < width; x += blockDimension)
{
for(UINT y = 0; y < height; y += blockDimension)
{
Block32 curBlock;
for(UINT yOffset = 0; yOffset < blockDimension; yOffset++)
{
for(UINT xOffset = 0; xOffset < blockDimension; xOffset++)
{
curBlock.c[yOffset][xOffset] = bmp[y + yOffset][x + xOffset];
}
}
UINT bestPaletteError = 0xFFFFFFFF;
UINT bestPaletteIndex = 0;
for(UINT paletteIndex = 0; paletteIndex < paletteSize; paletteIndex++)
{
UINT curPaletteError = CompareBlocks(curBlock, _palette.colors[paletteIndex]);
if(curPaletteError < bestPaletteError)
{
bestPaletteIndex = paletteIndex;
bestPaletteError = curPaletteError;
}
}
stream << BYTE(bestPaletteIndex);
//stream << UINT16(bestPaletteIndex);
}
}
}
示例4: BitmapDimensions
static void BitmapDimensions(int &width, int &height, Texmap * map)
{
// int h=dim; w=dim;
if(map == NULL){
//NH 05-Dec-05 This can happen when submaps are not assigned - in this case simply bail and let
//the parent texture deal with it.
// height = width = 0;
return;
}
if(map->ClassID() == GNORMAL_CLASS_ID)
{
Texmap * bmap;
map->GetParamBlock(0)->GetValue(2,0,bmap,FOREVER); // normal map
BitmapDimensions(width,height,bmap);
return;
}
else if(map->ClassID() == Class_ID(BMTEX_CLASS_ID, 0))
{
BitmapTex *pBT;
Bitmap *pTex;
pBT = static_cast<BitmapTex *>(map);
pTex = pBT->GetBitmap(0);
if (pTex)
{
width = getClosestPowerOf2(pTex->Width());
height = getClosestPowerOf2(pTex->Height());
}
return;
}
else{
}
}
示例5: intersects
boolean UStencil::intersects (BoxObj& userb, Graphic* gs) {
Transformer* t = gs->GetTransformer();
Bitmap* bitmap = (_mask == nil) ? _image : _mask;
Coord xmax = bitmap->Width();
Coord ymax = bitmap->Height();
Coord tx0, ty0, tx1, ty1;
if (t != nil && t->Rotated()) {
Coord x[4], tx[5];
Coord y[4], ty[5];
x[0] = x[3] = y[0] = y[1] = 0;
x[2] = x[1] = xmax;
y[2] = y[3] = ymax;
transformList(x, y, 4, tx, ty, gs);
tx[4] = tx[0];
ty[4] = ty[0];
FillPolygonObj fp (tx, ty, 5);
return fp.Intersects(userb);
} else if (t != nil) {
t->Transform(0, 0, tx0, ty0);
t->Transform(xmax, ymax, tx1, ty1);
BoxObj b1 (tx0, ty0, tx1, ty1);
return b1.Intersects(userb);
} else {
BoxObj b2 (0, 0, xmax, ymax);
return b2.Intersects(userb);
}
}
示例6:
void
UVMapView::DragBy(double dx, double dy)
{
if (!material || !material->tex_diffuse || selverts.size() < 1)
return;
Bitmap* bmp = material->tex_diffuse;
double w = zoom * bmp->Width();
double h = zoom * bmp->Height();
float du = (float) (dx/w);
float dv = (float) (dy/h);
for (auto svi = selverts.begin(); svi != selverts.end(); ++svi) {
DWORD value = *svi;
DWORD p = value >> 16;
DWORD n = value & 0xffff;
Poly* poly = polys[p];
if (poly && n < poly->nverts) {
VertexSet* vset = poly->vertex_set;
int v = poly->verts[n];
vset->tu[v] += du;
vset->tv[v] += dv;
}
}
}
示例7: Assert
void D3D9RenderTargetTexture::GetData(Bitmap &B, const Rectangle2i &Source, const Rectangle2i &Dest)
{
D3DAlwaysValidate(_Device->GetRenderTargetData(_Surface, _SurfacePlain), "GetRenderTargetData");
if(_SurfaceResizing == NULL)
{
D3DAlwaysValidate(_Device->CreateOffscreenPlainSurface(_Width, _Height, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &_SurfaceResizing, NULL), "CreateOffscreenPlainSurface");
}
D3DAlwaysValidate(_Device->UpdateSurface(_SurfacePlain, NULL, _SurfaceResizing, NULL), "UpdateSurface");
RECT SourceRect = Source.ToRect();
RECT DestRect = Rectangle2i(Vec2i::Origin, Dest.Dimensions()).ToRect();
D3DAlwaysValidate(_Device->StretchRect(_SurfaceResizing, &SourceRect, _Surface, &DestRect, D3DTEXF_LINEAR), "StretchRect");
D3DAlwaysValidate(_Device->GetRenderTargetData(_Surface, _SurfacePlain), "GetRenderTargetData");
D3DLOCKED_RECT LockedRect;
D3DAlwaysValidate(_SurfacePlain->LockRect(&LockedRect, NULL, 0), "LockRect");
Assert(int(B.Width()) >= Dest.Max.x && int(B.Height()) >= Dest.Max.y, "Bitmap too small");
RGBColor *SurfData = (RGBColor*)LockedRect.pBits;
for(int y = Dest.Min.y; y < Dest.Max.y; y++)
{
//memcpy(B[_Height - 1 - y], &SurfData[y * LockedRect.Pitch / 4], _Width * 4);
memcpy(B[y] + Dest.Min.x, &SurfData[(y - Dest.Min.y) * LockedRect.Pitch / 4], Dest.Dimensions().x * 4);
}
_SurfacePlain->UnlockRect();
}
示例8: Build
void BitmapFont::Build() {
if (isBuilt) return;
if (!LoadFontMap()) {
psys->GetLogger("BitmapFont")->Error("Failed to load font map");
return;
}
for(int i=0; i<256; i++) {
if (chardefs[i]->Used()) {
BitmapCharDef *character = chardefs[i];
psys->GetLogger("BitmapFont")->Debug("Char '%c' (X:%d, Y:%d), (W:%d, H:%d)",i,character->X(), character->Y(), character->Width(), character->Height());
Bitmap *bmpChar = bitmap->CopyToNew(character->X(), character->Y(), character->Width(), character->Height());
FontChar *fc = new FontChar(i, 0, 0, bmpChar->Width(), bmpChar->Height(), bmpChar);
//FontChar *fc = new FontChar(i, 0, 0, bitmap->Width(), bitmap->Height(), bitmap);
fc->GenerateTexture();
AddChar(i, fc);
}
}
isBuilt = true;
}
示例9: pixelShouldGetHalo
// Checks each pixel immediately adjacent to the given pixel in the bitmap. If
// any of them are not the halo color, returns true. This defines the halo of
// pixels that will appear around the text. Note that we have to check each
// pixel against both the halo color and transparent since DrawStringWithHalo
// will modify the bitmap as it goes, and clears pixels shouldn't count as
// changed.
static bool pixelShouldGetHalo(const Bitmap& bitmap,
int x, int y, const Color& halo_color)
{
if(x>0 &&
bitmap.GetPixel(x-1, y).GetValue()!=halo_color.GetValue() &&
bitmap.GetPixel(x-1, y).GetValue()!=0)
{
return true; // Touched pixel to the left.
}
if(x<bitmap.Width()-1 &&
bitmap.GetPixel(x+1, y).GetValue()!=halo_color.GetValue() &&
bitmap.GetPixel(x+1, y).GetValue()!=0)
{
return true; // Touched pixel to the right.
}
if(y>0 &&
bitmap.GetPixel(x, y-1).GetValue()!=halo_color.GetValue() &&
bitmap.GetPixel(x, y-1).GetValue()!=0)
{
return true; // Touched pixel above.
}
if(y<bitmap.Height()-1 &&
bitmap.GetPixel(x, y+1).GetValue()!=halo_color.GetValue() &&
bitmap.GetPixel(x, y+1).GetValue()!=0)
{
return true; // Touched pixel below.
}
return false;
}
示例10: contains
boolean UStencil::contains (PointObj& po, Graphic* gs) {
Bitmap* bitmap = (_mask == nil) ? _image : _mask;
PointObj pt (&po);
invTransform(pt._x, pt._y, gs);
BoxObj b (0, 0, bitmap->Width(), bitmap->Height());
return b.Contains(pt);
}
示例11: ReleaseSurface
void Canvas::
SetTo( const Bitmap &image ) {
ReleaseSurface();
activeSurface = SurfaceInfo( BITMAP_TARGET, image.Width(), image.Height(), &image );
SelectImage( image );
FinishSurfaceSelection();
}
示例12: TrainPalette
void ImageCompressorBlockPalette::TrainPalette(const Bitmap &bmp)
{
Vector<const float*> allBlocks;
const UINT width = bmp.Width();
const UINT height = bmp.Height();
for(UINT x = 0; x < width; x += blockDimension)
{
for(UINT y = 0; y < height; y += blockDimension)
{
float *curBlock = new float[blockSize * 3];
UINT curDimensionIndex = 0;
for(UINT yOffset = 0; yOffset < blockDimension; yOffset++)
{
for(UINT xOffset = 0; xOffset < blockDimension; xOffset++)
{
RGBColor curColor = bmp[y + yOffset][x + xOffset];
curBlock[curDimensionIndex++] = curColor.r;
curBlock[curDimensionIndex++] = curColor.g;
curBlock[curDimensionIndex++] = curColor.b;
}
}
allBlocks.PushEnd(curBlock);
}
}
KMeansClusteringFloat<blockSize * 3> clustering;
Vector<KMeansClusteringTierEntry> tierInfo(4);
tierInfo[0] = KMeansClusteringTierEntry(4, 10);
tierInfo[1] = KMeansClusteringTierEntry(4, 10);
tierInfo[2] = KMeansClusteringTierEntry(4, 10);
tierInfo[3] = KMeansClusteringTierEntry(4, 10);
clustering.Cluster(allBlocks, tierInfo, true);
//clustering.Cluster(allBlocks, paletteSize);
//clustering.Cluster(allBlocks, paletteSize, 100);
for(UINT paletteIndex = 0; paletteIndex < paletteSize; paletteIndex++)
{
Block32 &curEntry = _palette.colors[paletteIndex];
const float *curCluster = clustering.ClusterCentroid(paletteIndex);
UINT curDimensionIndex = 0;
for(UINT yOffset = 0; yOffset < blockDimension; yOffset++)
{
for(UINT xOffset = 0; xOffset < blockDimension; xOffset++)
{
RGBColor &curColor = curEntry.c[yOffset][xOffset];
curColor.r = BYTE(curCluster[curDimensionIndex++]);
curColor.g = BYTE(curCluster[curDimensionIndex++]);
curColor.b = BYTE(curCluster[curDimensionIndex++]);
}
}
}
}
示例13: destRect
void
Scrollbar::_DrawTrough(const GFX::rect& screenRect)
{
IE::scrollbar* scrollbar = (IE::scrollbar*)fControl;
Bitmap* frame = const_cast<Bitmap*>(fResource->FrameForCycle(scrollbar->cycle,
scrollbar->trough));
GFX::rect destRect(screenRect.x, screenRect.y + 40,
frame->Width(), frame->Height());
GraphicsEngine::Get()->BlitToScreen(frame, NULL, &destRect);
}
示例14: new
HRESULT
AviFile::AddFrame(const Bitmap& bmp)
{
HRESULT hr = E_FAIL;
if (!iserr && !play && bmp.IsHighColor() && bmp.Width() == rect.w && bmp.Height() == rect.h) {
int w = bmp.Width();
int h = bmp.Height();
BYTE* buffer = new(__FILE__,__LINE__) BYTE[frame_size];
BYTE* dst = buffer;
for (int y = 0; y < bmp.Height(); y++) {
Color* src = bmp.HiPixels() + (h - 1 - y) * w;
for (int x = 0; x < bmp.Width(); x++) {
*dst++ = (BYTE) src->Blue();
*dst++ = (BYTE) src->Green();
*dst++ = (BYTE) src->Red();
src++;
}
}
#pragma warning(suppress: 6001)
hr = AVIStreamWrite(ps_comp, nframe, 1, buffer, frame_size, AVIIF_KEYFRAME, 0, 0);
if (SUCCEEDED(hr)) {
nframe++;
}
else {
Print("AVIStreamWriteFile failed. %08x\n", hr);
iserr = true;
}
delete [] buffer;
}
return hr;
}
示例15: BytesPerLine
Bitmap::Bitmap(const Graphics& g, const Bitmap& bitmap)
{
if (this == &bitmap)
return;
m_platformBitmap = ThePlatformFactory->CreatePlatformBitmap(
g.GetPlatformGraphics(), bitmap.Width(), bitmap.Height(),
bitmap.BitsPerPixel());
uchar* bits = new uchar[Height() * BytesPerLine()];
bitmap.GetBits(g, bits, 0, Height(), BitsPerPixel());
SetBits(g, bits, 0, Height(), BitsPerPixel());
delete[] bits;
}