void ComposeLBItem(uint32 iIdx, bool bSel, const iRect& irc) { iTextComposer::FontConfig fc(dlgfc_plain); iRect rc=irc; if (bSel) { gGfxMgr.BlitTile(PDGG_CTILE, gApp.Surface(),rc); ButtonFrame(gApp.Surface(),rc,0); } rc.DeflateRect(2); iCastle* pCastle = *(m_pOwner->CastleFirst()+iIdx); // Glyph gApp.Surface().FillRect(iRect(rc.x,rc.y,34,22),cColor_Black); SpriteId sid = PDGG_CTL_SICONS + (pCastle->Proto()->Size()-1)*CTLT_COUNT + pCastle->Proto()->Type(); gGfxMgr.Blit(sid,gApp.Surface(), iPoint(rc.x+1,rc.y+1)); // Name rc.DeflateRect(36,0,0,0); rc.h = 10; gTextComposer.TextOut(dlgfc_topic,gApp.Surface(),rc,pCastle->Name(),rc,AlignTop); rc.y+=10; State state = GetItemState(iIdx); if (state == Occupied) { iTextComposer::FontConfig fc(iTextComposer::FS_SMALL,RGB16(255,128,128)); gTextComposer.TextOut(fc,gApp.Surface(),rc,pCastle->Visitor()->Name(),rc,AlignTop); } else if (state == Normal) { iTextComposer::FontConfig fc(iTextComposer::FS_SMALL,RGB16(128,255,128)); gTextComposer.TextOut(fc,gApp.Surface(),rc,gTextMgr[TRID_UNOCCUPIED],rc,AlignTop); } else { check(0); } }
void iSpellListView::OnCompose() { iRect rc = GetScrRect(); // Buttons frame; iRect brc = m_pSchoolSwitch->GetScrRect(); brc.InflateRect(1); gApp.Surface().FrameRect(brc, cColor_Black); rc.DeflateRect(m_pSchoolSwitch->GetRect().x2() + 5, -1, -1, -1); // Frame gApp.Surface().FrameRect(rc, cColor_Black); gApp.Surface().Darken25Rect(rc); rc.DeflateRect(3); // Spell if (m_curSel != MSP_INVALID) { // Name gTextComposer.TextOut(iTextComposer::FontConfig(iTextComposer::FS_MEDIUM,MSCH_COLORS[SPELL_DESCRIPTORS[m_curSel].school][0]), gApp.Surface(),iPoint(rc.x,rc.y),gTextMgr[TRID_SPNAME_MAGICARROW+m_curSel],rc, AlignTop); rc.DeflateRect(0,13,0,0); // Level gTextComposer.TextOut(iTextComposer::FontConfig(iTextComposer::FS_SMALL,MSCH_COLORS[SPELL_DESCRIPTORS[m_curSel].school][0]), gApp.Surface(),iPoint(rc.x,rc.y),gTextMgr[TRID_LEVEL] + iFormat(_T(": %d"), SPELL_DESCRIPTORS[m_curSel].level + 1),rc, AlignTop); rc.DeflateRect(0,16,0,0); // Icon rc.DeflateRect(0,40,0,0); // Hero school level ComposeSpellLevel(gApp.Surface(), rc, m_curSel, m_pOwner); rc.DeflateRect(0,12,0,0); // Cost uint8 cost = iBaseSpell::GetSpellCost(m_curSel, m_pOwner); uint8 school = SPELL_DESCRIPTORS[m_curSel].school; gTextComposer.TextOut(iTextComposer::FontConfig(iTextComposer::FS_SMALL,MSCH_COLORS[school][0]), gApp.Surface(),iPoint(rc.x,rc.y),gTextMgr[TRID_COST]+iFormat(_T(" %d"),cost),rc, AlignTop); rc.DeflateRect(0,20,0,0); // Inaccessebility reason if (m_pOwner->ManaPts() < cost) { iStringT msgStr(gTextMgr[TRID_MSG_SPELL_NOT_ENOUGH_MANA]); iTextComposer::FontConfig fntSmall(iTextComposer::FS_SMALL,RGB16(255,96,0)); gTextComposer.TextBoxOut( fntSmall, gApp.Surface(), msgStr,rc); } else if (iCombatSpell* pCombatSpell = DynamicCast<iCombatSpell*>(gGame.ItemMgr().m_spellMgr.Spell(m_curSel))) { iTextComposer::FontConfig fntSmallDifferentColor(iTextComposer::FS_SMALL,RGB16(255,255,0)); gTextComposer.TextBoxOut( fntSmallDifferentColor, gApp.Surface(), pCombatSpell->ActionText(m_pOwner),rc); } } else { iTextComposer::FontConfig fntSmall(iTextComposer::FS_SMALL,RGB16(255,96,0)); gTextComposer.TextBoxOut(fntSmall, gApp.Surface(), gTextMgr[TRID_NO_SPELL_SELECTED],rc); } }
void iDlg_CreatInfo::DoCompose(const iRect& clRect) { iRect rc(clRect); // title gTextComposer.TextOut(dlgfc_hdr, gApp.Surface(),rc.point(),gTextMgr[m_cGroup.Type()*3+TRID_CREATURE_PEASANT_F2], iRect(rc.x,rc.y,rc.w,15),AlignCenter); rc.y+=15; // icon BlitIcon(gApp.Surface(),PDGG_MINIMON+m_cGroup.Type(),iRect(rc.x,rc.y,rc.w,45)); rc.y+=45; // Perks if (CREAT_DESC[m_cGroup.Type()].perks != CPERK_NONE) rc.y+=15; // props iRect trc(rc.x,rc.y,90,12); iTextComposer::FontConfig fc(iTextComposer::FS_SMALL, RGB16(192,192,255)); gTextComposer.TextOut(fc, gApp.Surface(),trc.point(),iStringT(gTextMgr[TRID_SKILL_ATTACK])+_T(" :"),trc,AlignTopRight); trc.y+=10; gTextComposer.TextOut(fc, gApp.Surface(),trc.point(),iStringT(gTextMgr[TRID_SKILL_DEFENCE])+_T(" :"),trc,AlignTopRight); trc.y+=10; gTextComposer.TextOut(fc, gApp.Surface(),trc.point(),iStringT(gTextMgr[TRID_SKILL_SHOTS])+_T(" :"),trc,AlignTopRight); trc.y+=10; gTextComposer.TextOut(fc, gApp.Surface(),trc.point(),iStringT(gTextMgr[TRID_SKILL_DAMAGE])+_T(" :"),trc,AlignTopRight); trc.y+=10; gTextComposer.TextOut(fc, gApp.Surface(),trc.point(),iStringT(gTextMgr[TRID_SKILL_HEALTH])+_T(" :"),trc,AlignTopRight); trc.y+=10; gTextComposer.TextOut(fc, gApp.Surface(),trc.point(),iStringT(gTextMgr[TRID_SKILL_SPEED])+_T(" :"),trc,AlignTopRight); trc.y+=10; gTextComposer.TextOut(fc, gApp.Surface(),trc.point(),iStringT(gTextMgr[TRID_SKILL_MORALE])+_T(" :"),trc,AlignTopRight); trc.y+=10; gTextComposer.TextOut(fc, gApp.Surface(),trc.point(),iStringT(gTextMgr[TRID_SKILL_LUCK])+_T(" :"),trc,AlignTopRight); trc.y+=10; trc = iRect(rc.x+95,rc.y,rc.w-105,12); iTextComposer::FontConfig tfc(iTextComposer::FS_SMALL, RGB16(255,220,192)); iStringT tout; tout.Setf(_T("%d (%d)"),CREAT_DESC[m_cGroup.Type()].attack, CREAT_DESC[m_cGroup.Type()].attack+m_furtSkills.Value(FSK_ATTACK)); gTextComposer.TextOut(tfc, gApp.Surface(),trc.point(),tout,trc,AlignTopLeft); trc.y+=10; tout.Setf(_T("%d (%d)"),CREAT_DESC[m_cGroup.Type()].defence, CREAT_DESC[m_cGroup.Type()].defence+m_furtSkills.Value(FSK_DEFENCE)); gTextComposer.TextOut(tfc, gApp.Surface(),trc.point(),tout,trc,AlignTopLeft); trc.y+=10; if (CREAT_DESC[m_cGroup.Type()].shots) tout.Setf(_T("%d"),CREAT_DESC[m_cGroup.Type()].shots); else tout.Setf(_T("-")); gTextComposer.TextOut(tfc, gApp.Surface(),trc.point(),tout,trc,AlignTopLeft); trc.y+=10; tout.Setf(_T("%d - %d"),CREAT_DESC[m_cGroup.Type()].damage_min,CREAT_DESC[m_cGroup.Type()].damage_max); gTextComposer.TextOut(tfc, gApp.Surface(),trc.point(),tout,trc,AlignTopLeft); trc.y+=10; tout.Setf(_T("%d (%d)"),CREAT_DESC[m_cGroup.Type()].hits, CREAT_DESC[m_cGroup.Type()].hits+m_furtSkills.Value(FSK_HITS)); gTextComposer.TextOut(tfc, gApp.Surface(),trc.point(),tout,trc,AlignTopLeft); trc.y+=10; tout.Setf(_T("%d (%d)"),CREAT_DESC[m_cGroup.Type()].speed, CREAT_DESC[m_cGroup.Type()].speed+m_furtSkills.Value(FSK_SPEED)); gTextComposer.TextOut(tfc, gApp.Surface(),trc.point(),tout,trc,AlignTopLeft); trc.y+=10; sint32 morale = (CREAT_DESC[m_cGroup.Type()].perks&CPERK_UNDEAD)?0:(m_furtSkills.Value(FSK_MORALE)+m_moraleMod); gTextComposer.TextOut(tfc, gApp.Surface(),trc.point(),FormatNumber(morale,true),trc,AlignTopLeft); trc.y+=10; gTextComposer.TextOut(tfc, gApp.Surface(),trc.point(),FormatNumber(m_furtSkills.Value(FSK_LUCK),true),trc,AlignTopLeft); trc.y+=10; }
uint16 gdi_get_color_16bpp(HDC hdc, COLORREF color) { uint8 r, g, b; uint16 color16; GetRGB32(r, g, b, color); if(hdc->rgb555) { if (hdc->invert) { color16 = BGR15(r, g, b); } else { color16 = RGB15(r, g, b); } } else { if (hdc->invert) { color16 = BGR16(r, g, b); } else { color16 = RGB16(r, g, b); } } return color16; }
UINT16 gdi_get_color_16bpp(HGDI_DC hdc, GDI_COLOR color) { BYTE r, g, b; UINT16 color16; GetRGB32(r, g, b, color); if (hdc->rgb555) { if (hdc->invert) { color16 = BGR15(r, g, b); } else { color16 = RGB15(r, g, b); } } else { if (hdc->invert) { color16 = BGR16(r, g, b); } else { color16 = RGB16(r, g, b); } } return color16; }
/* * InitPixelShade: * Fills the PixelShade array with precomputed shades of every possible pixel (32 shades) */ void InitPixelShade(void) { int i, j; int r, g, b; int dr, dg, db; const double alpha[32] = { 0.0, 0.03, 0.06, 0.09, 0.13, 0.17, 0.21, 0.24, 0.27, 0.31, 0.34, 0.37, 0.41, 0.44, 0.47, 0.49, 0.51, 0.53, 0.56, 0.59, 0.63, 0.66, 0.69, 0.73, 0.76, 0.79, 0.83, 0.87, 0.91, 0.94, 0.97, 1.0 }; for (i = 0; i < 32; i++) { for (j = 0; j < 65536; j++) { r = RED(j); g = GREEN(j); b = BLUE(j); dr = (int)(r * alpha[i]); dg = (int)(g * alpha[i]); db = (int)(b * alpha[i]); PixelShade[i][j] = RGB16(dr, dg, db); } } }
static int load_bmp_rgb24(unsigned char *p_file, int size_B, int w, int h, int pad_B) { // - 画像データは左下から右上に向かって記録されている // - 画像の横ラインのデータは4バイトの境界に揃えないといけない COLOR16 *buf = mem_alloc(w * h * sizeof (COLOR16)); if (buf == 0) { return ERROR_SID; } int sid = new_surface_from_buf(NO_PARENT_SID, w, h, buf, 16); if (sid == ERROR_SID) { return sid; } unsigned char *p = p_file + sizeof (struct BMP_FILE_HDR) + sizeof (struct BMP_INFO_HDR); unsigned char r, g, b; for (int y = h - 1; y >= 0; y--) { for (int x = 0; x < w; x++) { b = *p++; g = *p++; r = *p++; buf[y * w + x] = RGB16(r, g, b); } p += pad_B; } return sid; }
/*! Converts palette to 16bit GBA colors, compresses it and fills in \a gr._palRec. */ bool grit_prep_pal(GritRec *gr) { lprintf(LOG_STATUS, "Palette preparation.\n"); int ii, nclrs, palS; COLOR *palOut; RGBQUAD *palIn; nclrs= gr->palEnd - gr->palStart; if(dib_get_nclrs(gr->_dib) < nclrs && nclrs != 0) nclrs= dib_get_nclrs(gr->_dib); palS= nclrs*sizeof(COLOR); palOut= (COLOR*)malloc(palS); palIn= &dib_get_pal(gr->_dib)[gr->palStart]; for(ii=0; ii<nclrs; ii++) palOut[ii]= RGB16(palIn[ii].rgbBlue, palIn[ii].rgbGreen, palIn[ii].rgbRed); RECORD rec= { 2, palS/2, (BYTE*)palOut }; if( BYTE_ORDER == BIG_ENDIAN ) data_byte_rev(rec.data, rec.data, rec_size(&rec), 2); // Attach and compress palette grit_compress(&rec, &rec, gr->palCompression); rec_alias(&gr->_palRec, &rec); lprintf(LOG_STATUS, "Palette preparation complete.\n"); return true; }
uint16 GetPenColor_16bpp(HPEN pen) { uint16 p; int r, g, b; GetRGB32(r, g, b, pen->color); RGB_888_565(r, g, b); p = RGB16(r, g, b); return p; }
iDlg_ArtInfo::iDlg_ArtInfo(iViewMgr* pViewMgr, uint16 artId, const iHero* pOwner) : iBaseGameDlg(pViewMgr, (pOwner)?(pOwner->Owner()->PlayerId()):PID_NEUTRAL), m_pOwner(pOwner), m_artId(artId), m_fcReqMsg(dlgfc_splain) { SECONDARY_SKILLS reqSkill = gGame.ItemMgr().m_artMgr[artId].ReqSkill(); uint16 reqLevel = gGame.ItemMgr().m_artMgr[artId].ReqLevel(); if (reqLevel && reqSkill != SECSK_NONE) { m_reqMsg.Setf(gTextMgr[TRID_MSG_ARTREQ_LVL_SKILL], reqLevel, gTextMgr[TRID_HSKILL_ESTATES+reqSkill]); } else if (reqLevel) { m_reqMsg.Setf(gTextMgr[TRID_MSG_ARTREQ_LVL], reqLevel); } else if (reqSkill != SECSK_NONE) { m_reqMsg.Setf(gTextMgr[TRID_MSG_ARTREQ_SKILL], gTextMgr[TRID_HSKILL_ESTATES+reqSkill]); } if (pOwner && gGame.ItemMgr().m_artMgr[artId].CanAttach(pOwner)) { m_fcReqMsg.cmpProps.faceColor = RGB16(96,255,96); } else { m_fcReqMsg.cmpProps.faceColor = RGB16(255,96,96); } }
static PyObject* osl_RGB16(PyObject *self, PyObject *args, PyObject *kwargs) { int r, g, b; if (!PyArg_ParseTuple(args, "iii:RGB16", &r, &g, &b)) return NULL; return Py_BuildValue("i", RGB16(r, g, b)); }
static int BitBlt_PATINVERT_16bpp(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight) { int x, y; uint8 *dstp; uint8 *patp; uint8 colR, colG, colB; uint16 col; uint16 *dstp16; if(hdcDest->brush->style == BS_SOLID) { GetRGB(colR, colG, colB, hdcDest->brush->color); RGB_888_565(colR, colG, colB); col = RGB16(colR, colG, colB); for (y = 0; y < nHeight; y++) { dstp16 = (uint16*)gdi_get_bitmap_pointer(hdcDest, nXDest, nYDest + y); if (dstp16 != 0) { for (x = 0; x < nWidth; x++) { *dstp16 ^= col; dstp16++; } } } } else { for (y = 0; y < nHeight; y++) { dstp = gdi_get_bitmap_pointer(hdcDest, nXDest, nYDest + y); if (dstp != 0) { for (x = 0; x < nWidth; x++) { patp = gdi_get_brush_pointer(hdcDest, x, y); *dstp = *patp ^ *dstp; patp++; dstp++; *dstp = *patp ^ *dstp; patp++; dstp++; } } } } return 0; }
void iDlg_HallOfFame::DoCompose(const iRect& clRect) { iRect rc(clRect); // title gTextComposer.TextOut(dlgfc_hdr, gApp.Surface(),rc.point(),gTextMgr[TRID_MENU_HIGHSCORE], iRect(rc.x,rc.y,rc.w,15),AlignCenter); rc.y+=17; // Header gTextComposer.TextOut(dlgfc_topic, gApp.Surface(),rc, gTextMgr[TRID_HOF_RANK], iRect(rc.x, rc.y, 30, 15),AlignTop); gTextComposer.TextOut(dlgfc_topic, gApp.Surface(),rc, gTextMgr[TRID_HOF_LAND], iRect(rc.x+30, rc.y, 120, 15),AlignTop); gTextComposer.TextOut(dlgfc_topic, gApp.Surface(),rc, gTextMgr[TRID_HOF_DATE], iRect(rc.x+30+120, rc.y, 50, 15),AlignTop); gTextComposer.TextOut(dlgfc_topic, gApp.Surface(),rc, gTextMgr[TRID_HOF_DAYS], iRect(rc.x+30+120+50, rc.y, 40, 15),AlignTop); gTextComposer.TextOut(dlgfc_topic, gApp.Surface(),rc, gTextMgr[TRID_HOF_SCORE], iRect(rc.x+30+120+50+40, rc.y, 40, 15),AlignTop); rc.y += 15; // Entries uint32 eid; iTextComposer::FontConfig fc(iTextComposer::FS_MEDIUM, RGB16(192,192,192)); for (eid = 0; eid<m_hScore.Count() && eid<10; ++eid) { if (eid == (uint32)m_curScore) fc.cmpProps.faceColor = RGB16(255,192,128); else fc.cmpProps.faceColor = RGB16(192,192,192); gTextComposer.TextOut(fc, gApp.Surface(),rc, iFormat(_T("%d."),eid+1), iRect(rc.x, rc.y, 30, 15),AlignTop); gTextComposer.TextOut(fc, gApp.Surface(),rc, m_hScore.Entry(eid).land, iRect(rc.x+30, rc.y, 120, 15),AlignTopLeft); gTextComposer.TextOut(fc, gApp.Surface(),rc, FormatDate(m_hScore.Entry(eid).date, false), iRect(rc.x+30+120, rc.y, 50, 15),AlignTop); gTextComposer.TextOut(fc, gApp.Surface(),rc, iFormat(_T("%d"),m_hScore.Entry(eid).days), iRect(rc.x+30+120+50, rc.y, 40, 15),AlignTop); gTextComposer.TextOut(fc, gApp.Surface(),rc, iFormat(_T("%d"),m_hScore.Entry(eid).score), iRect(rc.x+30+120+50+40, rc.y, 40, 15),AlignTop); rc.y += 14; } fc.cmpProps.faceColor = RGB16(192,192,192); for (; eid<10; ++eid) { gTextComposer.TextOut(fc, gApp.Surface(),rc, iFormat(_T("%d."),eid+1), iRect(rc.x, rc.y, 30, 15),AlignTop); gTextComposer.TextOut(fc, gApp.Surface(),rc, _T("-"), iRect(rc.x+30, rc.y, 120, 15),AlignTopLeft); gTextComposer.TextOut(fc, gApp.Surface(),rc, _T("-"), iRect(rc.x+30+120, rc.y, 50, 15),AlignTop); gTextComposer.TextOut(fc, gApp.Surface(),rc, _T("-"), iRect(rc.x+30+120+50, rc.y, 40, 15),AlignTop); gTextComposer.TextOut(fc, gApp.Surface(),rc, _T("-"), iRect(rc.x+30+120+50+40, rc.y, 40, 15),AlignTop); rc.y += 14; } }
int main() { char x,y; u16* Screen = (u16*)VRAM; SetMode(MODE_4 | BG2_ON); // clear screen, and draw a blue back ground for(x = 0; x<240;x++) //loop through all x { for(y = 0; y<160; y++) //loop through all y { Screen[x+y*240] = RGB16(0,0,31); } } // draw a white HI on the background for(x = 20; x<=60; x+=15) for(y = 30; y<50; y++) Screen[x+y*240] = RGB16(31,31,31); for (x = 20; x < 35; x++) Screen[x+40*240] = RGB16(31,31,31); while(1){} //loop forever }
void OnCompose() { // gApp.Surface().Darken50Rect(GetScrRect()); // Compose outer frame iRect rect = GetScrRect(); rect.InflateRect(1); iDibFont::ComposeProps props = iDibFont::ComposeProps(iGradient(menuBtnText,15), cColor_Black, iDibFont::DecBorder); uint32 state = GetButtonState(); if ( state & iButton::Disabled ) { props = iDibFont::ComposeProps(RGB16(255,160,80), cColor_Black, iDibFont::DecBorder); } else if ( state & iButton::Pressed ) { props = iDibFont::ComposeProps(RGB16(255,255,255), cColor_Black, iDibFont::DecBorder); uint16 cColor_Grey = RGB16(32,32,32); gApp.Surface().HLine(iPoint(rect.x+2, rect.y), rect.x+rect.w-3, cColor_Grey); gApp.Surface().HLine(iPoint(rect.x+2, rect.y+rect.h-1), rect.x+rect.w-3, cColor_Grey); gApp.Surface().VLine(iPoint(rect.x,rect.y+2), rect.y+rect.h-2, cColor_Grey); gApp.Surface().VLine(iPoint(rect.x+rect.w-1,rect.y+2), rect.y+rect.h-2, cColor_Grey); gApp.Surface().Darken50Rect(GetScrRect()); } iTextComposer::FontConfig fc(iTextComposer::FS_LARGE, props ); gTextComposer.TextOut(fc, gApp.Surface(), iPoint(), gTextMgr[m_TextKey], GetScrRect(), AlignCenter); }
uint32_t prom_P16(mapa_t *mapa, int col, int fil, int radio, uint32_t w, uint32_t h) { uint32_t result; /*Variable de retorno.*/ uint32_t prom[3]; /*Variable para calcular el promedio*/ int lc, lf, i_f, i_c,cont, c,f, pos; /*Estructuras para referenciar el pixel adecuado.*/ pixel_16 *inicio; lc=(col+radio>(w))?(w):col+radio;/*calculmos el limite para columnas. */ lf=(fil+radio>(h))?(h):fil+radio;/*calculamos el limite para filas.*/ i_f=(fil-radio<0)?0:(fil-radio); /*Limite principio filas */ i_c=(col-radio<0)?0:(col-radio); /*Limite principio columnas*/ prom[0]=0; prom[1]=0; prom[2]=0; inicio=mapa->map_16; if (inicio == NULL) return 0; /*Si no existe mapa de bit salimos.*/ cont=0; for(f=i_f;f<lf;f++) { for(c=i_c;c<lc;c++) { pos = c+(f*w); prom[0]+=(inicio+pos)->r; prom[1]+=(inicio+pos)->g; prom[2]+=(inicio+pos)->b; cont++; } } prom[0]= div_redondeo(prom[0], cont);/*Calculamos y guardamos el promedio.*/ prom[1]= div_redondeo(prom[1], cont); prom[2]= div_redondeo(prom[2], cont); result = RGB16(prom[0], prom[1], prom[2]); return result; }/*Fin prom_P16*/
void ili9340_readRect(struct ili9340 *self, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t *data){ _ili9340_setAddrWindow(self, x, y, x + w - 1, y + h - 1); //_wr_command(self, ILI9340_RAMRD); // read RAM CS_LO; DC_LO; spi_writereadbyte(ILI9340_RAMRD); //spi_writereadbyte(0); DC_HI; spi_writereadbyte(0); uint16_t cnt = w * h; for(uint16_t c = 0; c < cnt; c++){ // DAMN! this took a while to figure out :) // The data is one byte per color! NOT packed! data[c] = RGB16(spi_writereadbyte(0), spi_writereadbyte(0), spi_writereadbyte(0)); } CS_HI; }
int FillRect_16bpp(HDC hdc, HRECT rect, HBRUSH hbr) { int x, y; char *dstp; char r, g, b; int nXDest, nYDest; int nWidth, nHeight; uint16 *dstp16; uint16 color16; RectToCRgn(rect, &nXDest, &nYDest, &nWidth, &nHeight); if (ClipCoords(hdc, &nXDest, &nYDest, &nWidth, &nHeight, NULL, NULL) == 0) return 0; GetRGB(r, g, b, hbr->color); RGB_888_565(r, g, b); color16 = RGB16(r, g, b); for (y = 0; y < nHeight; y++) { dstp = gdi_get_bitmap_pointer(hdc, nXDest, nYDest + y); if (dstp != 0) { for (x = 0; x < nWidth; x++) { dstp16 = (uint16*) dstp; *dstp16 = color16; dstp += 2; } } } InvalidateRegion(hdc, nXDest, nYDest, nWidth, nHeight); return 0; }
// ビットマップコピー static void blit_src_copy16(struct GBUFFER *src, int src_x, int src_y, int w, int h, struct GBUFFER *dst, int dst_x, int dst_y) { // src と dst が同じ場合は、重なっている場合も考慮しないといけないので // 場合分けが少し複雑になっている。 COLOR16 *src_buf = (COLOR16 *) src->buf; src_buf = &src_buf[src_y * src->w + src_x];; COLOR16 *dst_buf = (COLOR16 *) dst->buf; dst_buf = &dst_buf[dst_y * dst->w + dst_x]; if (src->flags & GBF_FLG_HAS_COLORKEY) { COLOR16 colorkey = RGB32_TO_16(src->colorkey); for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { if (*src_buf != colorkey) { *dst_buf = *src_buf; } src_buf++; dst_buf++; } src_buf += (src->w - w); dst_buf += (dst->w - w); } } else if (src->flags & GBF_FLG_HAS_ALPHA) { unsigned char alpha = src->alpha; for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { *dst_buf = RGB16( (GET_RED16(*src_buf) * (100 - alpha) + GET_RED16(*dst_buf) * alpha) / 100, (GET_GREEN16(*src_buf) * (100 - alpha) + GET_GREEN16(*dst_buf) * alpha) / 100, (GET_BLUE16(*src_buf) * (100 - alpha) + GET_BLUE16(*dst_buf) * alpha) / 100); src_buf++; dst_buf++; } src_buf += (src->w - w); dst_buf += (dst->w - w); } } else { // srcとdstの幅が同じなら一気にコピー if (src->w == w && src->w == dst->w) { if (src == dst) { memmove(dst_buf, src_buf, w * h * sizeof (COLOR16)); } else { memcpy(dst_buf, src_buf, w * h * sizeof (COLOR16)); } } else { // src と dst の幅が違うなら1行ずつコピー if (src == dst) { if (src_y >= dst_y) { for (int y = 0; y < h; y++) { memmove(dst_buf, src_buf, w * sizeof (COLOR16)); src_buf += src->w; dst_buf += dst->w; } } else { for (int y = h; y >= 0; y--) { memmove(dst_buf, src_buf, w * sizeof (COLOR16)); src_buf += src->w; dst_buf += dst->w; } } } else { for (int y = 0; y < h; y++) { memcpy(dst_buf, src_buf, w * sizeof (COLOR16)); src_buf += src->w; dst_buf += dst->w; } } } } }
TextureFormat const * TextureFormat::fromImageType(AbstractImage::Type type, bool is_depth) { if (is_depth) { switch (type) { case AbstractImage::Type::LUMINANCE_16U : return DEPTH16(); case AbstractImage::Type::LUMINANCE_32U : return DEPTH32(); case AbstractImage::Type::LUMINANCE_32F : return DEPTH32F(); default: throw Error("TextureFormat: No supported depth texture format corresponds to the specified image format"); } } enum { COLOR_ORDER_RGB, COLOR_ORDER_BGR } color_order; color_order = (AbstractImage::Channel::RED < AbstractImage::Channel::BLUE ? COLOR_ORDER_RGB : COLOR_ORDER_BGR); switch (type) { case AbstractImage::Type::LUMINANCE_8U : return L8(); case AbstractImage::Type::LUMINANCE_16U : return L16(); case AbstractImage::Type::LUMINANCE_32F : return L32F(); case AbstractImage::Type::RGB_8U : return color_order == COLOR_ORDER_RGB ? RGB8() : BGR8(); case AbstractImage::Type::RGBA_8U : return color_order == COLOR_ORDER_RGB ? RGBA8() : BGRA8(); case AbstractImage::Type::RGB_16U : return color_order == COLOR_ORDER_RGB ? RGB16() : BGR16(); case AbstractImage::Type::RGBA_16U : return color_order == COLOR_ORDER_RGB ? RGBA16() : BGRA16(); case AbstractImage::Type::RGB_32F : return color_order == COLOR_ORDER_RGB ? RGB32F() : BGR32F(); case AbstractImage::Type::RGBA_32F : return color_order == COLOR_ORDER_RGB ? RGBA32F() : BGRA32F(); default: throw Error("TextureFormat: No supported texture format corresponds to the specified image format"); } }
TextureFormat const * TextureFormat::fromCode(Code code) { switch (code) { case Code::L8: return L8(); case Code::L16: return L16(); case Code::L16F: return L16F(); case Code::L32F: return L32F(); case Code::A8: return A8(); case Code::A16: return A16(); case Code::A16F: return A16F(); case Code::A32F: return A32F(); case Code::LA4: return LA4(); case Code::LA8: return LA8(); case Code::LA16: return LA16(); case Code::LA16F: return LA16F(); break; case Code::LA32F: return LA32F(); case Code::RGB5: return RGB5(); case Code::RGB5A1: return RGB5A1(); case Code::RGB8: return RGB8(); case Code::RGB10: return RGB10(); case Code::RGB10A2: return RGB10A2(); case Code::RGB16: return RGB16(); case Code::RGB32F: return RGB32F(); case Code::R11G11B10F: return R11G11B10F(); case Code::RGB9E5F: return RGB9E5F(); case Code::RGB8I: return RGB8I(); case Code::RGB8UI: return RGB8UI(); case Code::ARGB8: return NULL; case Code::BGR8: return BGR8(); case Code::BGRA8: return BGRA8(); case Code::BGR16: return BGR16(); case Code::BGRA16: return BGRA16(); case Code::BGR32F: return BGR32F(); case Code::BGRA32F: return BGRA32F(); case Code::R8: return R8(); case Code::RG8: return RG8(); case Code::RG8I: return RG8I(); case Code::RG8UI: return RG8UI(); case Code::RG16F: return RG16F(); case Code::RGBA8: return RGBA8(); case Code::RGBA16: return RGBA16(); case Code::RGBA16F: return RGBA16F(); case Code::RGBA32F: return RGBA32F(); case Code::RGBA32UI: return RGBA32UI(); case Code::BAYER_RGGB8: // TODO case Code::BAYER_GRBG8: // TODO case Code::BAYER_GBRG8: // TODO case Code::BAYER_BGGR8: // TODO case Code::BAYER_RGGB32F: // TODO case Code::BAYER_GRBG32F: // TODO case Code::BAYER_GBRG32F: // TODO case Code::BAYER_BGGR32F: // TODO case Code::HSV8: // TODO case Code::HSV32F: // TODO return NULL; break; case Code::RGB_DXT1: return RGB_DXT1(); break; case Code::RGBA_DXT1: return RGBA_DXT1(); break; case Code::RGBA_DXT3: return RGBA_DXT3(); break; case Code::RGBA_DXT5: return RGBA_DXT5(); break; case Code::SRGB8: return SRGB8(); break; case Code::SRGBA8: return SRGBA8(); break; case Code::SL8: return SL8(); break; case Code::SLA8: return SLA8(); break; case Code::SRGB_DXT1: return SRGB_DXT1(); break; case Code::SRGBA_DXT1: return SRGBA_DXT1(); break; case Code::SRGBA_DXT3: return SRGBA_DXT3(); break; case Code::SRGBA_DXT5: return SRGBA_DXT5(); break; case Code::DEPTH16: return DEPTH16(); break; case Code::DEPTH24: return DEPTH24(); break; case Code::DEPTH32: return DEPTH32(); break; case Code::DEPTH32F: return DEPTH32F(); break; case Code::STENCIL1: return STENCIL1(); break; case Code::STENCIL4: return STENCIL4(); break; case Code::STENCIL8: return STENCIL8(); break; case Code::STENCIL16: return STENCIL16(); break; case Code::DEPTH24_STENCIL8: return DEPTH24_STENCIL8(); break; case Code::YUV420_PLANAR: return YUV420_PLANAR(); break; case Code::YUV422: return YUV422(); break; case Code::YUV444: return YUV444(); break; default: return NULL; } }
void vdp1_clip_test() { int gouraud_table_address = 0x40000; u32 clipping_mode = 3;//outside u16* p = (u16 *)(0x25C00000 + gouraud_table_address); for (;;) { vdp_start_draw_list(); sprite_struct quad; //system clipping quad.x = 319 - 8; quad.y = 223 - 8; vdp_system_clipping(&quad); //user clipping quad.x = 8; quad.y = 8; quad.x2 = 319 - 16; quad.y2 = 223 - 16; vdp_user_clipping(&quad); //fullscreen polygon quad.x = 319; quad.y = 0; quad.x2 = 319; quad.y2 = 223; quad.x3 = 0; quad.y3 = 223; quad.x4 = 0; quad.y4 = 0; quad.bank = RGB16(0x10, 0x10, 0x10);//gray quad.gouraud_addr = gouraud_table_address; quad.attr = (clipping_mode << 9) | 4;//use gouraud shading //red, green, blue, and white p[0] = RGB16(31, 0, 0); p[1] = RGB16(0, 31, 0); p[2] = RGB16(0, 0, 31); p[3] = RGB16(31, 31, 31); vdp_draw_polygon(&quad); vdp_end_draw_list(); vdp_vsync(); if (per[0].but_push_once & PAD_A) { clipping_mode = 0; //clipping disabled } if (per[0].but_push_once & PAD_B) { clipping_mode = 2; //inside drawing mode } if (per[0].but_push_once & PAD_C) { clipping_mode = 3; //outside drawing mode } if (per[0].but_push_once & PAD_START) break; } }
void vdp1_clip_test() { int gouraud_table_address = 0x40000; u32 clipping_mode = 3;//outside u16* p = (u16 *)(0x25C00000 + gouraud_table_address); auto_test_sub_test_start("Clipping test"); VDP1_REG_FBCR = 0; vdp_start_draw_list(); sprite_struct quad; quad.x = 0; quad.y = 0; vdp_local_coordinate(&quad); //system clipping quad.x = 319 - 8; quad.y = 223 - 8; vdp_system_clipping(&quad); //user clipping quad.x = 8; quad.y = 8; quad.x2 = 319 - 16; quad.y2 = 223 - 16; vdp_user_clipping(&quad); //fullscreen polygon quad.x = 319; quad.y = 0; quad.x2 = 319; quad.y2 = 223; quad.x3 = 0; quad.y3 = 223; quad.x4 = 0; quad.y4 = 0; quad.bank = RGB16(0x10, 0x10, 0x10);//gray quad.gouraud_addr = gouraud_table_address; quad.attr = (clipping_mode << 9) | 4;//use gouraud shading //red, green, blue, and white p[0] = RGB16(31, 0, 0); p[1] = RGB16(0, 31, 0); p[2] = RGB16(0, 0, 31); p[3] = RGB16(31, 31, 31); vdp_draw_polygon(&quad); vdp_end_draw_list(); vdp_vsync(); VDP1_REG_FBCR = 3; vdp_vsync(); vdp_vsync(); #ifdef BUILD_AUTOMATED_TESTING auto_test_get_framebuffer(); #else for (;;) { while (!(VDP2_REG_TVSTAT & 8)) { ud_check(0); } while (VDP2_REG_TVSTAT & 8) { } if (per[0].but_push_once & PAD_A) { clipping_mode = 0; //clipping disabled } if (per[0].but_push_once & PAD_B) { clipping_mode = 2; //inside drawing mode } if (per[0].but_push_once & PAD_C) { clipping_mode = 3; //outside drawing mode } if (per[0].but_push_once & PAD_START) break; if (per[0].but_push_once & PAD_X) { ar_menu(); } if (per[0].but_push_once & PAD_Y) { reset_system(); } } #endif }
/*! This basically does two things. First, create a bitmap from the designated area of the source bitmap. Then, converts it 8 or 16 bpp, depending on \a gr.gfxBpp. Conversion to lower bpp is done later, when it's more convenient. The resultant bitmap is put into \a gr._dib, and will be used in later preparation. */ bool grit_prep_work_dib(GritRec *gr) { int ii, nn; RGBQUAD *rgb; lprintf(LOG_STATUS, "Work-DIB creation.\n"); // --- resize --- CLDIB *dib= dib_copy(gr->srcDib, gr->areaLeft, gr->areaTop, gr->areaRight, gr->areaBottom, false); if(dib == NULL) { lprintf(LOG_ERROR, " Work-DIB creation failed.\n"); return false; } // ... that's it? Yeah, looks like. // --- resample (to 8 or 16) --- // int dibB= dib_get_bpp(dib); // Convert to 16bpp, but ONLY for bitmaps if( gr->gfxBpp == 16 && gr->gfxMode != GRIT_GFX_TILE ) { if(dibB != 16) { lprintf(LOG_WARNING, " converting from %d bpp to %d bpp.\n", dibB, gr->gfxBpp); CLDIB *dib2= dib_convert_copy(dib, 16, 0); // If paletted src AND -pT AND NOT -gT[!] // use trans color pal[T] //# PONDER: did I fix this right? if(dibB <= 8 && gr->palHasAlpha && !gr->gfxHasAlpha) { rgb= &dib_get_pal(dib)[gr->palAlphaId]; lprintf(LOG_WARNING, " pal->true-color conversion with transp pal-id option.\n" " using color %02X%02X%02X", rgb->rgbRed, rgb->rgbGreen, rgb->rgbBlue); gr->gfxHasAlpha= true; gr->gfxAlphaColor= *rgb; } dib_free(dib); if(dib2 == NULL) { lprintf(LOG_ERROR, "prep: Bpp conversion failed.\n"); return false; } dib= dib2; } // --- Dealing with 16bpp images --- // Modes: // 555 | GBA | swap R_B // 555+A=1 | NDS | swap R_B + add NDS_ALPHA // 555+A | NDS, transp | swap R_B + NDS_ALPHA if !trans-clr // src-pal + -pT -> NDS, transp // Swap palette bRGB to bBGR // And resolve -gT nn= dib_get_size_img(dib)/2; WORD *dibD2= (WORD*)dib_get_img(dib); // Single transparent color if(gr->gfxHasAlpha) { rgb= &gr->gfxAlphaColor; WORD clr= RGB16(rgb->rgbBlue, rgb->rgbGreen, rgb->rgbRed), wd; lprintf(LOG_STATUS, " converting to: 16bpp BGR, alpha=1, except for 0x%04X.\n", clr); for(ii=0; ii<nn; ii++) { wd= swap_rgb16(dibD2[ii]); dibD2[ii]= (wd == clr ? wd : wd | NDS_ALPHA); } } else if(gr->gfxMode == GRIT_GFX_BMP_A) { lprintf(LOG_STATUS, "converting to: 16bpp BGR, alpha=1.\n"); for(ii=0; ii<nn; ii++) dibD2[ii]= swap_rgb16(dibD2[ii]) | NDS_ALPHA; } else { lprintf(LOG_STATUS, "converting to: 16bpp, BGR.\n"); for(ii=0; ii<nn; ii++) dibD2[ii]= swap_rgb16(dibD2[ii]); } } else if(dibB != 8) // otherwise, convert to 8bpp { lprintf(LOG_WARNING, " converting from %d bpp to %d bpp.\n", dibB, gr->gfxBpp); if(!dib_convert(dib, 8, 0)) { dib_free(dib); lprintf(LOG_ERROR, " Bpp conversion failed.\n"); return false; } } // Palette transparency additions. if(dib_get_bpp(dib)==8) { // If gfx-trans && !pal-trans: // Find gfx-trans in palette and use that if(gr->gfxHasAlpha && !gr->palHasAlpha) { rgb= &gr->gfxAlphaColor; RGBQUAD *pal= dib_get_pal(dib); lprintf(LOG_WARNING, " tru/pal -> pal conversion with transp color option.\n" " looking for color %02X%02X%02X in palette.\n", rgb->rgbRed, rgb->rgbGreen, rgb->rgbBlue); uint ii_min= 0, dist, dist_min; dist_min= rgb_dist(rgb, &pal[0]); for(ii=1; ii<256; ii++) { dist= rgb_dist(rgb, &pal[ii]); if(dist < dist_min) { ii_min= ii; dist_min= dist; } } // HACK: count 'match' only if average error is < +/-14 if(dist_min < 576) { gr->palHasAlpha= true; gr->palAlphaId= ii_min; } } // Swap alpha and pixels palette entry if(gr->palHasAlpha) { lprintf(LOG_STATUS, " Palette transparency: pal[%d].\n", gr->palAlphaId); BYTE *imgD= dib_get_img(dib); nn= dib_get_size_img(dib); for(ii=0; ii<nn; ii++) { if(imgD[ii] == 0) imgD[ii]= gr->palAlphaId; else if(imgD[ii] == gr->palAlphaId) imgD[ii]= 0; } RGBQUAD tmp, *pal= dib_get_pal(dib); SWAP3(pal[0], pal[gr->palAlphaId], tmp); } // TODO: Palette merging. if(gr->palIsShared) { lprintf(LOG_STATUS, " Palette merging\n"); nn= dib_pal_reduce(dib, &gr->shared->palRec); if(nn>PAL_MAX) lprintf(LOG_WARNING, " New palette exceeds 256. Truncating.\n"); } } dib_free(gr->_dib); gr->_dib= dib; lprintf(LOG_STATUS, "Work-DIB creation complete: %dx%d@%d.\n", dib_get_width(gr->_dib), dib_get_height(gr->_dib), dib_get_bpp(gr->_dib)); return true; }
void iCastleView::OnCompose() { gApp.Surface().FillRect(GetScrRect(),RGB16(32,64,128)); }
#include "stdafx.h" #include "Credits.h" #include "MenuView.h" #include "Dlg_ScenList.h" #include "Dlg_Save.h" #include "Dlg_ScenProps.h" #include "Dlg_HallOfFame.h" /* * Main dialog */ const iDib::pixel menuBtnText[15] = { RGB16(210,190,115), RGB16(214,192,110), RGB16(216,192,102), RGB16(219,193,96), RGB16(221,193,85), RGB16(224,194,76), RGB16(228,196,67), RGB16(231,195,59), RGB16(233,196,49), RGB16(236,196,40), RGB16(239,198,31), RGB16(242,198,23), RGB16(224,198,16), RGB16(247,199,0), RGB16(248,200,0) }; class iMainMenuDlg : public iDialog, public IViewCmdHandler { public: class iMainMenuBtn : public iButton { public: iMainMenuBtn(iViewMgr* pViewMgr, IViewCmdHandler* pCmdHandler, const iRect& rect, TextResId textKey, uint32 uid, uint32 state = Visible|Enabled)\ : iButton(pViewMgr, pCmdHandler, rect, uid, state), m_TextKey(textKey) {} void OnBtnDown() const