void BBackView::flush() { BBitmap * bmp = Bitmap(); if(LockLooper()) { backView->Flush(); SetViewBitmap(bmp, B_FOLLOW_NONE, 0); Invalidate(); UnlockLooper(); } }
void CMassView::FrameResized(float neww, float newh) { if (neww < 32 || newh < 32) return; CELL_SIZE = std::min(Bounds().Width()/DEFAULT_N_COLS, Bounds().Height()/DEFAULT_N_ROWS); //BRect bitampSize(0, 0, CELL_SIZE * DEFAULT_N_COLS, CELL_SIZE * DEFAULT_N_ROWS); BRect bitmapSize = Bounds(); theBlitMap = new BBitmap(bitmapSize, B_RGB_32_BIT, true); // create blitmap theBlitView = new CMassBlitView(bitmapSize, "BlitView", theBitmaps, theBlitMap); // create the blitview theBlitView->theBoard = theBoard; // TODO ? set this to true in OpenGL mode ? (and use a 512x512 rect ?) theBlitView->isOpenGL = false; // and start in OpenGL mode theBlitMap->AddChild(theBlitView); // add the blitview to the blitmap theBlitView->Generate(); // fill in the blitmap SetViewBitmap(theBlitMap, B_FOLLOW_TOP | B_FOLLOW_LEFT, false); }
void HalftonePreviewView::preview(float gamma, float min, Halftone::DitherType ditherType, bool color) { const color_space kColorSpace = B_RGB32; const float right = Bounds().Width(); const float bottom = Bounds().Height(); BRect rect(0, 0, right, bottom); BBitmap testImage(rect, kColorSpace, true); BBitmap preview(rect, kColorSpace); BView view(rect, "", B_FOLLOW_ALL, B_WILL_DRAW); // create test image testImage.Lock(); testImage.AddChild(&view); // color bars const int height = Bounds().IntegerHeight()+1; const int width = Bounds().IntegerWidth()+1; const int delta = height / 4; const float red_bottom = delta - 1; const float green_bottom = red_bottom + delta; const float blue_bottom = green_bottom + delta; const float gray_bottom = height - 1; for (int x = 0; x <= right; x ++) { uchar value = x * 255 / width; BPoint from(x, 0); BPoint to(x, red_bottom); // red view.SetHighColor(255, value, value); view.StrokeLine(from, to); // green from.y = to.y+1; to.y = green_bottom; view.SetHighColor(value, 255, value); view.StrokeLine(from, to); // blue from.y = to.y+1; to.y = blue_bottom; view.SetHighColor(value, value, 255); view.StrokeLine(from, to); // gray from.y = to.y+1; to.y = gray_bottom; view.SetHighColor(value, value, value); view.StrokeLine(from, to); } view.Sync(); testImage.RemoveChild(&view); testImage.Unlock(); // create preview image Halftone halftone(kColorSpace, gamma, min, ditherType); halftone.setBlackValue(Halftone::kLowValueMeansBlack); const int widthBytes = (width + 7) / 8; // byte boundary uchar* buffer = new uchar[widthBytes]; const uchar* src = (uchar*)testImage.Bits(); uchar* dstRow = (uchar*)preview.Bits(); const int numPlanes = color ? 3 : 1; if (color) { halftone.setPlanes(Halftone::kPlaneRGB1); } for (int y = 0; y < height; y ++) { for (int plane = 0; plane < numPlanes; plane ++) { // halftone the preview image halftone.dither(buffer, src, 0, y, width); // convert the plane(s) to RGB32 ColorRGB32Little* dst = (ColorRGB32Little*)dstRow; const uchar* bitmap = buffer; for (int x = 0; x < width; x ++, dst ++) { const int bit = 7 - (x % 8); const bool isSet = (*bitmap & (1 << bit)) != 0; uchar value = isSet ? 255 : 0; if (color) { switch (plane) { case 0: dst->red = value; break; case 1: dst->green = value; break; case 2: dst->blue = value; break; } } else { dst->red = dst->green = dst->blue = value; } if (bit == 0) { bitmap ++; } } } // next row src += testImage.BytesPerRow(); dstRow += preview.BytesPerRow(); } delete[] buffer; SetViewBitmap(&preview); Invalidate(); }
//***************************************************** void PointersView::AttachedToWindow() { SetViewBitmap(BTranslationUtils::GetBitmapFile("./Bitmaps/PointerView.png"), B_FOLLOW_ALL); }