static int dbPrintVar(char *varName, response *res, error *err) { if (varName == NULL) { ERROR(err, E_BADARG); goto exit; } void *payload; VAR_TYPE type; if (varMapGetVar(varName, &type, &payload, err)) { goto exit; } int resultBytes; int *results; if (type == VAR_BMP) { struct bitmap *bmp = (struct bitmap *) payload; printf("Bitmap result: \n"); bitmapPrint(bmp); int bmpSize = bitmapSize(bmp); resultBytes = bmpSize * sizeof(int); results = (int *) malloc(resultBytes); if (resultBytes == 0) { free(results); results = NULL; } else { for (int i = 0; i < bmpSize; i++) { results[i] = bitmapIsSet(bmp, i) ? 1 : 0; } } } else if (type == VAR_RESULTS) { fetchResults *fResults = (fetchResults *) payload; resultBytes = fResults->nResultEntries * sizeof(int); results = (int *) malloc(resultBytes); memcpy(results, fResults->results, resultBytes); if (resultBytes == 0) { free(results); results = NULL; } } else { ERROR(err, E_VARTYPE); goto exit; } RESPONSE(res, "Print var results:", resultBytes, results); return 0; exit: return 1; }
int unsortedFetch(void *_header, FILE *dataFp, struct bitmap *bmp, int *resultBytes, int **results, int **indices, error *err) { if (bitmapSize(bmp) != ((columnHeaderUnsorted *) _header)->nEntries) { ERROR(err, E_BADFTC); return 1; } return commonFetch(dataFp, bmp, resultBytes, results, indices, err); }
int commonFetch(FILE *dataFp, struct bitmap *bmp, int *resultBytes, int **results, int **indices, error *err) { // Seek to beginning of file if (fseek(dataFp, 0, SEEK_SET) == -1) { ERROR(err, E_FSK); return 1; } int resultBuf[BUFSIZE]; int indexBuf[BUFSIZE]; int resultOffset = 0; int length = bitmapSize(bmp); for (int i = 0; i < length; i++) { if (resultOffset >= BUFSIZE) { ERROR(err, E_NOMEM); return 1; } if (bitmapIsSet(bmp, i)) { int entry; if (fread(&entry, sizeof(int), 1, dataFp) < 1) { ERROR(err, E_FRD); return 1; } resultBuf[resultOffset] = entry; indexBuf[resultOffset] = i; resultOffset += 1; } else { if (fseek(dataFp, sizeof(int), SEEK_CUR) == -1) { ERROR(err, E_FSK); return 1; } } } *resultBytes = resultOffset * sizeof(int); *results = (int *) malloc(*resultBytes); *indices = (int *) malloc(*resultBytes); if (*results == NULL) { ERROR(err, E_NOMEM); return 1; } if (*indices == NULL) { free(*results); ERROR(err, E_NOMEM); return 1; } memcpy(*results, resultBuf, *resultBytes); memcpy(*indices, indexBuf, *resultBytes); return 0; }
void BitmapToggleButton::OnPaint(wxPaintEvent& event) { if (IsBeingDeleted()) return; const wxSize size = GetClientSize(); const wxSize bmpSize = bitmapSize(); const wxSize delta = size - bmpSize; const wxPoint offset(delta.x / 2, delta.y / 2); wxPaintDC dc(this); dc.DrawBitmap(currentBitmap(), offset); }
void CSplashContainer::Draw(const TRect & /*aRect*/)const { CWindowGc &gc = SystemGc(); gc.SetBrushStyle(CGraphicsContext::ENullBrush); gc.SetBrushColor(KRgbBlack); gc.DrawRect(Rect()); TPoint topLeft(KTopLeftX, KTopLeftY); TSize bitmapSize(KSizeWidth, KSizeHeight); gc.DrawBitmap(TRect(topLeft, bitmapSize), iLogoBitmap); }
///////////////////////////////////////////////////////////////////////////// // CMainToolBarCtrl message handlers void CMainToolBarCtrl::Init() { COLORREF crMask = RGB(255, 255, 255); CSize bitmapSize(32, 32); SetBitmapSize(bitmapSize); CSize buttonSize(40, 40); SetButtonSize(buttonSize); m_normalIL.Create(32, 32, ILC_COLOR24|ILC_MASK, 6, 1); UINT nBtnID[] = {IDB_TB_ADD, IDB_TB_START, IDB_TB_CLEAR, IDB_TB_EXPORT, IDB_TB_OPTION, IDB_TB_EXIT}; COLORREF nCrMask[] = {RGB(255, 255, 255), RGB(255, 0, 255), RGB(255, 0, 255), RGB(255, 255, 255), RGB(255, 255, 255), RGB(255, 255, 255)}; int i; for(i = 0; i < (sizeof(nBtnID)/sizeof(nBtnID[0])); i++) { CBitmap bm; bm.LoadBitmap(nBtnID[i]); m_normalIL.Add(&bm, nCrMask[i]); } SetImageList(&m_normalIL); int nFirstButtonID = IDC_MAIN_TOOLBAR_BUTTON_FIRST; int m_nButtonCount = IDC_MAIN_TOOLBAR_BUTTON_LAST - nFirstButtonID + 1; int nBitmapIndex[] = {0, 1, 2, 3, 4, 5}; TBBUTTON tb; for (int nIndex = 0; nIndex < m_nButtonCount; nIndex++) { CString string; string.LoadString(nIndex + nFirstButtonID); // Add second '\0' int nStringLength = string.GetLength() + 1; TCHAR * pString = string.GetBufferSetLength(nStringLength); pString[nStringLength] = 0; VERIFY((tb.iString = AddStrings(pString)) != -1); string.ReleaseBuffer(); tb.fsState = TBSTATE_ENABLED; tb.fsStyle = TBSTYLE_BUTTON | TBSTYLE_AUTOSIZE; tb.dwData = 0; tb.iBitmap = nBitmapIndex[nIndex]; tb.idCommand = nIndex + nFirstButtonID; AddButtons(1, &tb); } }
BitmapToggleButton::BitmapToggleButton(wxWindow* parent, wxWindowID windowId, const wxBitmap& upBitmap, const wxBitmap& downBitmap) : wxPanel(parent, windowId), m_upBitmap(upBitmap), m_downBitmap(downBitmap), m_upDisabledBitmap(m_upBitmap.ConvertToDisabled()), m_downDisabledBitmap(m_downBitmap.ConvertToDisabled()), m_state(false) { assert(m_upBitmap.IsOk()); assert(m_downBitmap.IsOk()); SetMinClientSize(bitmapSize()); Bind(wxEVT_PAINT, &BitmapToggleButton::OnPaint, this); Bind(wxEVT_LEFT_DOWN, &BitmapToggleButton::OnMouseDown, this); }
void CFontNamesComboBox::DoSetSize( int x, int y, int width, int height, int sizeFlags ) { int heightOrig = height; wxSize bitmapSize( 0, 0 ); if( height != wxDefaultCoord ) { int cx, cy; wxGetCharSize( GetHWND(), &cx, &cy, GetFont() ); int hItem = SendMessage( GetHwnd(), CB_GETITEMHEIGHT, (WPARAM) -1, 0 ); if( m_bmp1 ) bitmapSize = m_bmp1->GetSize(); height = ( EDIT_HEIGHT_FROM_CHAR_HEIGHT( cy ) * 6 ) + hItem - 6; } wxBitmapComboBox::DoSetSize( x, y, width, height, sizeFlags ); if( m_pendingSize != wxDefaultSize ) m_pendingSize = wxSize( width, heightOrig ); }
void wxWizard::AddBitmapRow(wxBoxSizer *mainColumn) { m_sizerBmpAndPage = new wxBoxSizer(wxHORIZONTAL); mainColumn->Add( m_sizerBmpAndPage, 1, // Vertically stretchable wxEXPAND // Horizonal stretching, no border ); mainColumn->Add(0,5, 0, // No vertical stretching wxEXPAND // No border, (mostly useless) horizontal stretching ); #if wxUSE_STATBMP if ( m_bitmap.Ok() ) { wxSize bitmapSize(wxDefaultSize); if (GetBitmapPlacement()) bitmapSize.x = GetMinimumBitmapWidth(); m_statbmp = new wxStaticBitmap(this, wxID_ANY, m_bitmap, wxDefaultPosition, bitmapSize); m_sizerBmpAndPage->Add( m_statbmp, 0, // No horizontal stretching wxALL, // Border all around, top alignment 5 // Border width ); m_sizerBmpAndPage->Add( 5,0, 0, // No horizontal stretching wxEXPAND // No border, (mostly useless) vertical stretching ); } #endif // Added to m_sizerBmpAndPage later m_sizerPage = new wxWizardSizer(this); }
///////////////////////////////////////////////////////////////////////////// // CMyToolBarCtrl message handlers void CMyToolBarCtrl::Init() { COLORREF crMask = RGB(255, 0, 255); CBitmap tbBitmap; tbBitmap.LoadBitmap(IDB_TB_HOT); BITMAP bmpInfo; tbBitmap.GetBitmap(&bmpInfo); CSize bitmapSize(bmpInfo.bmHeight - 2, bmpInfo.bmHeight); SetBitmapSize(bitmapSize); CSize buttonSize(bmpInfo.bmHeight + 7, bmpInfo.bmHeight + 7); SetButtonSize(buttonSize); m_normalIL.Create(bmpInfo.bmHeight - 2, bmpInfo.bmHeight, ILC_COLOR24|ILC_MASK, 1, 1); m_normalIL.Add(&tbBitmap, crMask); SetImageList(&m_normalIL); tbBitmap.DeleteObject(); tbBitmap.LoadBitmap(IDB_TB_HOT); m_hotIL.Create(bmpInfo.bmHeight - 2, bmpInfo.bmHeight, ILC_COLOR24|ILC_MASK, 1, 1); m_hotIL.Add(&tbBitmap, crMask); SetHotImageList(&m_hotIL); tbBitmap.DeleteObject(); tbBitmap.LoadBitmap(IDB_TB_HOT); m_disableIL.Create(bmpInfo.bmHeight - 2, bmpInfo.bmHeight, ILC_COLOR24|ILC_MASK, 1, 1); m_disableIL.Add(&tbBitmap, crMask); SetDisabledImageList(&m_disableIL); tbBitmap.DeleteObject(); int nFirstButtonID = FISRT_TOOLBAR_BUTTON_ID; int m_nButtonCount = LAST_TOOLBAR_BUTTON_ID - nFirstButtonID + 1; TBBUTTON tb; for (int nIndex = 0; nIndex < m_nButtonCount; nIndex++) { CString string; string.LoadString(nIndex + nFirstButtonID); // Add second '\0' int nStringLength = string.GetLength() + 1; TCHAR * pString = string.GetBufferSetLength(nStringLength); pString[nStringLength] = 0; VERIFY((tb.iString = AddStrings(pString)) != -1); string.ReleaseBuffer(); tb.fsState = TBSTATE_ENABLED; tb.fsStyle = TBSTYLE_BUTTON | TBSTYLE_AUTOSIZE; tb.dwData = 0; tb.iBitmap = nIndex; tb.idCommand = nIndex + nFirstButtonID; if(tb.idCommand >= TBBTN_DUMMY2) { tb.fsState = 0; } AddButtons(1, &tb); } }
TBool CAknAnimationData::ExecutePendingAnimationStep(CBitmapContext& aGc, TAnimMultiStep* aStep) { TBool done = EFalse; switch (aStep->iDrawStep.Type()) { case EAnimDrawLine: { TAnimLineDrawStep* step = (aStep->iDrawStep.LineDrawStep()); if (aStep->iSubStep == step->iSteps -1) { done = ETrue; } { TInt diffX = step->iEndX - step->iStartX; TInt diffY = step->iEndY - step->iStartY; TInt startX = step->iStartX + (diffX * aStep->iSubStep / step->iSteps); TInt startY = step->iStartY + (diffY * aStep->iSubStep / step->iSteps); TInt endX = step->iStartX + (diffX * (aStep->iSubStep+1)/ step->iSteps); TInt endY = step->iStartY + (diffY * (aStep->iSubStep+1) / step->iSteps); aGc.SetBrushColor(iDrawColor); aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); aGc.Clear(TRect(TPoint(startX,startY),TPoint(endX+1, endY+1))); } } break; case EAnimRevealPartNewViewFromLeft: { TAnimBlitStep* step = (aStep->iDrawStep.BlitStep()); TPoint offset((step->iWidth * aStep->iSubStep) / step->iSteps, 0); TSize size((step->iWidth / step->iSteps)+1, step->iHeight); aGc.BitBlt(TPoint(step->iDestX, step->iDestY) + offset, iViewBitmap, TRect(TPoint(step->iSrcX, step->iSrcY) + offset, size)); if (aStep->iSubStep == step->iSteps-1) done = ETrue; } break; case EAnimRevealPartNewViewFromRight: { TAnimBlitStep* step = (aStep->iDrawStep.BlitStep()); TInt thisStep = (step->iSteps - aStep->iSubStep) - 1; TPoint offset((step->iWidth * thisStep) / step->iSteps, 0); TSize size((step->iWidth / step->iSteps)+1, step->iHeight); aGc.BitBlt(TPoint(step->iDestX, step->iDestY) + offset, iViewBitmap, TRect(TPoint(step->iSrcX, step->iSrcY) + offset, size)); if (aStep->iSubStep == step->iSteps-1) done = ETrue; } break; case EAnimRevealPartNewViewFromTop: { TAnimBlitStep* step = (aStep->iDrawStep.BlitStep()); TPoint offset(0,(step->iHeight * aStep->iSubStep) / step->iSteps); TSize size(step->iWidth,(step->iHeight / step->iSteps)+1); aGc.BitBlt(TPoint(step->iDestX, step->iDestY) + offset, iViewBitmap, TRect(TPoint(step->iSrcX, step->iSrcY) + offset, size)); if (aStep->iSubStep == step->iSteps-1) done = ETrue; } break; case EAnimRevealPartNewViewFromBottom: { TAnimBlitStep* step = (aStep->iDrawStep.BlitStep()); TInt thisStep = (step->iSteps - aStep->iSubStep) - 1; TPoint offset(0,(step->iHeight * thisStep) / step->iSteps); TSize size(step->iWidth,(step->iHeight / step->iSteps)+1); aGc.BitBlt(TPoint(step->iDestX, step->iDestY) + offset, iViewBitmap, TRect(TPoint(step->iSrcX, step->iSrcY) + offset, size)); if (aStep->iSubStep == step->iSteps-1) done = ETrue; } break; case EAnimBlitSlideNewView: // Slide the bitmap between two screen positions { TAnimSlideStep* step = (aStep->iDrawStep.SlideStep()); TSize bitmapSize(step->iWidth, step->iHeight); TInt slideDifferenceX = step->iSlideToX - step->iSlideFromX; TInt slideDifferenceY = step->iSlideToY - step->iSlideFromY; TInt slidePosX = step->iSlideFromX + ((slideDifferenceX * aStep->iSubStep) / step->iSteps); TInt slidePosY = step->iSlideFromY + ((slideDifferenceY * aStep->iSubStep) / step->iSteps); aGc.BitBlt(TPoint(slidePosX, slidePosY), iViewBitmap, TRect(TPoint(step->iSrcX, step->iSrcY), bitmapSize)); if (aStep->iSubStep == step->iSteps) done = ETrue; } break; case EAnimBlitSlideNewViewClearBehind: // Slide the bitmap between two screen positions, clearing the screen behind it { TAnimSlideStep* step = (aStep->iDrawStep.SlideStep()); TSize bitmapSize(step->iWidth, step->iHeight); TInt slideDifferenceX = step->iSlideToX - step->iSlideFromX; TInt slideDifferenceY = step->iSlideToY - step->iSlideFromY; if (aStep->iSubStep > 0) { // This is not the first step, so clear over the area of the previous step TInt slidePosX = step->iSlideFromX + ((slideDifferenceX * (aStep->iSubStep-1)) / step->iSteps); TInt slidePosY = step->iSlideFromY + ((slideDifferenceY * (aStep->iSubStep-1)) / step->iSteps); aGc.Clear(TRect(TPoint(slidePosX, slidePosY), bitmapSize)); } TInt slidePosX = step->iSlideFromX + ((slideDifferenceX * aStep->iSubStep) / step->iSteps); TInt slidePosY = step->iSlideFromY + ((slideDifferenceY * aStep->iSubStep) / step->iSteps); aGc.BitBlt(TPoint(slidePosX, slidePosY), iViewBitmap, TRect(TPoint(step->iSrcX, step->iSrcY), bitmapSize)); if (aStep->iSubStep == step->iSteps) done = ETrue; } break; default: done = DrawUserAnimationStep(aGc, *aStep); break; } aStep->iSubStep++; return done; }
static int dbFetch(tableInfo *tbl, fetchArgs *args, response *res, error *err) { char *columnName = args->columnName; char *oldVarName = args->oldVarName; char *newVarName = args->newVarName; if (columnName == NULL || oldVarName == NULL) { ERROR(err, E_BADARG); goto exit; } printf("Fetching from column '%s'...\n", columnName); // Get bitmap from var name struct bitmap *bmp; VAR_TYPE type; if (varMapGetVar(oldVarName, &type, (void **) (&bmp), err)) { goto exit; } if (type != VAR_BMP) { ERROR(err, E_VARTYPE); goto exit; } printf("Got bitmap for variable '%s'\n", oldVarName); bitmapPrint(bmp); // Retrieve the column from disk column *col = (column *) malloc(sizeof(column)); if (col == NULL) { ERROR(err, E_NOMEM); goto exit; } if (columnReadFromDisk(tbl, columnName, col, err)) { free(col); goto exit; } // Fetch the results int resultBytes; int *results; int *indices; if (columnFetch(col, bmp, &resultBytes, &results, &indices, err)) { goto cleanupColumn; } // Return data to user if the haven't given a variable to store it in if (newVarName[0] == '\0') { int nResults = resultBytes / sizeof(int); printf("Got %d results from fetch\n", nResults); printf("["); for (int i = 0; i < nResults; i++) { printf("%d,", results[i]); } printf("]\n"); if (resultBytes == 0) { results = NULL; } RESPONSE(res, "Fetch results:", resultBytes, results); free(indices); } // Otherwise, store data in variable else { // Add variable-results pair to varmap fetchResults *fResults = (fetchResults *) malloc(sizeof(fetchResults)); if (fResults == NULL) { ERROR(err, E_NOMEM); goto cleanupColumn; } fResults->nColumnEntries = bitmapSize(bmp); fResults->nResultEntries = resultBytes / sizeof(int); fResults->results = results; fResults->indices = indices; if (varMapAddVar(newVarName, VAR_RESULTS, fResults, err)) { free(results); free(indices); free(fResults); goto cleanupColumn; } printf("Added variable '%s'\n", newVarName); RESPONSE_SUCCESS(res); } // Cleanup columnDestroy(col); return 0; // cleanupResults: // free(results); // free(indices); cleanupColumn: columnDestroy(col); exit: return 1; }
Bitmap Chunk::getBitmap() { return Bitmap(reinterpret_cast<word_t*>(bitmapBase()), bitmapSize() * 8); }
Address Chunk::storageBase() const { ASSERT(isAligned(bitmapSize(), kWordSize)); return bitmapBase() + bitmapSize(); }
void CTDirectScreenBitmap::ExhaustiveTestMergePerDispModeL(TDisplayMode aDrawDeviceDispMode, TBool aInSrcPreMul,TBool aInDestPreMul,TBool aOutDestPreMul, TInt aStepSize,TInt aChannelControl,TInt aOtherChannels, TDisplayMode aTestMode) { CFbsDrawDevice *pDev = NULL; iDispMode = aDrawDeviceDispMode; TRAPD(err,pDev = CFbsDrawDevice::NewScreenDeviceL(0,aDrawDeviceDispMode)); if (err !=KErrNone) { INFO_PRINTF2(_L("Note: Failed to create screen device for display mode %i - not supported on this config?"),iDispMode); } else { INFO_PRINTF2(_L("Test Exhaustive Merge for display mode %i "),iDispMode); User::LeaveIfError(pDev->InitScreen()); pDev->SetAutoUpdate(ETrue); TSize screenSize = pDev->SizeInPixels(); //Full screen non-incremental run TRect directRect(TPoint(0, 0), screenSize); INFO_PRINTF1(_L("PDEF099416: Test of pixel merge over full colour and alpha range")); TRAPD(err, ConstructL(directRect, CDirectScreenBitmap::ENone)); if (err) { delete pDev; INFO_PRINTF1(_L("The Direct Screen Bitmap object is not created")); } else { if (!iInterface->ScreenClear()) { INFO_PRINTF1(_L("The display mode of the iBitmapInfo is not expected")); delete pDev; return; } else { TSize bitmapSize(256,1); TUint32 bitmapMem[256]; TUint32 srcLine[256]; CFbsDrawDevice* bmd = CFbsDrawDevice::NewBitmapDeviceL(bitmapSize, aTestMode, CFbsBitmap::ScanLineLength(256, aTestMode)); CleanupStack::PushL(bmd); //initialize bmd->SetAutoUpdate(EFalse); bmd->SetBits(bitmapMem); //Eveything printed to the screen is just to show the error levels graphically. //Patterns are very interesting sometimes if (screenSize.iHeight>200 && screenSize.iWidth>600) { iInterface->BeginDraw(); iInterface->DrawColor(TRect(260,0,290,30),TRgb(255,0,0)); iInterface->DrawColor(TRect(260,30,290,60),TRgb(100,0,0)); iInterface->DrawColor(TRect(260,60,290,90),TRgb(100,0,0)); iInterface->DrawColor(TRect(260,100,290,130),TRgb(0,255,0)); iInterface->DrawColor(TRect(260,130,290,160),TRgb(0,200,0)); iInterface->DrawColor(TRect(260,160,290,190),TRgb(0,100,0)); iInterface->DrawColor(TRect(560,100,590,130),TRgb(0,0,255)); iInterface->DrawColor(TRect(560,130,590,160),TRgb(0,0,200)); iInterface->DrawColor(TRect(560,160,590,190),TRgb(0,0,100)); iInterface->EndDraw(iRequestStatus); } //const TInt channelMask; if (aChannelControl<1) { channelMask=0x0000FF; } else { if(aChannelControl==1) { channelMask=0x00FF00; } else { channelMask=0xFF0000; } } const TInt otherMask=0xFFFFFF^channelMask; const TInt channelMul=channelMask&0x01010101; const TInt addFactor=aOtherChannels & otherMask; //Use to set the other colour channels with a fixed test value TInt passFlag=0; INFO_PRINTF3(_L("AddFactor pass: channel %i others %x "),aChannelControl,addFactor); passFlag=passFlag^0x8000; const TReal KIgnore=0.00000001;//0.3; const TReal KGross=1.51; const TReal KMultiplyErrorBrightness=200.0; TReal errMax=20; TReal errAMax256=0; TReal totErrCol=0; TReal totErrAlpha=0; TReal zeroErrCol=0; TReal zeroErrAlpha=0; TInt countAlphas=0; TInt countColours=0; const TInt stepFactor=aStepSize; //1, 3, 5, 15, 17; //This has a ^3 effect on speed TIgnoreSpecialCases ignoreSpecialCases(aInSrcPreMul,aInDestPreMul,aOutDestPreMul); //bkgrdMask is background mask/alpha input value for (TInt bkgrdMask=0;bkgrdMask<256;bkgrdMask+=stepFactor) { TInt logLine=-1; iInterface->BeginDraw(); iInterface->DrawColour64KPixel(270+bkgrdMask/screenSize.iHeight,bkgrdMask%screenSize.iHeight, TRgb(addFactor|passFlag)); TInt maxChannels=256; if (aInDestPreMul) { maxChannels=bkgrdMask+1; } TInt clippedother=((addFactor-((bkgrdMask*0x010101)&otherMask))>>8)&otherMask; //clippedother is now 0x00FF00FF or 0x00000000 (or 0x00FF0000 or 0x000000FF) clippedother=(addFactor&(clippedother^otherMask))|(((bkgrdMask*0x010101)&clippedother)); //bkgrdChannel is background channel input value. In PM it is 0...bkgrdMask. In NP it is 0...255 for (TInt bkgrdChannel=0,colour=(bkgrdMask<<24)|clippedother,stepChannel=stepFactor*channelMul;bkgrdChannel<maxChannels;bkgrdChannel+=stepFactor,colour+=stepChannel) { TInt failsPerPass=10; logLine++; if (logLine>=screenSize.iHeight) { logLine=0; } //srcMask is the source mask/alpha for (TInt srcMask=0;srcMask<256;srcMask+=stepFactor) //0 and 255 are special cases, but need testing anyway! { TInt maxChannels=256; //nested if (aInSrcPreMul) { maxChannels=srcMask+1; //In PM-PM source colour passes through unchanged, so skip the tests } bmd->WriteRgbMulti(0,0,maxChannels,1,TRgb(colour,bkgrdMask),CGraphicsContext::EDrawModeWriteAlpha); TInt clippedother=((addFactor-((srcMask*0x010101)&otherMask))>>8)&otherMask; //clippedother is now 0x00FF00FF or 0x00000000 (or 0x00FF0000 or 0x000000FF) clippedother=(addFactor&(clippedother^otherMask))|(((srcMask*0x010101)&clippedother)); //srcChannel1 is the source channel input value. In PM it is 0...srcMask. In NP it is 0...255 for (TInt srcChannel1=0,C=(srcMask<<24)+clippedother;srcChannel1<maxChannels;srcChannel1++,C+=channelMul) { srcLine[srcChannel1]=C; } bmd->WriteLine(0,0,maxChannels,srcLine,CGraphicsContext::EDrawModePEN); TReal errPos=0; TReal errNeg=0; TReal errGross=0; TReal errAPos=0; TReal errANeg=0; TReal errAGross=0; //source multiplier factor for alpha that can then be used to optimise non-multiplied input calculations. TReal srcMultiplier=srcMask/255.0; //destination/background multiplier factor for alpha that can then be used to optimise non-multiplied input calculations. TReal destMultiplier=(bkgrdMask/255.0)*(1.0-srcMultiplier); //alphaPixelValue is the alpha pixel value as generated from the library code under test TUint alphaPixelValue=bmd->ReadPixel(0,0).Alpha(); //alphaDiff is the difference in alpha between pixel and float calcuation, i.e. the error. This can be less than 1 level of brightness, i.e. insignificant. TReal alphaDiff=0.0; //pre-mul mode does not effect the alpha calculation //alphaOutputValue is a floating-point calculation of the alpha output value using 255.0 as the scaling factor. TReal alphaOutputValue=(srcMultiplier+destMultiplier)*255.0; alphaDiff=alphaOutputValue-alphaPixelValue; zeroErrAlpha+=alphaDiff; if (alphaDiff>KIgnore || alphaDiff<-KIgnore) { if (alphaDiff>0) { if (alphaDiff>KGross) { if (--failsPerPass>0) LogColourEvent(bkgrdMask,bkgrdChannel,srcMask,-1,alphaOutputValue,alphaPixelValue,alphaDiff,_L("Big Alpha error: expected %f, got %f"),ETrue); errAGross+=(alphaDiff-KIgnore)*KMultiplyErrorBrightness; } else { errAPos+=(alphaDiff-KIgnore)*KMultiplyErrorBrightness; } totErrAlpha+=alphaDiff; } else { if(alphaDiff<-KGross) { if (--failsPerPass>0) LogColourEvent(bkgrdMask,bkgrdChannel,srcMask,-1,alphaOutputValue,alphaPixelValue,alphaDiff,_L("Big Alpha error: expected %f, got %f"),ETrue); errAGross-=(alphaDiff+KIgnore)*KMultiplyErrorBrightness; } else { errANeg-=(alphaDiff+KIgnore)*KMultiplyErrorBrightness; } totErrAlpha-=alphaDiff; } } TInt errA= STATIC_CAST(TInt,(errAPos-errANeg)); countAlphas++; countColours+=maxChannels; //The other channel values should not change while the tested channel is modulated... //So I grab it's value for the zero case to compare. TUint otherChannels0=bmd->ReadPixel(0,0).Color16MA()&(otherMask|0xff000000); //srcChannel is the source channel input value. In PM it is 0...srcMask. In NP it is 0...255 for (TInt srcChannel=0;srcChannel<maxChannels;srcChannel++) { //channelOutputValue is a floating-point calculation of the channel output value using 255.0 as the scaling factor. TReal channelOutputValue; if (aInSrcPreMul) { channelOutputValue=srcChannel; } else { channelOutputValue=srcChannel*srcMultiplier; } if (aInDestPreMul) { channelOutputValue+=bkgrdChannel*(1.0-srcMultiplier); } else { channelOutputValue+=bkgrdChannel*destMultiplier; } if (!aOutDestPreMul) { if ((srcMultiplier+destMultiplier)!=0) { channelOutputValue=channelOutputValue/(srcMultiplier+destMultiplier); } } TUint readPixel=bmd->ReadPixel(srcChannel,0).Color16MA(); //channelPixelValue is the channel pixel value as generated from the library code under test TUint channelPixelValue=(readPixel&channelMask)/channelMul; if (aOutDestPreMul) { if (channelPixelValue>alphaPixelValue) { if (!ignoreSpecialCases(bkgrdMask,bkgrdChannel,srcMask,srcChannel)) { if (--failsPerPass>0) { LogColourEvent(bkgrdMask,bkgrdChannel,srcMask,srcChannel,alphaPixelValue,channelOutputValue,channelPixelValue,_L("Output multiplied colour exceeds alpha %f: expected %f got %f"),!ignoreSpecialCases(bkgrdMask,bkgrdChannel,srcMask,srcChannel)); } } errGross+=10; //output value out of range - bright red spot! } } TUint otherChannels=readPixel&(otherMask|0xff000000); if (otherChannels!=otherChannels0) { //Other channels should all be constant here! LogColourEvent(bkgrdMask,bkgrdChannel,srcMask,srcChannel,otherChannels0,otherChannels,0,_L("Output for other channels changed when modulating test channel only - Inter-channel leakage? srcChannel=0 value = %f, this value = %f"),ETrue); } //channelDiff is the difference in channel between pixel and float calcuation, i.e. the error. This can be less than 1 level of brightness, i.e. insignificant. TReal channelDiff=channelOutputValue-channelPixelValue; zeroErrCol+=channelDiff; if (channelDiff>KIgnore || channelDiff<-KIgnore) if (channelDiff>0) { if (channelDiff>KGross) { if (!ignoreSpecialCases(bkgrdMask,bkgrdChannel,srcMask,srcChannel)) { if (--failsPerPass>0) { LogColourEvent(bkgrdMask,bkgrdChannel,srcMask,srcChannel,channelOutputValue,channelPixelValue,channelDiff,_L("Big Colour error: expected %f, got %f"),!ignoreSpecialCases(bkgrdMask,bkgrdChannel,srcMask,srcChannel)); } } errGross+=channelDiff-KIgnore; } else { errPos+=channelDiff-KIgnore; } totErrCol+=channelDiff; } else { if (channelDiff<-KGross) { if (!ignoreSpecialCases(bkgrdMask,bkgrdChannel,srcMask,srcChannel)) { if (--failsPerPass>0) { LogColourEvent(bkgrdMask,bkgrdChannel,srcMask,srcChannel,channelOutputValue,channelPixelValue,channelDiff,_L("Big Colour error: expected %f, got %f"),!ignoreSpecialCases(bkgrdMask,bkgrdChannel,srcMask,srcChannel)); } } errGross-=channelDiff+KIgnore; } else { errNeg-=channelDiff+KIgnore; } totErrCol-=channelDiff; } } TReal err=errPos-errNeg; errGross+=errAGross; if (errA>errAMax256) { //LogColourEvent(bkgrdMask,bkgrdChannel,srcMask,-1,errA,0,0,_L("Row alpha error level increase, now: %f"),EFalse); errAMax256=errA; } errPos=Min(TReal(255),(errPos*KMultiplyErrorBrightness/TReal(maxChannels))); errNeg=Min(TReal(255),(errNeg*KMultiplyErrorBrightness/TReal(maxChannels))); TReal err256=Min(TReal(255),err*KMultiplyErrorBrightness/TReal(maxChannels)); if (err256>errMax) { //LogColourEvent(bkgrdMask,bkgrdChannel,srcMask,-1,err256,err,0,_L("Row colour error level increase, per call now: %f value for row: %f"),EFalse); errMax=err256; } errAPos=Min(TReal(255),(errAPos)); errANeg=Min(TReal(255),(errANeg)); errA=Min(255,errA); if (errGross>10) { errGross=TReal(255); } else { errGross*=TReal(20); } TRect pix(TPoint(),TSize(1,1)); if (screenSize.iWidth>260) { iInterface->DrawColour64KPixel(srcMask,logLine, TRgb(STATIC_CAST(TInt,errGross),STATIC_CAST(TInt,errNeg),STATIC_CAST(TInt,errPos))); } if (screenSize.iWidth>360) { iInterface->DrawColour64KPixel(srcMask+300,logLine, TRgb(STATIC_CAST(TInt,errGross),STATIC_CAST(TInt,errNeg),STATIC_CAST(TInt,errPos))); } } if (failsPerPass<0) { //note that this count may be out by 1... INFO_PRINTF2(_L("Additional %i errors not reported in this pass."),-failsPerPass); } } iInterface->EndDraw(iRequestStatus); } if (ignoreSpecialCases.IgnoreCount() && ignoreSpecialCases.IgnoreCount()<ignoreSpecialCases.ExpectedIgnoreCount(aStepSize)) { TEST(ignoreSpecialCases.IgnoreCount()<ignoreSpecialCases.ExpectedIgnoreCount(aStepSize)); INFO_PRINTF3(_L("There were less ignored special-case errors than exepected (but more than zero): Expected: 0 or %i, got %i"), ignoreSpecialCases.ExpectedIgnoreCount(aStepSize),ignoreSpecialCases.IgnoreCount() ); } INFO_PRINTF4(_L("Highest error rows (normalised @%f per row): Alpha: %f, Colour: %f "),KMultiplyErrorBrightness,errMax,errAMax256); INFO_PRINTF4(_L("Alpha: Samples: %i, total abs= %f, total signed=%f (should be 0)"),countAlphas,totErrAlpha,zeroErrAlpha); INFO_PRINTF4(_L("Colour: Samples: %i, total abs= %f, total signed=%f (should be 0)"),countColours,totErrCol,zeroErrCol); CleanupStack::PopAndDestroy(bmd); delete pDev; } } } }