本文整理汇总了C++中BBitmap::SetBits方法的典型用法代码示例。如果您正苦于以下问题:C++ BBitmap::SetBits方法的具体用法?C++ BBitmap::SetBits怎么用?C++ BBitmap::SetBits使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BBitmap
的用法示例。
在下文中一共展示了BBitmap::SetBits方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BBitmap
BBitmap *RBitmapLoader::ConvertBitmapTo8Bit(BBitmap *source)
{
BRect r;
BBitmap *dest;
float sx,sy;
if (!source) return NULL;
r = source->Bounds();
dest = new BBitmap(r, B_COLOR_8_BIT);
if (!dest) return NULL;
sx = r.Width()+1;
sy = r.Height()+1;
BYTE *sourceBits = (BYTE *)source->Bits();
long sourceBpr = source->BytesPerRow();
color_space sourceCs = source->ColorSpace();
if (sourceCs == B_COLOR_8_BIT)
{
dest->SetBits(sourceBits, sourceBpr, 0, sourceCs);
return dest;
}
else
if (sourceCs != B_RGB_32_BIT)
{
return NULL;
}
BYTE *rvb = ConvertTo24bit(sx, sy, sourceBits, sourceBpr);
dest->SetBits(rvb, sx * sy * 3, 0, B_RGB_32_BIT);
delete rvb;
return dest;
}
示例2: file
BBitmap *GetIcon8FromResource(const char *theResource)
{
// Get application info
app_info info;
be_app->GetAppInfo(&info);
BFile file(&info.ref, O_RDONLY);
if (file.InitCheck())
return NULL;
size_t size;
BBitmap *data;
BResources res(&file);
data = (BBitmap *)res.FindResource('bits', theResource, &size);
if (!data)
return NULL;
// Load icon
BRect bounds;
bounds.Set(0, 0, 7, 7);
BBitmap *bitmap = new BBitmap(bounds, B_COLOR_8_BIT);
ASSERT(bitmap);
bitmap->SetBits(data, size, 0, B_COLOR_8_BIT);
return (bitmap);
}
示例3: mime
// -------------------------------------------------------------------
// * CONSTRUCTORS and DESTRUCTORS
// -------------------------------------------------------------------
DPRegression::DPRegression() : BApplication(data_plus_regr_sig)
{
// Install this app and data file type if necessary
BMimeType mime(data_plus_regr_sig);
if (mime.InitCheck() == B_OK && !mime.IsInstalled()) {
mime.Install();
}
BMimeType dataMime(regrplot_mime_type);
if (dataMime.InitCheck() == B_OK && !dataMime.IsInstalled()) {
dataMime.Install();
// Set the document icons
status_t status;
BBitmap* lgIcon = new BBitmap(BRect(0,0,31,31),B_CMAP8);
lgIcon->SetBits(largeIcon_bits,sizeof(largeIcon_bits),0,B_CMAP8);
status = dataMime.SetIcon(lgIcon,B_LARGE_ICON);
delete lgIcon;
BBitmap* miniIcon = new BBitmap(BRect(0,0,15,15),B_CMAP8);
miniIcon->SetBits(smallIcon_bits,sizeof(smallIcon_bits),0,B_CMAP8);
status = dataMime.SetIcon(miniIcon,B_MINI_ICON);
delete miniIcon;
}
// Make sure data marker is installed
BMimeType markMime(data_plus_marker_sig);
if (markMime.InitCheck() == B_OK && !markMime.IsInstalled()) {
markMime.Install();
}
// We should get preference data for this
mData = new BList();
// Show the regression graph
BRect dataRect;
dataRect.Set(100, 100, 450, 450);
mRegrWindow = new DRRegrWindow(dataRect);
mRegrWindow->Show();
}
示例4: rect
BBitmap *LoadMiniIcon(int32 id) {
BResources *res = BApplication::AppResources();
if (res != NULL) {
size_t length;
const void *bits = res->LoadResource(miniIcon, id, &length);
if ((bits != NULL) && (length == B_MINI_ICON * B_MINI_ICON)) {
BRect rect(0, 0, B_MINI_ICON-1, B_MINI_ICON-1);
BBitmap *bitmap = new BBitmap(rect, B_CMAP8);
bitmap->SetBits(bits, B_MINI_ICON * B_MINI_ICON, 0, B_CMAP8);
return bitmap;
}
}
return NULL;
}
示例5: path
BBitmap *RBitmapLoader::TranslateIcon(int index, const char *name)
{
BPath path(&mAppDir, name);
RIconLoader l;
BBitmap *result = 0;
if (l.Open(path.Path()))
{
ICONDATA *data = l.m_Icon.IconData + index;
ICONENTRY *dir = l.m_Icon.IconDir + index;
RGB *sourcebits = 0;
RGB opacity;
uint32 opaque = B_TRANSPARENT_MAGIC_RGBA32;
opacity = *(RGB*)&opaque;
switch(dir->NumColors) {
case 0: // 256
{
sourcebits = l.Expand8ToRGB(data->XorMap, data->Palette, dir->Width * dir->Height);
}
break;
case 16:
{
sourcebits = l.Expand4ToRGB(data->XorMap, data->Palette, dir->Width * dir->Height);
}
break;
}
l.PreMask(sourcebits, data->AndMap, dir->Width * dir->Height, opacity);
l.InvertY(sourcebits, dir->Width, dir->Height);
result = new BBitmap(BRect(0,0, dir->Width-1, dir->Height-1), B_RGB32);
if (sourcebits)
{
BYTE *rvb = ConvertTo24bit(dir->Width, dir->Height, (BYTE*)sourcebits, dir->Width * 4);
result->SetBits(rvb, dir->Width * dir->Height * 3, 0, B_RGB32);
delete rvb;
}
}
return result;
}
示例6: InitWindow
// HelpTipWindow::InitWindow -- Initialization Commands here
void HelpTipWindow::InitWindow(void)
{
BRect r;
r = Bounds(); // the whole view
char TipTitle[256];
char TipText[150];
char TipText2[150];
BString TipText3;
switch(TipNumber)
{
case 1:
{
sprintf(TipTitle,"BRIE Tip #%i - %s",TipNumber,"Loading Projects");
sprintf(TipText,"%s","Please note we only support the loading of existing BRIE");
sprintf(TipText2,"%s","BRIE projects.");
}
break;
case 2:
{
sprintf(TipTitle,"BRIE Tip #%i - %s",TipNumber,"New Project Name");
sprintf(TipText,"%s","Try giving your New Project a name better than Untitled.");
sprintf(TipText2,"%s","");
TipText3.SetTo("C'mon ... Surely, your life can't be that dull. ;)");
}
break;
case 3:
{
sprintf(TipTitle,"BRIE Tip #%i - %s",TipNumber,"No Project Name");
sprintf(TipText,"%s","You must create a New Project first.");
sprintf(TipText2,"%s","");
TipText3.SetTo("NB: Click on File, then New Project or use the first icon on the Toolbar.");
}
break;
default:
{
strcat(TipTitle,"BRIE Helpful Tips");
}
break;
}
float LeftMarginTitles = 55;
float LeftMargin = 6;
float LeftMarginText = LeftMarginTitles;
float TextTop = 40;
float RightMargin = r.right;
float OkayButtonSize = 70;
float OkayLeftMargin = RightMargin - OkayButtonSize - 10;
rgb_color TipTitleFontColor = { 0,0,255,0 };
stvTipTitle = new BStringView(BRect(LeftMarginTitles, 14, RightMargin, 28), "TipTitle", TipTitle);
stvTipTitle->SetFont(be_bold_font);
stvTipTitle->SetHighColor(TipTitleFontColor);
stvTipText = new BStringView(BRect(LeftMarginText, TextTop, RightMargin, TextTop+10), "Text", TipText);
stvTipText2 = new BStringView(BRect(LeftMarginText, TextTop+13, RightMargin, TextTop+23), "Text2", TipText2);
stvTipText3 = new BStringView(BRect(LeftMarginText, TextTop+28, RightMargin, TextTop+38), "Text3", TipText3.String());
chkDontShowAgain = new BCheckBox(BRect(LeftMargin+8,r.bottom - 25,RightMargin,r.bottom - 13),"chkDontShowAgain","Don't Show this Tip Again", new BMessage(CHK_DONTSHOWAGAIN), B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE);
btnOkay = new BButton(BRect (OkayLeftMargin,r.bottom-35,OkayLeftMargin+OkayButtonSize,r.bottom-15),"Okay","Okay", new BMessage(BTN_OKAY), B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE);
btnOkay->MakeDefault(true);
// create icon of Dr Be ;)
BRect IconFrame (BRect(0,0,31,31));
BRect IconViewLocation (BRect(LeftMargin+2,r.top+10,LeftMargin+48,r.top+55));
BBitmap *drbeicon = new BBitmap(IconFrame,B_RGB32);
drbeicon->SetBits(drbe,3072,0,B_RGB32);
BRIETipIconView* IconView = new BRIETipIconView(drbeicon,IconViewLocation);
IconView->SetDrawingMode(B_OP_OVER);
AddChild(IconView);
AddChild(btnOkay);
AddChild(chkDontShowAgain);
AddChild(stvTipTitle);
AddChild(stvTipText);
AddChild(stvTipText2);
AddChild(stvTipText3);
stvTipTitle->AttachedToWindow();
chkDontShowAgain->AttachedToWindow();
stvTipText->AttachedToWindow();
stvTipText2->AttachedToWindow();
stvTipText3->AttachedToWindow();
// Create the Views
AddChild(ptrHelpTipView = new HelpTipView(r));
}
示例7: malloc
status_t
get_mouse_bitmap(BBitmap** bitmap, BPoint* hotspot)
{
if (bitmap == NULL && hotspot == NULL)
return B_BAD_VALUE;
BPrivate::AppServerLink link;
link.StartMessage(AS_GET_CURSOR_BITMAP);
int32 code;
status_t status = link.FlushWithReply(code);
if (status != B_OK)
return status;
if (code != B_OK)
return code;
uint32 size = 0;
uint32 cursorWidth = 0;
uint32 cursorHeight = 0;
// if link.Read() returns an error, the same error will be returned on
// subsequent calls, so we'll check only the return value of the last call
link.Read<uint32>(&size);
link.Read<uint32>(&cursorWidth);
link.Read<uint32>(&cursorHeight);
if (hotspot == NULL) {
BPoint dummy;
link.Read<BPoint>(&dummy);
} else
link.Read<BPoint>(hotspot);
void* data = NULL;
if (size > 0)
data = malloc(size);
if (data == NULL)
return B_NO_MEMORY;
status = link.Read(data, size);
if (status != B_OK) {
free(data);
return status;
}
BBitmap* cursorBitmap = new (std::nothrow) BBitmap(BRect(0, 0,
cursorWidth - 1, cursorHeight - 1), B_RGBA32);
if (cursorBitmap == NULL) {
free(data);
return B_NO_MEMORY;
}
status = cursorBitmap->InitCheck();
if (status == B_OK)
cursorBitmap->SetBits(data, size, 0, B_RGBA32);
free(data);
if (status == B_OK && bitmap != NULL)
*bitmap = cursorBitmap;
else
delete cursorBitmap;
return status;
}
示例8: new
BBitmap*
BAlert::_InitIcon()
{
// Save the desired alert type and set it to "empty" until
// loading the icon was successful
alert_type alertType = fMsgType;
fMsgType = B_EMPTY_ALERT;
// After a bit of a search, I found the icons in app_server. =P
BBitmap* icon = NULL;
BPath path;
status_t status = find_directory(B_BEOS_SERVERS_DIRECTORY, &path);
if (status < B_OK) {
FTRACE((stderr, "BAlert::_InitIcon() - find_directory failed: %s\n",
strerror(status)));
return NULL;
}
path.Append("app_server");
BFile file;
status = file.SetTo(path.Path(), B_READ_ONLY);
if (status < B_OK) {
FTRACE((stderr, "BAlert::_InitIcon() - BFile init failed: %s\n",
strerror(status)));
return NULL;
}
BResources resources;
status = resources.SetTo(&file);
if (status < B_OK) {
FTRACE((stderr, "BAlert::_InitIcon() - BResources init failed: %s\n",
strerror(status)));
return NULL;
}
// Which icon are we trying to load?
const char* iconName = ""; // Don't want any seg faults
switch (alertType) {
case B_INFO_ALERT:
iconName = "info";
break;
case B_IDEA_ALERT:
iconName = "idea";
break;
case B_WARNING_ALERT:
iconName = "warn";
break;
case B_STOP_ALERT:
iconName = "stop";
break;
default:
// Alert type is either invalid or B_EMPTY_ALERT;
// either way, we're not going to load an icon
return NULL;
}
int32 iconSize = 32 * icon_layout_scale();
// Allocate the icon bitmap
icon = new(std::nothrow) BBitmap(BRect(0, 0, iconSize - 1, iconSize - 1),
0, B_RGBA32);
if (icon == NULL || icon->InitCheck() < B_OK) {
FTRACE((stderr, "BAlert::_InitIcon() - No memory for bitmap\n"));
delete icon;
return NULL;
}
// Load the raw icon data
size_t size = 0;
const uint8* rawIcon;
#ifdef __ANTARES__
// Try to load vector icon
rawIcon = (const uint8*)resources.LoadResource(B_VECTOR_ICON_TYPE,
iconName, &size);
if (rawIcon != NULL
&& BIconUtils::GetVectorIcon(rawIcon, size, icon) == B_OK) {
// We have an icon, restore the saved alert type
fMsgType = alertType;
return icon;
}
#endif
// Fall back to bitmap icon
rawIcon = (const uint8*)resources.LoadResource(B_LARGE_ICON_TYPE,
iconName, &size);
if (rawIcon == NULL) {
FTRACE((stderr, "BAlert::_InitIcon() - Icon resource not found\n"));
delete icon;
return NULL;
}
// Handle color space conversion
#ifdef __ANTARES__
if (icon->ColorSpace() != B_CMAP8) {
BIconUtils::ConvertFromCMAP8(rawIcon, iconSize, iconSize,
iconSize, icon);
}
#else
icon->SetBits(rawIcon, iconSize, 0, B_CMAP8);
//.........这里部分代码省略.........
示例9: InitWindow
// ToolboxWindow::InitWindow -- Initialization Commands here
void ToolboxWindow::InitWindow(void)
{
BRect r;
r = Bounds();
// Add Controls
// Toolbar
//int ToolbarButtonMargin = 2;
//int ToolbarButtonWidth = 22;
//int ButtonGap = 1;
// StringView Button
BRect BitmapFrame (BRect(0,0,23,23));
BPicture *tmpBPicture;
BPicture *tmpBPicture2;
BView *tmpBPictureView = new BView(BitmapFrame, "tmpBPictureView",B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE);
rgb_color toolbar_button_background = { 255, 255, 255, 0 };
AddChild(tmpBPictureView);
BBitmap *stringviewpicture = new BBitmap(BitmapFrame,B_RGB32);
stringviewpicture->SetBits(stringviewicon,1728,0,B_RGB32);
tmpBPictureView->SetLowColor(toolbar_button_background);
tmpBPictureView->BeginPicture(new BPicture);
tmpBPictureView->DrawBitmap(stringviewpicture,BPoint(0,0));
tmpBPicture = tmpBPictureView->EndPicture();
tmpBPictureView->RemoveSelf();
AddChild(tmpBPictureView);
BBitmap *stringviewpicture_state2 = new BBitmap(BitmapFrame,B_RGB32);
stringviewpicture_state2->SetBits(stringviewiconinverse,1728,0,B_RGB32);
tmpBPictureView->SetLowColor(toolbar_button_background);
tmpBPictureView->BeginPicture(new BPicture);
tmpBPictureView->DrawBitmap(stringviewpicture_state2,BPoint(0,0));
tmpBPicture2 = tmpBPictureView->EndPicture();
btnBrieStringViewControl = new BPictureButton(BRect (1,0,24,23),"StringView",tmpBPicture,tmpBPicture2, new BMessage(TOOLBOX_BTN_STRINGVIEWCONTROL),B_ONE_STATE_BUTTON, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE);
tmpBPictureView->RemoveSelf();
AddChild(tmpBPictureView);
//--------------------------------------------------------------------//
// TextView Button
BBitmap *textviewpicture = new BBitmap(BitmapFrame,B_RGB32);
textviewpicture->SetBits(brietextcontrol,1728,0,B_RGB32);
tmpBPictureView->SetLowColor(toolbar_button_background);
tmpBPictureView->BeginPicture(new BPicture);
tmpBPictureView->DrawBitmap(textviewpicture,BPoint(0,0));
tmpBPicture = tmpBPictureView->EndPicture();
tmpBPictureView->RemoveSelf();
AddChild(tmpBPictureView);
BBitmap *textviewpicture_state2 = new BBitmap(BitmapFrame,B_RGB32);
textviewpicture_state2->SetBits(brietextcontrolinverse,1728,0,B_RGB32);
tmpBPictureView->SetLowColor(toolbar_button_background);
tmpBPictureView->BeginPicture(new BPicture);
tmpBPictureView->DrawBitmap(textviewpicture_state2,BPoint(0,0));
tmpBPicture2 = tmpBPictureView->EndPicture();
btnBrieTextControl = new BPictureButton(BRect (26,0,50,23),"TextControl",tmpBPicture,tmpBPicture2, new BMessage(TOOLBOX_BTN_TEXTCONTROL),B_ONE_STATE_BUTTON, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE);
tmpBPictureView->RemoveSelf();
AddChild(tmpBPictureView);
//--------------------------------------------------------------------//
// Button Button
BBitmap *buttonpicture = new BBitmap(BitmapFrame,B_RGB32);
buttonpicture->SetBits(stringviewicon,1728,0,B_RGB32);
tmpBPictureView->SetLowColor(toolbar_button_background);
tmpBPictureView->BeginPicture(new BPicture);
tmpBPictureView->DrawBitmap(buttonpicture,BPoint(0,0));
tmpBPicture = tmpBPictureView->EndPicture();
tmpBPictureView->RemoveSelf();
AddChild(tmpBPictureView);
BBitmap *buttonpicture_state2 = new BBitmap(BitmapFrame,B_RGB32);
buttonpicture_state2->SetBits(stringviewiconinverse,1728,0,B_RGB32);
tmpBPictureView->SetLowColor(toolbar_button_background);
tmpBPictureView->BeginPicture(new BPicture);
tmpBPictureView->DrawBitmap(buttonpicture_state2,BPoint(0,0));
tmpBPicture2 = tmpBPictureView->EndPicture();
btnBrieButtonControl = new BPictureButton(BRect (1,25,24,48),
"Button",tmpBPicture,tmpBPicture2, new BMessage(TOOLBOX_BTN_BUTTONCONTROL),B_ONE_STATE_BUTTON, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE);
tmpBPictureView->RemoveSelf();
AddChild(tmpBPictureView);
//--------------------------------------------------------------------//
// Picture Button
BBitmap *picturepicture = new BBitmap(BitmapFrame,B_RGB32);
picturepicture->SetBits(stringviewicon,1728,0,B_RGB32);
tmpBPictureView->SetLowColor(toolbar_button_background);
tmpBPictureView->BeginPicture(new BPicture);
tmpBPictureView->DrawBitmap(picturepicture,BPoint(0,0));
tmpBPicture = tmpBPictureView->EndPicture();
//.........这里部分代码省略.........
示例10: iconRect
void
DeviceListItem::DrawItem(BView* owner, BRect itemRect, bool complete)
{
rgb_color kBlack = { 0, 0, 0, 0 };
rgb_color kHighlight = { 156, 154, 156, 0 };
if (IsSelected() || complete) {
rgb_color color;
if (IsSelected())
color = kHighlight;
else
color = owner->ViewColor();
owner->SetHighColor(color);
owner->SetLowColor(color);
owner->FillRect(itemRect);
owner->SetHighColor(kBlack);
} else {
owner->SetLowColor(owner->ViewColor());
}
font_height finfo;
be_plain_font->GetHeight(&finfo);
BPoint point = BPoint(itemRect.left + DeviceClass::PixelsForIcon
+ 2 * INSETS, itemRect.bottom - finfo.descent + 1);
owner->SetFont(be_fixed_font);
owner->SetHighColor(kBlack);
owner->MovePenTo(point);
BString secondLine;
secondLine << bdaddrUtils::ToString(fAddress) << " ";
fClass.GetMajorDeviceClass(secondLine);
secondLine << " / ";
fClass.GetMinorDeviceClass(secondLine);
owner->DrawString(secondLine.String());
point -= BPoint(0, (finfo.ascent + finfo.descent + finfo.leading) + INSETS);
owner->SetFont(be_plain_font);
owner->MovePenTo(point);
owner->DrawString(fName.String());
fClass.Draw(owner, BPoint(itemRect.left, itemRect.top));
#if 0
switch (fClass.GetMajorDeviceClass()) {
case 1:
{
BRect iconRect(0, 0, 15, 15);
BBitmap* icon = new BBitmap(iconRect, B_CMAP8);
icon->SetBits(kTVBits, kTVWidth * kTVHeight, 0, kTVColorSpace);
owner->DrawBitmap(icon, iconRect, BRect(itemRect.left + INSETS,
itemRect.top + INSETS, itemRect.left + INSETS + PIXELS_FOR_ICON,
itemRect.top + INSETS + PIXELS_FOR_ICON));
break;
}
case 4:
{
BRect iconRect(0, 0, 15, 15);
BBitmap* icon = new BBitmap(iconRect, B_CMAP8);
icon->SetBits(kMixerBits, kMixerWidth * kMixerHeight, 0, kMixerColorSpace);
owner->DrawBitmap(icon, iconRect, BRect(itemRect.left + INSETS,
itemRect.top + INSETS, itemRect.left + INSETS + PIXELS_FOR_ICON,
itemRect.top + INSETS + PIXELS_FOR_ICON));
break;
}
}
#endif
owner->SetHighColor(kBlack);
}
示例11: BBitmap
BBitmap *targatobbitmap(
const unsigned char* targa, int targasize)
{
BBitmap *bitmap;
int idlength;
int colormaptype;
int imagetype;
int height;
int width;
int depth;
int imagedescriptor;
int rowbytes;
int bitssize;
unsigned char *bits;
const unsigned char *ptarga;
unsigned char *pbits;
int i,j,k;
int count;
unsigned char px0,px1,px2;
idlength=targa[0];
colormaptype=targa[1];
if(colormaptype!=0) return NULL;
imagetype=targa[2];
if(imagetype!=2 && imagetype!=10) return NULL;
width=targa[12]+(targa[13]<<8);
height=targa[14]+(targa[15]<<8);
depth=targa[16];
if(depth!=24) return NULL;
imagedescriptor=targa[17];
if(imagedescriptor!=0) return NULL;
rowbytes=3*width;
bitssize=height*rowbytes;
if(imagetype==2
&& 18+idlength+bitssize>targasize) return NULL;
bits=new unsigned char[bitssize];
if(!bits) return NULL;
ptarga=targa+18+idlength;
switch(imagetype){
case 2:
pbits=bits+(height-1)*rowbytes;
for(j=0;j<height;j++){
for(i=0;i<width;i++){
pbits[2]=*ptarga++;
pbits[1]=*ptarga++;
pbits[0]=*ptarga++;
pbits+=3;
}
pbits-=2*rowbytes;
}
break;
case 10: // RLE
pbits=bits+(height-1)*rowbytes;
for(j=0;j<height;j++){
for(i=0;i<width;i+=count){
count=*ptarga++;
if(count&0x80){
count&=0x7F;
count++;
if(i+count>width) count=width-i;
px2=*ptarga++;
px1=*ptarga++;
px0=*ptarga++;
for(k=0;k<count;k++){
pbits[2]=px2;
pbits[1]=px1;
pbits[0]=px0;
pbits+=3;
}
}else{
count++;
if(i+count>width) count=width-i;
for(k=0;k<count;k++){
pbits[2]=*ptarga++;
pbits[1]=*ptarga++;
pbits[0]=*ptarga++;
pbits+=3;
}
}
}
pbits-=2*rowbytes;
}
break;
}
bitmap=new BBitmap(BRect(0,0,width-1,height-1),B_RGB_32_BIT);
bitmap->SetBits(bits,bitssize,0,B_RGB_32_BIT);
delete[] bits;
//.........这里部分代码省略.........
示例12: main
//.........这里部分代码省略.........
}
case 't':
{
BuiltInTablet = true;
break;
}
case 'h':
{
fprintf (stderr, "Recognized command line options:\n");
fprintf (stderr, " -v Verbose add-on loading (useful for debugging your own)\n");
fprintf (stderr, " -q Verbose quitting\n");
fprintf (stderr, " -x Don't load add-ons (faster launch time)\n");
fprintf (stderr, " -d Use default settings (don't load settings)\n");
fprintf (stderr, " -w Force saving of settings (use with -d)\n");
fprintf (stderr, " -Dn Debug verbosity level\n");
fprintf (stderr, " -Sn Silence level (scripting operation)\n");
fprintf (stderr, " -M Don't use MMX\n");
fprintf (stderr, " -c Show recognized RGB color names at startup\n");
fprintf (stderr, " -C Enable export as C struct\n");
fprintf (stderr, " -t Switch on builtin Wacom tablet support\n");
fprintf (stderr, " -h Display this message\n");
break;
}
default:
fprintf (stderr, "Unrecognized command line option: '%c'\n(Becasso -h displays command line usage help)\n", argv[i][1]);
}
}
}
#if defined (TIME_LIMITED)
struct tm *mytime;
time_t mytimet = time (NULL);
#endif
#if defined (__INTEL__)
if (UseMMX)
UseMMX = mmx_available();
#else
UseMMX = false;
#endif
if (UseMMX)
verbose (1, "MMX detected\n");
else
verbose (1, "No MMX\n");
if (BuiltInTablet)
verbose (1, "Builtin Tablet support enabled\n");
mainapp = new Becasso();
setup_alphabuffer();
if (DebugLevel)
{
extern const char *Version;
fprintf (stderr, "Becasso version %s %s, built %s\n",
Version, (gGlobalAlpha ? "(Registered)" : "(Unregistered)"), __DATE__);
}
size_t bsize, ssize;
void *becassodata, *sumdata;
app_info info;
mainapp->GetAppInfo (&info);
BFile file (&info.ref, O_RDONLY);
BResources res (&file);
if (!(becassodata = res.FindResource ('blog', 128, &bsize)))
fprintf (stderr, "Becasso logo resource not found\n");
if (!(sumdata = res.FindResource ('slog', 129, &ssize)))
fprintf (stderr, "Sum logo resource not found\n");
BScreen screen;
BRect becassorect = BRect (0, 0, 231, 93);
BRect sumrect = BRect (0, 0, 63, 83);
BBitmap *becasso = new BBitmap (becassorect, (screen.ColorSpace() == B_COLOR_8_BIT) ? B_COLOR_8_BIT : B_RGB32);
// This strange color space thing is because we can't store bitmaps in 16 bit depth, so we use
// a 32bit version for this screen mode (which doesn't look too bad).
BBitmap *sum = new BBitmap (sumrect, B_RGB32);
becasso->SetBits (becassodata, bsize, 0, B_RGB32);
sum->SetBits (sumdata, ssize, 0, B_RGB32);
BRect center = BRect (0, 0, 280, 210);
center.OffsetTo (screen.Frame().Width()/2 - 140, screen.Frame().Height()/2 - 105);
splash = new SplashWindow (center, becasso, sum);
splash->Minimize (SilentOperation >= 3);
splash->Show();
mainapp->LoadAddOns();
#if defined (TIME_LIMITED)
mytime = localtime (&mytimet);
// if (mytime->tm_year == 97 && mytime->tm_mon < 11)
if (mytime->tm_year == 97)
mainapp->Run();
else
{
BAlert *alert = new BAlert ("", "This demo version of Becasso has expired.\nOn http://www.sumware.demon.nl you can find info on obtaining a newer version.\nThanks for your interest in Becasso!", "OK", NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT);
alert->Go();
}
#else
mainapp->Run();
#endif
delete mainapp;
// delete BTranslatorRoster::Default();
return 0;
}
示例13: locker
void
ImageView::_UpdateImage()
{
// ToDo: add scroller if necessary?!
BAutolock locker(fEditor);
// we need all the data...
size_t viewSize = fEditor.ViewSize();
// that may need some more memory...
if ((off_t)viewSize < fEditor.FileSize())
fEditor.SetViewSize(fEditor.FileSize());
const char *data;
if (fEditor.GetViewBuffer((const uint8 **)&data) != B_OK) {
fEditor.SetViewSize(viewSize);
return;
}
if (fBitmap != NULL && (fEditor.Type() == B_MINI_ICON_TYPE
|| fEditor.Type() == B_LARGE_ICON_TYPE)) {
// optimize icon update...
fBitmap->SetBits(data, fEditor.FileSize(), 0, B_CMAP8);
fEditor.SetViewSize(viewSize);
return;
}
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
if (fBitmap != NULL && fEditor.Type() == B_VECTOR_ICON_TYPE
&& fScaleSlider->Value() * 8 - 1 == fBitmap->Bounds().Width()) {
if (BIconUtils::GetVectorIcon((const uint8 *)data,
(size_t)fEditor.FileSize(), fBitmap) == B_OK) {
fEditor.SetViewSize(viewSize);
return;
}
}
#endif
delete fBitmap;
fBitmap = NULL;
switch (fEditor.Type()) {
case B_MINI_ICON_TYPE:
fBitmap = new BBitmap(BRect(0, 0, 15, 15), B_CMAP8);
if (fBitmap->InitCheck() == B_OK)
fBitmap->SetBits(data, fEditor.FileSize(), 0, B_CMAP8);
break;
case B_LARGE_ICON_TYPE:
fBitmap = new BBitmap(BRect(0, 0, 31, 31), B_CMAP8);
if (fBitmap->InitCheck() == B_OK)
fBitmap->SetBits(data, fEditor.FileSize(), 0, B_CMAP8);
break;
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
case B_VECTOR_ICON_TYPE:
fBitmap = new BBitmap(BRect(0, 0, fScaleSlider->Value() * 8 - 1,
fScaleSlider->Value() * 8 - 1), B_RGB32);
if (fBitmap->InitCheck() != B_OK
|| BIconUtils::GetVectorIcon((const uint8 *)data,
(size_t)fEditor.FileSize(), fBitmap) != B_OK) {
delete fBitmap;
fBitmap = NULL;
}
break;
#endif
case B_PNG_FORMAT:
{
BMemoryIO stream(data, fEditor.FileSize());
fBitmap = BTranslationUtils::GetBitmap(&stream);
break;
}
case B_MESSAGE_TYPE:
{
BMessage message;
// ToDo: this could be problematic if the data is not large
// enough to contain the message...
if (message.Unflatten(data) == B_OK)
fBitmap = new BBitmap(&message);
break;
}
}
// Update the bitmap description. If no image can be displayed,
// we will show our "unsupported" message
if (fBitmap != NULL && fBitmap->InitCheck() != B_OK) {
delete fBitmap;
fBitmap = NULL;
}
if (fBitmap != NULL) {
char buffer[256];
const char *type = B_TRANSLATE("Unknown type");
switch (fEditor.Type()) {
case B_MINI_ICON_TYPE:
case B_LARGE_ICON_TYPE:
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
case B_VECTOR_ICON_TYPE:
#endif
type = B_TRANSLATE("Icon");
break;
//.........这里部分代码省略.........
示例14: bounds
AboutWindow::AboutWindow ()
: BWindow (BRect (0, 0, 300, 200), "About", B_MODAL_WINDOW,
B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_NOT_RESIZABLE)
{
PRINT (("AboutWindow::AboutWindow ()\n"));
SetFeel (B_MODAL_APP_WINDOW_FEEL);
SetLook (B_MODAL_WINDOW_LOOK);
/* Create the BBitmap objects and set its data with error checking */
BBitmap *appIcon = new BBitmap (BRect (0, 0, kLargeIconWidth - 1, kLargeIconHeight - 1), B_COLOR_8_BIT);
appIcon->SetBits (iconBits, 32 * 32 * 8, 0, B_COLOR_8_BIT);
BBitmap *bmp = BTranslationUtils::GetBitmap ('PNG ', "Image:AboutTitle");
if (bmp == NULL)
{
BAlert *err = new BAlert ("Error", "An error was encountered while "
"trying to load the resource element \"Image:AboutTitle\"\n", "Hmm..",
NULL, NULL, B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_STOP_ALERT);
err->Go();
Hide();
Quit();
QuitRequested();
return;
}
/* Yet another annoying control rendering section :( */
BRect bounds (Bounds());
backView = new BView (bounds.InsetBySelf (1, 1), "AboutWindow:BackView", B_FOLLOW_ALL_SIDES, B_WILL_DRAW);
AddChild (backView);
iconView = new BView (BRect (1.5 * DialogMargin + 3, 1.5 * DialogMargin,
1.5 * DialogMargin + kLargeIconWidth - 1 + 3, 1.5 * DialogMargin + kLargeIconWidth - 1),
"AboutWindow:IconView", B_FOLLOW_LEFT, B_WILL_DRAW);
backView->AddChild (iconView);
iconView->SetViewBitmap (appIcon);
float left = DialogMargin + kLargeIconWidth + 1.5 * ButtonSpacing - 3;
float top = DialogMargin / 2.0;
titleView = new BView (BRect (left, top, 214 + left, 58 + top), "AboutWindow:TitleView",
B_FOLLOW_LEFT, B_WILL_DRAW);
backView->AddChild (titleView);
titleView->SetViewBitmap (bmp);
lineView = new BView (BRect (0, titleView->Frame().bottom + 3, bounds.right, titleView->Frame().bottom + 3),
"AboutWindow:LineView", B_FOLLOW_LEFT, B_WILL_DRAW);
lineView->SetViewColor (128, 128, 128);
backView->AddChild (lineView);
textView = new MarqueeView (BRect (2, lineView->Frame().bottom + ButtonSpacing / 2 + 2,
bounds.right - DialogMargin - 1, bounds.bottom - 2 - ButtonSpacing / 2),
"AboutWindow:CreditsView", BRect (0, 0, bounds.right - DialogMargin, 0),
B_FOLLOW_LEFT, B_WILL_DRAW);
backView->AddChild (textView);
textView->SetStylable (true);
textView->MakeSelectable (false);
textView->MakeEditable (false);
textView->SetAlignment (B_ALIGN_CENTER);
textView->SetViewColor (BePureWhite);
backView->SetViewColor (BePureWhite);
textView->SetFontAndColor (be_plain_font, B_FONT_ALL, &BeJetBlack);
/* Calculate no of '\n's to leave to make the text go to the bottom, calculate the no. of lines */
font_height fntHt;
textView->GetFontHeight (&fntHt);
int32 noOfLines = (int32)(textView->Frame().Height() / fntHt.ascent) - 1;
for (int32 i = 1; i < (int32)noOfLines; i++)
lineFeeds << "\n";
creditsText =
"Freeware, Version " AppVersion "\n"
"Copyright " B_UTF8_COPYRIGHT " 2002 Ramshankar\n\n\n"
CODING "\nRamshankar\n([email protected])\n\n* * *\n\n\n\n\n\n\n\n\n"
THANKS_TO "\n\n"
BUBBLEHELP "\nMarco Nelissen\n\n"
BESHARE "\nJeremy Friesner\n\n"
"Thank you all for your\n"
"contributions with the code...\n\n* * *\n\n\n\n\n\n\n\n\n"
"Also thanks to\n\n"
"John Trujillo\nSebastian Benner\nM Floro\n\n"
"for your support and contributions...\n\n* * *\n\n\n\n\n\n\n\n\n"
"A special round of applause\n"
"to BeShare members (in no\n"
"particular order) :\n\n"
"lillo\nshatty\nProcton\n"
"Bryan\nPahtz\nmmu_man\nBeMikko\nNeil\nskiBUM\nand "
"others\n\n"
"for being so good... :)\n\n* * *\n\n\n\n\n\n\n\n\n"
LEGAL_MUMBO_JUMBO "\n\n"
"This program is distributed under\n"
"its own license, and the gist of\n"
"the license is attached to each\n"
"source file of this program\n\n"
"For third party code, the license's\n"
"terms and conditions are explicitly\n"
"stated and the author disclaimed of\n"
"any and all liabilities\n\n"
"For the full license read the\n"
//.........这里部分代码省略.........
示例15: constructCommandBox
BView* PrefsWindow::constructCommandBox(BRect frame)
{
BBox* commandBox = new BBox(frame);
commandBox->SetLabel("Commands");
float offset = 30.0f,
bwidth = 80.0f,
bheight = 30.0f,
bspacing = 10.0f,
globalTcOffset = 45.0f,
bitoffset = 45.0,
secOffset = 170.0f
;
BRect textCtrlFrame(offset / 2.0f, offset, offset / 2.0f + 300.0f, offset + 20.0f);
BStringView *textCtrlInfo = new BStringView(textCtrlFrame, "info", "The \'$\' represents the filename in filename.tex");
commandBox->AddChild(textCtrlInfo);
BRect bitRect(offset / 2.0f, offset + globalTcOffset, offset / 2.0f + 31.0f, offset + 31.0f + globalTcOffset);
BRect secCol(bitRect);
secCol.OffsetBy(secOffset, 0.0f);
secCol.OffsetBy(0.0f, bitoffset);
float textCtrlWidth = 100.0f,
textCtrlHeight = 20.0f,
textCtrlCo = 6.0f
;
BRect bitctrlRect(offset / 2.0f + bitoffset, offset + textCtrlCo + globalTcOffset, offset / 2.0f + bitoffset + textCtrlWidth, textCtrlCo + offset + textCtrlHeight + globalTcOffset);
BRect secColCtrl(bitctrlRect);
secColCtrl.OffsetBy(secOffset, 0.0f);
secColCtrl.right += 50.0f;
//tex to dvi
BRect bitmapFrame(0.0f, 0.0f, 31.0f, 31.0f);
BBitmap *texDviBitmap = new BBitmap(bitmapFrame, B_CMAP8);
texDviBitmap->SetBits(IconTexToDVI, 3072, 0, B_CMAP8);
commandBox->AddChild(new BitmapView(bitRect, texDviBitmap));
BTextControl *texDviCtrl = new BTextControl(bitctrlRect, K_LATEX_CMD, NULL, "", GetPrefsMessage(K_LATEX_CMD));
commandBox->AddChild(texDviCtrl);
bitctrlRect.OffsetBy(0.0f, bitoffset);
//dvi to pdf
bitRect.OffsetBy(0.0f, bitoffset);
BBitmap* dviPdfBitmap = new BBitmap(bitmapFrame, B_CMAP8);
dviPdfBitmap->SetBits(IconDVIToPDF, 3072, 0, B_CMAP8);
commandBox->AddChild(new BitmapView(bitRect, dviPdfBitmap));
BTextControl *dviPdfCtrl = new BTextControl(bitctrlRect, K_DVIPDF_CMD, NULL, "", GetPrefsMessage(K_DVIPDF_CMD));
commandBox->AddChild(dviPdfCtrl);
bitctrlRect.OffsetBy(0.0f, bitoffset);
//dvi to ps
bitRect.OffsetBy(0.0f, bitoffset);
BBitmap* dviPsBitmap = new BBitmap(bitmapFrame, B_CMAP8);
dviPsBitmap->SetBits(IconDVIToPS, 3072, 0, B_CMAP8);
commandBox->AddChild(new BitmapView(bitRect, dviPsBitmap));
BTextControl *dviPsCtrl = new BTextControl(bitctrlRect, K_DVIPS_CMD, NULL, "", GetPrefsMessage(K_DVIPS_CMD));
commandBox->AddChild(dviPsCtrl);
bitctrlRect.OffsetBy(0.0f, bitoffset);
//ps to pdf
bitRect.OffsetBy(0.0f, bitoffset);
BBitmap* psPdfBitmap = new BBitmap(bitmapFrame, B_CMAP8);
psPdfBitmap->SetBits(IconPSToPDF, 3072, 0, B_CMAP8);
commandBox->AddChild(new BitmapView(bitRect, psPdfBitmap));
BTextControl *psPdfCtrl = new BTextControl(bitctrlRect, K_PS2PDF_CMD, NULL, "", GetPrefsMessage(K_PS2PDF_CMD));
commandBox->AddChild(psPdfCtrl);
bitctrlRect.OffsetBy(0.0f, bitoffset);
//tex to pdf
bitRect.OffsetBy(0.0f, bitoffset);
BBitmap* texPdfBitmap = new BBitmap(bitmapFrame, B_CMAP8);
texPdfBitmap->SetBits(IconTexToPDF,3072,0,B_CMAP8);
commandBox->AddChild(new BitmapView(bitRect, texPdfBitmap));
BTextControl *texPdfCtrl = new BTextControl(bitctrlRect, K_PDFLATEX_CMD, NULL, "", GetPrefsMessage(K_PDFLATEX_CMD));
commandBox->AddChild(texPdfCtrl);
bitctrlRect.OffsetBy(0.0f, bitoffset);
//tex to html
bitRect.OffsetBy(0.0f, bitoffset);
BBitmap* texHtmlBitmap = new BBitmap(bitmapFrame, B_CMAP8);
texHtmlBitmap->SetBits(IconTexToHTML, 3072, 0, B_CMAP8);
commandBox->AddChild(new BitmapView(bitRect, texHtmlBitmap));
BTextControl *texHtmlCtrl = new BTextControl(bitctrlRect, K_LATEX2HTML_CMD, NULL, "", GetPrefsMessage(K_LATEX2HTML_CMD));
commandBox->AddChild(texHtmlCtrl);
bitctrlRect.OffsetBy(0.0f, bitoffset);
//ps
bitRect.OffsetBy(0.0f, bitoffset);
BBitmap* postScriptBitmap = new BBitmap(bitmapFrame, B_CMAP8);
postScriptBitmap->SetBits(IconPrevPS, 3072, 0, B_CMAP8);
commandBox->AddChild(new BitmapView(secCol, postScriptBitmap));
BTextControl *postScriptCtrl = new BTextControl(secColCtrl, K_POSTSCRIPT_CMD, NULL, "", GetPrefsMessage(K_POSTSCRIPT_CMD));
//.........这里部分代码省略.........