HRESULT SImageMaskWnd::OnAttrImage(const SStringW & strValue,BOOL bLoading) { if(m_bmpCache) { ISkinObj * pSkin = GETSKIN(strValue); if(pSkin) MakeCacheApha(pSkin); }else { m_strSkin = strValue; } return bLoading?S_OK:S_FALSE; }
void SQrCtrl::CreateQrImg( SStringT strContent ) { CQR_Encode qrEncode; int nLevel = 3; int nVersion = 0; bool bAutoExtent = true; int nMaskingNo = -1; SStringA strContentA = S_CT2A(strContent, CP_UTF8); if (qrEncode.EncodeData(nLevel, nVersion, bAutoExtent, nMaskingNo, strContentA, strContentA.GetLength())) { if (m_pSkin == NULL) { int qrSize = qrEncode.m_nSymbleSize + (QR_MARGIN * 2); CAutoRefPtr<IBitmap> bmp; GETRENDERFACTORY->CreateBitmap(&bmp); bmp->Init(qrSize, qrSize); LPDWORD pBits = (LPDWORD)bmp->LockPixelBits(); memset(pBits, 0xFF, qrSize*qrSize * 4); int nLineWid = qrSize; LPDWORD pLine = pBits + QR_MARGIN*nLineWid; for (int i = 0; i < qrEncode.m_nSymbleSize; i++) { LPDWORD pLineData = pLine + QR_MARGIN; for (int j = 0; j < qrEncode.m_nSymbleSize; j++) { if (qrEncode.m_byModuleData[i][j]) { pLineData[j] = RGBA(0, 0, 0, 255); } } pLine += qrSize; } bmp->UnlockPixelBits(pBits); SetImage(bmp); } else { int qrSize = qrEncode.m_nSymbleSize + 2; CAutoRefPtr<IBitmap> bmp; GETRENDERFACTORY->CreateBitmap(&bmp); SIZE skinSize = m_pSkin->GetSkinSize(); CRect rcWind = GetWindowRect(); bmp->Init(rcWind.Width(), rcWind.Height()); CAutoRefPtr<IBitmap> qrbmp; GETRENDERFACTORY->CreateBitmap(&qrbmp); qrbmp->Init(qrSize, qrSize); LPDWORD pBits = (LPDWORD)qrbmp->LockPixelBits(); memset(pBits, 0x00, qrSize*qrSize * 4); int nLineWid = qrSize; LPDWORD pLine = pBits + nLineWid; for (int i = 0; i < qrEncode.m_nSymbleSize; i++) { LPDWORD pLineData = pLine + 1; for (int j = 0; j < qrEncode.m_nSymbleSize; j++) { if (qrEncode.m_byModuleData[i][j]) { pLineData[j] = RGBA(0xFF, 0xFF, 0xFF, 0xFF); } } pLine += qrSize; } qrbmp->UnlockPixelBits(pBits); MakeCacheApha(m_pSkin, bmp, qrbmp); SetImage(bmp); } } }