本文整理汇总了C++中BBitmap::BytesPerRow方法的典型用法代码示例。如果您正苦于以下问题:C++ BBitmap::BytesPerRow方法的具体用法?C++ BBitmap::BytesPerRow怎么用?C++ BBitmap::BytesPerRow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BBitmap
的用法示例。
在下文中一共展示了BBitmap::BytesPerRow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WriteMonoRGBASpanBack
void MesaDriver::WriteMonoRGBASpanBack(const GLcontext *ctx, GLuint n,
GLint x, GLint y,
const GLchan color[4], const GLubyte mask[])
{
MesaDriver *md = (MesaDriver *) ctx->DriverCtx;
BBitmap *bitmap = md->m_bitmap;
assert(bitmap);
int row = md->m_bottom - y;
uint8 * ptr = (uint8 *) bitmap->Bits() + (row * bitmap->BytesPerRow()) + x * 4;
uint32 * pixel = (uint32 *) ptr;
uint32 pixel_color = PACK_B_RGBA32(color);
if (mask) {
while(n--) {
if (*mask++)
*pixel = pixel_color;
pixel++;
};
} else {
while(n--) {
*pixel++ = pixel_color;
};
};
}
示例2: CopyPixelsIn
status_t MesaDriver::CopyPixelsIn(BBitmap *bitmap, BPoint location)
{
color_space scs = bitmap->ColorSpace();
color_space dcs = m_bitmap->ColorSpace();
if (scs != dcs && (dcs != B_RGBA32 || scs != B_RGB32)) {
printf("CopyPixelsIn(): incompatible color space: %s != %s\n",
color_space_name(scs),
color_space_name(dcs));
return B_BAD_TYPE;
}
// debugger("CopyPixelsIn()");
BRect sr = bitmap->Bounds();
BRect dr = m_bitmap->Bounds();
sr = sr & dr.OffsetBySelf(location);
dr = sr.OffsetByCopy(-location.x, -location.y);
uint8 *ps = (uint8 *) bitmap->Bits();
uint8 *pd = (uint8 *) m_bitmap->Bits();
uint32 *s, *d;
uint32 y;
for (y = (uint32) sr.top; y <= (uint32) sr.bottom; y++) {
s = (uint32 *) (ps + y * bitmap->BytesPerRow());
s += (uint32) sr.left;
d = (uint32 *) (pd + (y + (uint32) (dr.top - sr.top)) * m_bitmap->BytesPerRow());
d += (uint32) dr.left;
memcpy(d, s, dr.IntegerWidth() * 4);
}
return B_OK;
}
示例3: WriteRGBSpanBack
void MesaDriver::WriteRGBSpanBack(const GLcontext *ctx, GLuint n,
GLint x, GLint y,
CONST GLubyte rgb[][3],
const GLubyte mask[])
{
MesaDriver *md = (MesaDriver *) ctx->DriverCtx;
BBitmap *bitmap = md->m_bitmap;
assert(bitmap);
int row = md->m_bottom - y;
uint8 * ptr = (uint8 *) bitmap->Bits() + (row * bitmap->BytesPerRow()) + x * 4;
uint32 * pixel = (uint32 *) ptr;
if (mask) {
while(n--) {
if (*mask++)
*pixel = PACK_B_RGB32(rgb[0]);
pixel++;
rgb++;
};
} else {
while(n--) {
*pixel++ = PACK_B_RGB32(rgb[0]);
rgb++;
};
};
}
示例4: GetSrcImage
BBitmap*
ImageProcessor::CreateDestImage(BBitmap* /* srcImage */)
{
color_space cs;
BBitmap* bm;
BRect rect;
if (GetSrcImage() == NULL) return NULL;
cs = GetSrcImage()->ColorSpace();
fBPP = BytesPerPixel(cs);
if (fBPP < 1) return NULL;
fWidth = GetSrcImage()->Bounds().IntegerWidth();
fHeight = GetSrcImage()->Bounds().IntegerHeight();
if (fOp == kRotateClockwise || fOp == kRotateCounterClockwise) {
rect.Set(0, 0, fHeight, fWidth);
} else {
rect.Set(0, 0, fWidth, fHeight);
}
bm = new BBitmap(rect, cs);
if (!IsBitmapValid(bm)) {
delete bm;
return NULL;
}
fSrcBPR = GetSrcImage()->BytesPerRow();
fDestBPR = bm->BytesPerRow();
return bm;
}
示例5: message
status_t
RemoteDrawingEngine::ReadBitmap(ServerBitmap* bitmap, bool drawCursor,
BRect bounds)
{
if (_AddCallback() != B_OK)
return B_UNSUPPORTED;
RemoteMessage message(NULL, fHWInterface->SendBuffer());
message.Start(RP_READ_BITMAP);
message.Add(fToken);
message.Add(bounds);
message.Add(drawCursor);
if (message.Flush() != B_OK)
return B_UNSUPPORTED;
status_t result;
do {
result = acquire_sem_etc(fResultNotify, 1, B_RELATIVE_TIMEOUT,
100 * 1000 * 1000);
} while (result == B_INTERRUPTED);
if (result != B_OK)
return result;
BBitmap* read = fReadBitmapResult;
if (read == NULL)
return B_UNSUPPORTED;
result = bitmap->ImportBits(read->Bits(), read->BitsLength(),
read->BytesPerRow(), read->ColorSpace());
delete read;
return result;
}
示例6: r
BBitmap *
TransportButton::MakeBitmap(uint32 mask)
{
BRect r(Bounds());
BBitmap *result = new BBitmap(r, B_CMAP8);
uint8* src = (uint8*)BitsForMask(mask);
if (src && result && result->IsValid()) {
// int32 width = r.IntegerWidth() + 1;
int32 height = r.IntegerHeight() + 1;
int32 bpr = result->BytesPerRow();
uint8* dst = (uint8*)result->Bits();
// copy source bits into bitmap line by line,
// taking possible alignment into account
// since the source data has been generated
// by QuickRes, it still contains aligment too
// (hence skipping bpr and not width bytes)
for (int32 y = 0; y < height; y++) {
memcpy(dst, src, bpr);
src += bpr;
dst += bpr;
}
ReplaceTransparentColor(result, Parent()->ViewColor());
} else {
delete result;
result = NULL;
}
return result;
}
示例7:
int32
get_bitmap_bytes_per_row(const Bitmap *bitmap)
{
BBitmap *bb = (BBitmap*)bitmap;
if (bb)
return bb->BytesPerRow();
return 0;
}
示例8: new
// SetIcon
status_t
IconButton::SetIcon(const unsigned char* bitsFromQuickRes,
uint32 width, uint32 height, color_space format, bool convertToBW)
{
status_t status = B_BAD_VALUE;
if (bitsFromQuickRes && width > 0 && height > 0) {
BBitmap* quickResBitmap = new(nothrow) BBitmap(BRect(0.0, 0.0, width - 1.0, height - 1.0), format);
status = quickResBitmap ? quickResBitmap->InitCheck() : B_ERROR;
if (status >= B_OK) {
// It doesn't look right to copy BitsLength() bytes, but bitmaps
// exported from QuickRes still contain their padding, so it is alright.
memcpy(quickResBitmap->Bits(), bitsFromQuickRes, quickResBitmap->BitsLength());
if (format != B_RGB32 && format != B_RGBA32 && format != B_RGB32_BIG && format != B_RGBA32_BIG) {
// colorspace needs conversion
BBitmap* bitmap = new(nothrow) BBitmap(quickResBitmap->Bounds(), B_RGB32, true);
if (bitmap && bitmap->IsValid()) {
BView* helper = new BView(bitmap->Bounds(), "helper",
B_FOLLOW_NONE, B_WILL_DRAW);
if (bitmap->Lock()) {
bitmap->AddChild(helper);
helper->SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR));
helper->FillRect(helper->Bounds());
helper->SetDrawingMode(B_OP_OVER);
helper->DrawBitmap(quickResBitmap, BPoint(0.0, 0.0));
helper->Sync();
bitmap->Unlock();
}
status = _MakeBitmaps(bitmap);
} else
printf("IconButton::SetIcon() - B_RGB32 bitmap is not valid\n");
delete bitmap;
} else {
// native colorspace (32 bits)
if (convertToBW) {
// convert to gray scale icon
uint8* bits = (uint8*)quickResBitmap->Bits();
uint32 bpr = quickResBitmap->BytesPerRow();
for (uint32 y = 0; y < height; y++) {
uint8* handle = bits;
uint8 gray;
for (uint32 x = 0; x < width; x++) {
gray = uint8((116 * handle[0] + 600 * handle[1] + 308 * handle[2]) / 1024);
handle[0] = gray;
handle[1] = gray;
handle[2] = gray;
handle += 4;
}
bits += bpr;
}
}
status = _MakeBitmaps(quickResBitmap);
}
} else
printf("IconButton::SetIcon() - error allocating bitmap: %s\n", strerror(status));
delete quickResBitmap;
}
return status;
}
示例9: WriteRGBAPixelsBack
void MesaDriver::WriteRGBAPixelsBack(const GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
CONST GLubyte rgba[][4],
const GLubyte mask[] )
{
MesaDriver *md = (MesaDriver *) ctx->DriverCtx;
BBitmap *bitmap = md->m_bitmap;
assert(bitmap);
#if 0
while(n--) {
if (*mask++) {
int row = md->m_bottom - *y;
uint8 * pixel = (uint8 *) bitmap->Bits() + (row * bitmap->BytesPerRow()) + *x * 4;
*((uint32 *) pixel) = PACK_B_RGBA32(rgba[0]);
};
x++;
y++;
rgba++;
};
#else
if (mask) {
for (GLuint i = 0; i < n; i++) {
if (mask[i]) {
GLubyte *pixel = (GLubyte *) bitmap->Bits()
+ ((md->m_bottom - y[i]) * bitmap->BytesPerRow()) + x[i] * 4;
pixel[BE_RCOMP] = rgba[i][RCOMP];
pixel[BE_GCOMP] = rgba[i][GCOMP];
pixel[BE_BCOMP] = rgba[i][BCOMP];
pixel[BE_ACOMP] = rgba[i][ACOMP];
}
}
}
else {
for (GLuint i = 0; i < n; i++) {
GLubyte *pixel = (GLubyte *) bitmap->Bits()
+ ((md->m_bottom - y[i]) * bitmap->BytesPerRow()) + x[i] * 4;
pixel[BE_RCOMP] = rgba[i][RCOMP];
pixel[BE_GCOMP] = rgba[i][GCOMP];
pixel[BE_BCOMP] = rgba[i][BCOMP];
pixel[BE_ACOMP] = rgba[i][ACOMP];
}
}
#endif
}
示例10: Refresh
void Window::Refresh(int x, int y, int w, int h) {
int32* d = (int32*)_offscreen->Bits();
int32* dl = d;
uint8* s = (uint8*)_bitmap->Bits();
uint8* sl = s;
if (Lock()) {
switch(_surface->root.bitmap.mode) {
case gr_pixel_mode_mono:
for (y = 0; y < _surface->root.bitmap.rows; y++) {
sl = s;
dl = d;
for (x = 0; x < _surface->root.bitmap.width; x++) {
*dl = *sl ? -1 : 0;
sl++; dl++;
}
s += _bitmap->BytesPerRow();
d = (int32*)(((char*)d) + _offscreen->BytesPerRow());
}
break;
case gr_pixel_mode_gray:
for (y = 0; y < _surface->root.bitmap.rows; y++) {
sl = s;
int8* dx = (int8*)d;
for (x = 0; x < _surface->root.bitmap.width; x++) {
*dx = *sl; dx++;
*dx = *sl; dx++;
*dx = *sl; dx++;
*dx = *sl; dx++;
sl++;
}
s += _bitmap->BytesPerRow();
d = (int32*)(((char*)d) + _offscreen->BytesPerRow());
}
break;
default:
fprintf(stderr, "unsupported mode: %d\n", _surface->root.bitmap.mode);
break;
}
_view->Invalidate();
Unlock();
}
}
示例11: WriteMonoRGBAPixelsBack
void MesaDriver::WriteMonoRGBAPixelsBack(const GLcontext *ctx, GLuint n,
const GLint x[], const GLint y[],
const GLchan color[4],
const GLubyte mask[])
{
MesaDriver *md = (MesaDriver *) ctx->DriverCtx;
BBitmap *bitmap = md->m_bitmap;
assert(bitmap);
uint32 pixel_color = PACK_B_RGBA32(color);
#if 0
while(n--) {
if (*mask++) {
int row = md->m_bottom - *y;
uint8 * pixel = (uint8 *) bitmap->Bits() + (row * bitmap->BytesPerRow()) + *x * 4;
*((uint32 *) pixel) = pixel_color;
};
x++;
y++;
};
#else
if (mask) {
for (GLuint i = 0; i < n; i++) {
if (mask[i]) {
GLubyte * ptr = (GLubyte *) bitmap->Bits()
+ ((md->m_bottom - y[i]) * bitmap->BytesPerRow()) + x[i] * 4;
*((uint32 *) ptr) = pixel_color;
}
}
}
else {
for (GLuint i = 0; i < n; i++) {
GLubyte * ptr = (GLubyte *) bitmap->Bits()
+ ((md->m_bottom - y[i]) * bitmap->BytesPerRow()) + x[i] * 4;
*((uint32 *) ptr) = pixel_color;
}
}
#endif
}
示例12: BBitmap
/*!
\brief Creates a new BBitmap from R5 cursor data
\param data Pointer to data in the R5 cursor data format
\return NULL if data was NULL, otherwise a new BBitmap
BBitmaps returned by this function are always in the RGBA32 color space
*/
BBitmap *
CursorSet::_CursorDataToBitmap(uint8 *data)
{
// 68-byte array used in R5 for holding cursors.
// This API has serious problems and should be deprecated(but supported) in R2
// Now that we have all the setup, we're going to map (for now) the cursor
// to RGBA32. Eventually, there will be support for 16 and 8-bit depths
if (data) {
BBitmap *bmp = new BBitmap(BRect(0,0,15,15),B_RGBA32,0);
uint32 black = 0xFF000000, white=0xFFFFFFFF, *bmppos;
uint16 *cursorpos, *maskpos, cursorflip, maskflip;
uint16 cursorval, maskval, powval;
uint8 i, j, *_buffer;
_buffer=(uint8*)bmp->Bits();
cursorpos=(uint16*)(data+4);
maskpos=(uint16*)(data+36);
// for each row in the cursor data
for (j = 0; j < 16; j++) {
bmppos = (uint32*)(_buffer+ (j*bmp->BytesPerRow()) );
// On intel, our bytes end up swapped, so we must swap them back
cursorflip = (cursorpos[j] & 0xFF) << 8;
cursorflip |= (cursorpos[j] & 0xFF00) >> 8;
maskflip = (maskpos[j] & 0xFF) << 8;
maskflip |= (maskpos[j] & 0xFF00) >> 8;
// for each column in each row of cursor data
for (i = 0; i < 16; i++) {
// Get the values and dump them to the bitmap
powval = 1 << (15-i);
cursorval = cursorflip & powval;
maskval = maskflip & powval;
bmppos[i] = (cursorval != 0 ? black : white)
& (maskval > 0 ? 0xFFFFFFFF : 0x00FFFFFF);
}
}
return bmp;
}
return NULL;
}
示例13:
void
RemoteMessage::AddBitmap(const BBitmap& bitmap)
{
BRect bounds = bitmap.Bounds();
Add(bounds.IntegerWidth() + 1);
Add(bounds.IntegerHeight() + 1);
Add(bitmap.BytesPerRow());
Add(bitmap.ColorSpace());
Add(bitmap.Flags());
uint32 bitsLength = bitmap.BitsLength();
Add(bitsLength);
if (!_MakeSpace(bitsLength))
return;
memcpy(fBuffer + fWriteIndex, bitmap.Bits(), bitsLength);
fWriteIndex += bitsLength;
fAvailable -= bitsLength;
}
示例14: new
BBitmap*
BIconButton::Bitmap() const
{
BBitmap* bitmap = NULL;
if (fNormalBitmap && fNormalBitmap->IsValid()) {
bitmap = new(std::nothrow) BBitmap(fNormalBitmap);
if (bitmap != NULL && bitmap->IsValid()) {
// TODO: remove this functionality when we use real transparent
// bitmaps
uint8* bits = (uint8*)bitmap->Bits();
uint32 bpr = bitmap->BytesPerRow();
uint32 width = bitmap->Bounds().IntegerWidth() + 1;
uint32 height = bitmap->Bounds().IntegerHeight() + 1;
color_space format = bitmap->ColorSpace();
if (format == B_CMAP8) {
// replace gray with magic transparent index
} else if (format == B_RGB32) {
for (uint32 y = 0; y < height; y++) {
uint8* bitsHandle = bits;
for (uint32 x = 0; x < width; x++) {
if (bitsHandle[0] == 216
&& bitsHandle[1] == 216
&& bitsHandle[2] == 216) {
// make this pixel completely transparent
bitsHandle[3] = 0;
}
bitsHandle += 4;
}
bits += bpr;
}
}
} else {
delete bitmap;
bitmap = NULL;
}
}
return bitmap;
}
示例15: fillBitmap
static void fillBitmap(BBitmap &bitmap) {
int32 height = bitmap.Bounds().IntegerHeight()+1;
int32 width = bitmap.Bounds().IntegerWidth()+1;
for (int32 y = 0; y < height; y ++) {
for (int32 x = 0; x < width; x ++) {
char *pixel = (char*)bitmap.Bits();
pixel += bitmap.BytesPerRow() * y + 4 * x;
if (isBorder(x, y, width, height)) {
// fill with green
pixel[0] = 255;
pixel[1] = 0;
pixel[2] = 255;
pixel[3] = 0;
} else {
// fill with blue
pixel[0] = 255;
pixel[1] = 0;
pixel[2] = 0;
pixel[3] = 255;
}
}
}
}