本文整理汇总了C++中Bitmap::GetCompatibleColor方法的典型用法代码示例。如果您正苦于以下问题:C++ Bitmap::GetCompatibleColor方法的具体用法?C++ Bitmap::GetCompatibleColor怎么用?C++ Bitmap::GetCompatibleColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bitmap
的用法示例。
在下文中一共展示了Bitmap::GetCompatibleColor方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw_text_window
void draw_text_window(Bitmap **text_window_ds, bool should_free_ds,
int*xins,int*yins,int*xx,int*yy,int*wii, color_t *set_text_color, int ovrheight, int ifnum) {
Bitmap *ds = *text_window_ds;
if (ifnum < 0)
ifnum = game.options[OPT_TWCUSTOM];
if (ifnum <= 0) {
if (ovrheight)
quit("!Cannot use QFG4 style options without custom text window");
draw_button_background(ds, 0,0,ds->GetWidth() - 1,ds->GetHeight() - 1,NULL);
if (set_text_color)
*set_text_color = ds->GetCompatibleColor(16);
xins[0]=3;
yins[0]=3;
}
else {
if (ifnum >= game.numgui)
quitprintf("!Invalid GUI %d specified as text window (total GUIs: %d)", ifnum, game.numgui);
if (!guis[ifnum].IsTextWindow())
quit("!GUI set as text window but is not actually a text window GUI");
int tbnum = get_but_pic(&guis[ifnum], 0);
wii[0] += get_textwindow_border_width (ifnum);
xx[0]-=spritewidth[tbnum];
yy[0]-=spriteheight[tbnum];
if (ovrheight == 0)
ovrheight = disp.fulltxtheight;
if (should_free_ds)
delete *text_window_ds;
int padding = get_textwindow_padding(ifnum);
*text_window_ds = BitmapHelper::CreateTransparentBitmap(wii[0],ovrheight+(padding*2)+spriteheight[tbnum]*2,System_GetColorDepth());
ds = SetVirtualScreen(*text_window_ds);
int xoffs=spritewidth[tbnum],yoffs=spriteheight[tbnum];
draw_button_background(ds, xoffs,yoffs,(ds->GetWidth() - xoffs) - 1,(ds->GetHeight() - yoffs) - 1,&guis[ifnum]);
if (set_text_color)
*set_text_color = ds->GetCompatibleColor(guis[ifnum].FgColor);
xins[0]=xoffs+padding;
yins[0]=yoffs+padding;
}
}
示例2: DrawingSurface_DrawString
void DrawingSurface_DrawString(ScriptDrawingSurface *sds, int xx, int yy, int font, const char* text)
{
sds->MultiplyCoordinates(&xx, &yy);
Bitmap *ds = sds->StartDrawing();
// don't use wtextcolor because it will do a 16->32 conversion
color_t text_color = sds->currentColour;
if ((ds->GetColorDepth() <= 8) && (play.raw_color > 255)) {
text_color = ds->GetCompatibleColor(1);
debug_script_warn ("RawPrint: Attempted to use hi-color on 256-col background");
}
wouttext_outline(ds, xx, yy, font, text_color, text);
sds->FinishedDrawing();
}
示例3: draw_text_window_and_bar
void draw_text_window_and_bar(Bitmap **text_window_ds, bool should_free_ds,
int*xins,int*yins,int*xx,int*yy,int*wii,color_t *set_text_color,int ovrheight, int ifnum) {
draw_text_window(text_window_ds, should_free_ds, xins, yins, xx, yy, wii, set_text_color, ovrheight, ifnum);
if ((topBar.wantIt) && (text_window_ds && *text_window_ds)) {
// top bar on the dialog window with character's name
// create an enlarged window, then free the old one
Bitmap *ds = *text_window_ds;
Bitmap *newScreenop = BitmapHelper::CreateBitmap(ds->GetWidth(), ds->GetHeight() + topBar.height, game.GetColorDepth());
newScreenop->Blit(ds, 0, 0, 0, topBar.height, ds->GetWidth(), ds->GetHeight());
delete *text_window_ds;
*text_window_ds = newScreenop;
ds = *text_window_ds;
// draw the top bar
color_t draw_color = ds->GetCompatibleColor(play.top_bar_backcolor);
ds->FillRect(Rect(0, 0, ds->GetWidth() - 1, topBar.height - 1), draw_color);
if (play.top_bar_backcolor != play.top_bar_bordercolor) {
// draw the border
draw_color = ds->GetCompatibleColor(play.top_bar_bordercolor);
for (int j = 0; j < play.top_bar_borderwidth; j++)
ds->DrawRect(Rect(j, j, ds->GetWidth() - (j + 1), topBar.height - (j + 1)), draw_color);
}
// draw the text
int textx = (ds->GetWidth() / 2) - wgettextwidth_compensate(topBar.text, topBar.font) / 2;
color_t text_color = ds->GetCompatibleColor(play.top_bar_textcolor);
wouttext_outline(ds, textx, play.top_bar_borderwidth + 1, topBar.font, text_color, topBar.text);
// don't draw it next time
topBar.wantIt = 0;
// adjust the text Y position
yins[0] += topBar.height;
}
else if (topBar.wantIt)
topBar.wantIt = 0;
}
示例4: DrawingSurface_Clear
void DrawingSurface_Clear(ScriptDrawingSurface *sds, int colour)
{
Bitmap *ds = sds->StartDrawing();
int allegroColor;
if ((colour == -SCR_NO_VALUE) || (colour == SCR_COLOR_TRANSPARENT))
{
allegroColor = ds->GetMaskColor();
}
else
{
allegroColor = ds->GetCompatibleColor(colour);
}
ds->Fill(allegroColor);
sds->FinishedDrawing();
}
示例5: DrawingSurface_SetDrawingColor
void DrawingSurface_SetDrawingColor(ScriptDrawingSurface *sds, int newColour)
{
sds->currentColourScript = newColour;
// StartDrawing to set up ds to set the colour at the appropriate
// depth for the background
Bitmap *ds = sds->StartDrawing();
if (newColour == SCR_COLOR_TRANSPARENT)
{
sds->currentColour = ds->GetMaskColor();
}
else
{
sds->currentColour = ds->GetCompatibleColor(newColour);
}
sds->FinishedDrawingReadOnly();
}
示例6: Draw
void InventoryScreen::Draw(Bitmap *ds)
{
color_t draw_color = ds->GetCompatibleColor(play.sierra_inv_color);
ds->FillRect(Rect(0,0,windowwid,windowhit), draw_color);
draw_color = ds->GetCompatibleColor(0);
ds->FillRect(Rect(barxp,bartop, windowwid - 2,buttonyp-1), draw_color);
for (int i = top_item; i < numitems; ++i) {
if (i >= top_item + num_visible_items)
break;
Bitmap *spof=spriteset[dii[i].sprnum];
wputblock(ds, barxp+1+((i-top_item)%4)*widest+widest/2-spof->GetWidth()/2,
bartop+1+((i-top_item)/4)*highest+highest/2-spof->GetHeight()/2,spof,1);
}
#define BUTTONWID Math::Max(1, game.SpriteInfos[btn_select_sprite].Width)
// Draw select, look and OK buttons
wputblock(ds, 2, buttonyp + 2, spriteset[btn_look_sprite], 1);
wputblock(ds, 3+BUTTONWID, buttonyp + 2, spriteset[btn_select_sprite], 1);
wputblock(ds, 4+BUTTONWID*2, buttonyp + 2, spriteset[btn_ok_sprite], 1);
// Draw Up and Down buttons if required
Bitmap *arrowblock = BitmapHelper::CreateTransparentBitmap (ARROWBUTTONWID, ARROWBUTTONWID);
draw_color = arrowblock->GetCompatibleColor(0);
if (play.sierra_inv_color == 0)
draw_color = ds->GetCompatibleColor(14);
arrowblock->DrawLine(Line(ARROWBUTTONWID/2, 2, ARROWBUTTONWID-2, 9), draw_color);
arrowblock->DrawLine(Line(ARROWBUTTONWID/2, 2, 2, 9), draw_color);
arrowblock->DrawLine(Line(2, 9, ARROWBUTTONWID-2, 9), draw_color);
arrowblock->FloodFill(ARROWBUTTONWID/2, 4, draw_color);
if (top_item > 0)
wputblock(ds, windowwid-ARROWBUTTONWID, buttonyp + 2, arrowblock, 1);
if (top_item + num_visible_items < numitems)
arrowblock->FlipBlt(arrowblock, windowwid-ARROWBUTTONWID, buttonyp + 4 + ARROWBUTTONWID, Common::kBitmap_VFlip);
delete arrowblock;
}
示例7: show_dialog_options
int show_dialog_options(int dlgnum, int sayChosenOption, bool runGameLoopsInBackground)
{
int dlgxp,dlgyp = get_fixed_pixel_size(160);
int usingfont=FONT_NORMAL;
int txthit = wgetfontheight(usingfont);
int curswas=cur_cursor;
int bullet_wid = 0, needheight;
IDriverDependantBitmap *ddb = NULL;
Bitmap *subBitmap = NULL;
GUITextBox *parserInput = NULL;
DialogTopic*dtop = NULL;
if ((dlgnum < 0) || (dlgnum >= game.numdialog))
quit("!RunDialog: invalid dialog number specified");
can_run_delayed_command();
play.in_conversation ++;
update_polled_stuff_if_runtime();
if (game.dialog_bullet > 0)
bullet_wid = spritewidth[game.dialog_bullet]+3;
// numbered options, leave space for the numbers
if (game.options[OPT_DIALOGNUMBERED])
bullet_wid += wgettextwidth_compensate("9. ", usingfont);
said_text = 0;
update_polled_stuff_if_runtime();
Bitmap *tempScrn = BitmapHelper::CreateBitmap(BitmapHelper::GetScreenBitmap()->GetWidth(), BitmapHelper::GetScreenBitmap()->GetHeight(), final_col_dep);
set_mouse_cursor(CURS_ARROW);
dtop=&dialog[dlgnum];
int ww,chose=-1,numdisp=0;
//get_real_screen();
Bitmap *ds = SetVirtualScreen(virtual_screen);
char disporder[MAXTOPICOPTIONS];
short dispyp[MAXTOPICOPTIONS];
int parserActivated = 0;
if ((dtop->topicFlags & DTFLG_SHOWPARSER) && (play.disable_dialog_parser == 0)) {
parserInput = new GUITextBox();
parserInput->hit = txthit + get_fixed_pixel_size(4);
parserInput->exflags = 0;
parserInput->font = usingfont;
}
numdisp=0;
for (ww=0;ww<dtop->numoptions;ww++) {
if ((dtop->optionflags[ww] & DFLG_ON)==0) continue;
ensure_text_valid_for_font(dtop->optionnames[ww], usingfont);
disporder[numdisp]=ww;
numdisp++;
}
if (numdisp<1) quit("!DoDialog: all options have been turned off");
// Don't display the options if there is only one and the parser
// is not enabled.
color_t draw_color;
if ((numdisp > 1) || (parserInput != NULL) || (play.show_single_dialog_option)) {
draw_color = ds->GetCompatibleColor(0); //ds->FillRect(Rect(0,dlgyp-1,scrnwid-1,dlgyp+numdisp*txthit+1);
int areawid, is_textwindow = 0;
int forecol = 14, savedwid;
int mouseison=-1,curyp;
int mousewason=-10;
int dirtyx = 0, dirtyy = 0;
int dirtywidth = virtual_screen->GetWidth(), dirtyheight = virtual_screen->GetHeight();
bool usingCustomRendering = false;
bool options_surface_has_alpha = false;
dlgxp = 1;
if (get_custom_dialog_options_dimensions(dlgnum))
{
usingCustomRendering = true;
dirtyx = multiply_up_coordinate(ccDialogOptionsRendering.x);
dirtyy = multiply_up_coordinate(ccDialogOptionsRendering.y);
dirtywidth = multiply_up_coordinate(ccDialogOptionsRendering.width);
dirtyheight = multiply_up_coordinate(ccDialogOptionsRendering.height);
}
else if (game.options[OPT_DIALOGIFACE] > 0)
{
GUIMain*guib=&guis[game.options[OPT_DIALOGIFACE]];
if (guib->is_textwindow()) {
// text-window, so do the QFG4-style speech options
is_textwindow = 1;
forecol = guib->fgcol;
}
else {
dlgxp = guib->x;
dlgyp = guib->y;
dirtyx = dlgxp;
dirtyy = dlgyp;
dirtywidth = guib->wid;
//.........这里部分代码省略.........
示例8: _display_main
// Pass yy = -1 to find Y co-ord automatically
// allowShrink = 0 for none, 1 for leftwards, 2 for rightwards
// pass blocking=2 to create permanent overlay
int _display_main(int xx,int yy,int wii,const char*text,int blocking,int usingfont,int asspch, int isThought, int allowShrink, bool overlayPositionFixed)
{
const bool use_speech_textwindow = (asspch < 0) && (game.options[OPT_SPEECHTYPE] >= 2);
const bool use_thought_gui = (isThought) && (game.options[OPT_THOUGHTGUI] > 0);
bool alphaChannel = false;
char todis[STD_BUFFER_SIZE];
snprintf(todis, STD_BUFFER_SIZE - 1, "%s", text);
int usingGui = -1;
if (use_speech_textwindow)
usingGui = play.speech_textwindow_gui;
else if (use_thought_gui)
usingGui = game.options[OPT_THOUGHTGUI];
int padding = get_textwindow_padding(usingGui);
int paddingScaled = get_fixed_pixel_size(padding);
int paddingDoubledScaled = get_fixed_pixel_size(padding * 2); // Just in case screen size does is not neatly divisible by 320x200
ensure_text_valid_for_font(todis, usingfont);
break_up_text_into_lines(wii-2*padding,usingfont,todis);
disp.lineheight = getfontheight_outlined(usingfont);
disp.linespacing= getfontspacing_outlined(usingfont);
disp.fulltxtheight = getheightoflines(usingfont, numlines);
// AGS 2.x: If the screen is faded out, fade in again when displaying a message box.
if (!asspch && (loaded_game_file_version <= kGameVersion_272))
play.screen_is_faded_out = 0;
// if it's a normal message box and the game was being skipped,
// ensure that the screen is up to date before the message box
// is drawn on top of it
if ((play.skip_until_char_stops >= 0) && (blocking == 1))
render_graphics();
EndSkippingUntilCharStops();
if (topBar.wantIt) {
// ensure that the window is wide enough to display
// any top bar text
int topBarWid = wgettextwidth_compensate(topBar.text, topBar.font);
topBarWid += multiply_up_coordinate(play.top_bar_borderwidth + 2) * 2;
if (longestline < topBarWid)
longestline = topBarWid;
// the top bar should behave like DisplaySpeech wrt blocking
blocking = 0;
}
if (asspch > 0) {
// update the all_buttons_disabled variable in advance
// of the adjust_x/y_for_guis calls
play.disabled_user_interface++;
update_gui_disabled_status();
play.disabled_user_interface--;
}
if (xx == OVR_AUTOPLACE) ;
// centre text in middle of screen
else if (yy<0) yy=play.viewport.GetHeight()/2-disp.fulltxtheight/2-padding;
// speech, so it wants to be above the character's head
else if (asspch > 0) {
yy-=disp.fulltxtheight;
if (yy < 5) yy=5;
yy = adjust_y_for_guis (yy);
}
if (longestline < wii - paddingDoubledScaled) {
// shrink the width of the dialog box to fit the text
int oldWid = wii;
//if ((asspch >= 0) || (allowShrink > 0))
// If it's not speech, or a shrink is allowed, then shrink it
if ((asspch == 0) || (allowShrink > 0))
wii = longestline + paddingDoubledScaled;
// shift the dialog box right to align it, if necessary
if ((allowShrink == 2) && (xx >= 0))
xx += (oldWid - wii);
}
if (xx<-1) {
xx=(-xx)-wii/2;
if (xx < 0)
xx = 0;
xx = adjust_x_for_guis (xx, yy);
if (xx + wii >= play.viewport.GetWidth())
xx = (play.viewport.GetWidth() - wii) - 5;
}
else if (xx<0) xx=play.viewport.GetWidth()/2-wii/2;
int ee, extraHeight = paddingDoubledScaled;
Bitmap *ds = GetVirtualScreen();
color_t text_color = ds->GetCompatibleColor(15);
if (blocking < 2)
remove_screen_overlay(OVER_TEXTMSG);
Bitmap *text_window_ds = BitmapHelper::CreateTransparentBitmap((wii > 0) ? wii : 2, disp.fulltxtheight + extraHeight, System_GetColorDepth());
//.........这里部分代码省略.........
示例9: __actual_invscreen
int __actual_invscreen() {
int BUTTONAREAHEIGHT = get_fixed_pixel_size(30);
int cmode=CURS_ARROW, toret = -1;
int top_item = 0, num_visible_items = 0;
int MAX_ITEMAREA_HEIGHT = ((scrnhit - BUTTONAREAHEIGHT) - get_fixed_pixel_size(20));
in_inv_screen++;
inv_screen_newroom = -1;
Bitmap *ds = NULL;
start_actinv:
ds = SetVirtualScreen(virtual_screen);
DisplayInvItem dii[MAX_INV];
int numitems=0,ww,widest=0,highest=0;
if (charextra[game.playercharacter].invorder_count < 0)
update_invorder();
if (charextra[game.playercharacter].invorder_count == 0) {
DisplayMessage(996);
in_inv_screen--;
return -1;
}
if (inv_screen_newroom >= 0) {
in_inv_screen--;
NewRoom(inv_screen_newroom);
return -1;
}
for (ww = 0; ww < charextra[game.playercharacter].invorder_count; ww++) {
if (game.invinfo[charextra[game.playercharacter].invorder[ww]].name[0]!=0) {
dii[numitems].num = charextra[game.playercharacter].invorder[ww];
dii[numitems].sprnum = game.invinfo[charextra[game.playercharacter].invorder[ww]].pic;
int snn=dii[numitems].sprnum;
if (spritewidth[snn] > widest) widest=spritewidth[snn];
if (spriteheight[snn] > highest) highest=spriteheight[snn];
numitems++;
}
}
if (numitems != charextra[game.playercharacter].invorder_count)
quit("inconsistent inventory calculations");
widest += get_fixed_pixel_size(4);
highest += get_fixed_pixel_size(4);
num_visible_items = (MAX_ITEMAREA_HEIGHT / highest) * ICONSPERLINE;
int windowhit = highest * (numitems/ICONSPERLINE) + get_fixed_pixel_size(4);
if ((numitems%ICONSPERLINE) !=0) windowhit+=highest;
if (windowhit > MAX_ITEMAREA_HEIGHT) {
windowhit = (MAX_ITEMAREA_HEIGHT / highest) * highest + get_fixed_pixel_size(4);
}
windowhit += BUTTONAREAHEIGHT;
int windowwid = widest*ICONSPERLINE + get_fixed_pixel_size(4);
if (windowwid < get_fixed_pixel_size(105)) windowwid = get_fixed_pixel_size(105);
int windowxp=scrnwid/2-windowwid/2;
int windowyp=scrnhit/2-windowhit/2;
int buttonyp=windowyp+windowhit-BUTTONAREAHEIGHT;
color_t draw_color = ds->GetCompatibleColor(play.sierra_inv_color);
ds->FillRect(Rect(windowxp,windowyp,windowxp+windowwid,windowyp+windowhit), draw_color);
draw_color = ds->GetCompatibleColor(0);
int bartop = windowyp + get_fixed_pixel_size(2);
int barxp = windowxp + get_fixed_pixel_size(2);
ds->FillRect(Rect(barxp,bartop, windowxp + windowwid - get_fixed_pixel_size(2),buttonyp-1), draw_color);
for (ww = top_item; ww < numitems; ww++) {
if (ww >= top_item + num_visible_items)
break;
Bitmap *spof=spriteset[dii[ww].sprnum];
wputblock(ds, barxp+1+((ww-top_item)%4)*widest+widest/2-spof->GetWidth()/2,
bartop+1+((ww-top_item)/4)*highest+highest/2-spof->GetHeight()/2,spof,1);
}
if ((spriteset[2041] == NULL) || (spriteset[2042] == NULL) || (spriteset[2043] == NULL))
quit("!InventoryScreen: one or more of the inventory screen graphics have been deleted");
#define BUTTONWID spritewidth[2042]
// Draw select, look and OK buttons
wputblock(ds, windowxp+2, buttonyp + get_fixed_pixel_size(2), spriteset[2041], 1);
wputblock(ds, windowxp+3+BUTTONWID, buttonyp + get_fixed_pixel_size(2), spriteset[2042], 1);
wputblock(ds, windowxp+4+BUTTONWID*2, buttonyp + get_fixed_pixel_size(2), spriteset[2043], 1);
// Draw Up and Down buttons if required
const int ARROWBUTTONWID = 11;
Bitmap *arrowblock = BitmapHelper::CreateTransparentBitmap (ARROWBUTTONWID, ARROWBUTTONWID);
draw_color = arrowblock->GetCompatibleColor(0);
if (play.sierra_inv_color == 0)
draw_color = ds->GetCompatibleColor(14);
arrowblock->DrawLine(Line(ARROWBUTTONWID/2, 2, ARROWBUTTONWID-2, 9), draw_color);
arrowblock->DrawLine(Line(ARROWBUTTONWID/2, 2, 2, 9), draw_color);
arrowblock->DrawLine(Line(2, 9, ARROWBUTTONWID-2, 9), draw_color);
arrowblock->FloodFill(ARROWBUTTONWID/2, 4, draw_color);
if (top_item > 0)
wputblock(ds, windowxp+windowwid-ARROWBUTTONWID, buttonyp + get_fixed_pixel_size(2), arrowblock, 1);
if (top_item + num_visible_items < numitems)
arrowblock->FlipBlt(arrowblock, windowxp+windowwid-ARROWBUTTONWID, buttonyp + get_fixed_pixel_size(4) + ARROWBUTTONWID, Common::kBitmap_VFlip);
delete arrowblock;
domouse(1);
set_mouse_cursor(cmode);
int wasonitem=-1;
//.........这里部分代码省略.........