bool ImageTile::TriggeredRaise(unsigned channelA, unsigned scanA, unsigned channelB, unsigned scanB, long double variance) const { if(channelB >= _channelCount) return false; if(scanB >= _scanCount) return false; long double value = GetValueAt(channelA, scanA) - GetValueAt(channelB, scanB); return value > _trigger * variance * 2.0; }
int cVoronoiMap::GetValueAt(int a_X, int a_Y, int & a_MinDist) { int SeedX, SeedY, MinDist2; int res = GetValueAt(a_X, a_Y, SeedX, SeedY, MinDist2); a_MinDist = (a_X - SeedX) * (a_X - SeedX) + (a_Y - SeedY) * (a_Y - SeedY); return res; }
double Series::GetValueAtOrNear(size_t index){ double value = NULL_VALUE; size_t lookDistance = 0; while (NULL_VALUE == value && lookDistance < DEFAULT_LOOK_DISTANCE){ value = GetValueAt(index - lookDistance); lookDistance++; } return value; }
HRESULT IDSMPropertyBagImpl::GetProperty(LPCWSTR key, BSTR* value) { CheckPointer(key, E_POINTER); CheckPointer(value, E_POINTER); int i = FindKey(key); if(i < 0) return E_FAIL; *value = GetValueAt(i).AllocSysString(); return S_OK; }
// map attributes that depend on the index of the column: // columnalign, columnlines, XXX need columnwidth and columnspacing too static void MapColAttributesIntoCSS(nsIFrame* aTableFrame, nsIFrame* aRowFrame, nsIFrame* aCellFrame) { DEBUG_VERIFY_THAT_FRAME_IS_TABLE(aTableFrame); DEBUG_VERIFY_THAT_FRAME_IS(aRowFrame, TABLE_ROW); DEBUG_VERIFY_THAT_FRAME_IS(aCellFrame, TABLE_CELL); PRInt32 rowIndex, colIndex; ((nsTableCellFrame*)aCellFrame)->GetCellIndexes(rowIndex, colIndex); nsIContent* cellContent = aCellFrame->GetContent(); PRUnichar* attr; // see if the columnalign attribute is not already set if (!cellContent->HasAttr(kNameSpaceID_None, nsGkAtoms::columnalign_) && !cellContent->HasAttr(kNameSpaceID_None, nsGkAtoms::MOZcolumnalign)) { // see if the columnalign attribute was specified on the row attr = GetValueAt(aRowFrame, nsGkAtoms::columnalign_, colIndex); if (!attr) { // see if the columnalign attribute was specified on the table attr = GetValueAt(aTableFrame, nsGkAtoms::columnalign_, colIndex); } if (attr) { // set our special -moz attribute without notifying a reflow cellContent->SetAttr(kNameSpaceID_None, nsGkAtoms::MOZcolumnalign, nsDependentString(attr), PR_FALSE); } } // if we are not on the first column, see if |columnlines| was specified on // the table. Note that we pass 'colIndex-1' because the CSS rule in mathml.css // is associated to 'border-left', and it is as if we draw the line on behalf // of the previous cell. This way of doing so allows us to handle selective lines, // e.g., 'r|cl', and cases of spanning cells without further complications. if (colIndex > 0 && !cellContent->HasAttr(kNameSpaceID_None, nsGkAtoms::MOZcolumnline)) { attr = GetValueAt(aTableFrame, nsGkAtoms::columnlines_, colIndex-1); if (attr) { // set our special -moz attribute without notifying a reflow cellContent->SetAttr(kNameSpaceID_None, nsGkAtoms::MOZcolumnline, nsDependentString(attr), PR_FALSE); } } }
NS_IMETHODIMP nsAutoCompleteController::GetCellText(PRInt32 row, nsITreeColumn* col, nsAString& _retval) { const PRUnichar* colID; col->GetIdConst(&colID); if (NS_LITERAL_STRING("treecolAutoCompleteValue").Equals(colID)) GetValueAt(row, _retval); else if (NS_LITERAL_STRING("treecolAutoCompleteComment").Equals(colID)) GetCommentAt(row, _retval); return NS_OK; }
void ImageTile::LineThreshold(bool evaluateBaseline, long double mean, long double variance, bool convolve) { Image2DPtr input = Image2D::CreateEmptyImagePtr(_scanCount, _channelCount); Mask2DPtr output = Mask2D::CreateSetMaskPtr<false>(_scanCount, _channelCount); if(evaluateBaseline) { for(unsigned channel = 0;channel<_channelCount;++channel) for(unsigned scan = 0;scan<_scanCount;++scan) input->SetValue(scan, channel, GetValueAt(channel, scan) - EvaluateBaselineFunction(scan, channel)); } else { for(unsigned channel = 0;channel<_channelCount;++channel) for(unsigned scan = 0;scan<_scanCount;++scan) input->SetValue(scan, channel, GetValueAt(channel, scan) - mean); } ThresholdMitigater::SumThreshold(input, output, 1, _trigger * variance); ThresholdMitigater::SumThreshold(input, output, 2, _trigger * variance * 1.6); ThresholdMitigater::SumThreshold(input, output, 3, _trigger * variance * 2.2); ThresholdMitigater::SumThreshold(input, output, 5, _trigger * variance * 3.0); ThresholdMitigater::SumThreshold(input, output, 10, _trigger * variance * 5.0); unsigned count = 0; for(unsigned channel = 0;channel<_channelCount;++channel) { for(unsigned scan = 0;scan<_scanCount;++scan) { if(output->Value(scan, channel)) { Window(scan, channel); count++; } } } while(count*2 > _channelCount*_scanCount) { size_t x = (size_t) (RNG::Uniform()*_scanCount); size_t y = (size_t) (RNG::Uniform()*_channelCount); if(_isWindowed[y][x]) { count--; _isWindowed[y][x]=false; } } if(convolve) ConvolveWindows(); }
// map attributes that depend on the index of the row: // rowalign, rowlines, XXX need rowspacing too static void MapRowAttributesIntoCSS(nsIFrame* aTableFrame, nsIFrame* aRowFrame) { DEBUG_VERIFY_THAT_FRAME_IS_TABLE(aTableFrame); DEBUG_VERIFY_THAT_FRAME_IS(aRowFrame, TABLE_ROW); PRInt32 rowIndex = ((nsTableRowFrame*)aRowFrame)->GetRowIndex(); nsIContent* rowContent = aRowFrame->GetContent(); PRUnichar* attr; // see if the rowalign attribute is not already set if (!rowContent->HasAttr(kNameSpaceID_None, nsGkAtoms::rowalign_) && !rowContent->HasAttr(kNameSpaceID_None, nsGkAtoms::MOZrowalign)) { // see if the rowalign attribute was specified on the table attr = GetValueAt(aTableFrame, nsGkAtoms::rowalign_, rowIndex); if (attr) { // set our special -moz attribute on the row without notifying a reflow rowContent->SetAttr(kNameSpaceID_None, nsGkAtoms::MOZrowalign, nsDependentString(attr), PR_FALSE); } } // if we are not on the first row, see if |rowlines| was specified on the table. // Note that we pass 'rowIndex-1' because the CSS rule in mathml.css is associated // to 'border-top', and it is as if we draw the line on behalf of the previous cell. // This way of doing so allows us to handle selective lines, [row]\hline[row][row]', // and cases of spanning cells without further complications. if (rowIndex > 0 && !rowContent->HasAttr(kNameSpaceID_None, nsGkAtoms::MOZrowline)) { attr = GetValueAt(aTableFrame, nsGkAtoms::rowlines_, rowIndex-1); if (attr) { // set our special -moz attribute on the row without notifying a reflow rowContent->SetAttr(kNameSpaceID_None, nsGkAtoms::MOZrowline, nsDependentString(attr), PR_FALSE); } } }
void CStringTable::PopulateXmlNode(CXmlTree& Tree, CTreeElement< CXmlNode > * pXmlNode) const { CXmlNode ConfigNode, DataNode; CString ValueData; for (int i=0;i<(int) GetSize();i++) { ConfigNode.SetType(xmlnOpen); ConfigNode.SetData(GetNameAt(i)); CTreeElement< CXmlNode > * pXmlConfigNode = Tree.AddChildLast(pXmlNode, ConfigNode); DataNode.SetType(xmlnData); ValueData = GetValueAt(i); ValueData.Replace("\\","\\\\"); DataNode.SetData(ValueData); Tree.AddChildLast(pXmlConfigNode, DataNode); ConfigNode.SetType(xmlnClose); Tree.AddChildLast(pXmlNode, ConfigNode); } }
void ImageTile::SetWindows(long double variance, bool convolve) { bool methodA = false; bool methodB = false; bool methodC = true; // Unwindow everything for(unsigned channel = 0;channel<_channelCount;++channel) { for(unsigned scan = 0;scan<_scanCount;++scan) _isWindowed[channel][scan] = false; } if(methodA) { // Window everything higher than trigger * sigma for(unsigned channel = 0;channel<_channelCount;++channel) { for(unsigned scan = 0;scan<_scanCount;++scan) { if(fabsl(GetValueAt(channel, scan) - EvaluateBaselineFunction(scan, channel)) > _trigger * variance) { Window(scan, channel); } } } } if(methodB) { for(unsigned channel = 0;channel<_channelCount;++channel) { for(unsigned scan = 0;scan<_scanCount;++scan) { bool triggered = TriggeredRaise(channel, scan, channel-1, scan-1, variance) || TriggeredRaise(channel, scan, channel-1, scan+1, variance) || TriggeredRaise(channel, scan, channel+1, scan-1, variance) || TriggeredRaise(channel, scan, channel+1, scan+1, variance); if(triggered) Window(scan, channel); } } } if(convolve) ConvolveWindows(); if(methodC) { LineThreshold(true, 0.0, variance, convolve); } }
void CDSMMuxerFilter::MuxFileInfo(IBitStream* pBS) { int len = 1; CSimpleMap<CStringA, CStringA> si; for (int i = 0; i < GetSize(); i++) { CStringA key = CStringA(CString(GetKeyAt(i))), value = UTF16To8(GetValueAt(i)); if (key.GetLength() != 4) { continue; } si.Add(key, value); len += 4 + value.GetLength() + 1; } MuxPacketHeader(pBS, DSMP_FILEINFO, len); pBS->BitWrite(DSMF_VERSION, 8); for (int i = 0; i < si.GetSize(); i++) { CStringA key = si.GetKeyAt(i), value = si.GetValueAt(i); pBS->ByteWrite((LPCSTR)key, 4); pBS->ByteWrite((LPCSTR)value, value.GetLength() + 1); } }
void ReRulerWidget::DrawForeground( QPainter& _painter ) { _painter.setPen( QColor( 0, 255, 255 ) ); IsHorizontal() ? _painter.drawLine( QPoint( m_cursor, 0 ), QPoint( m_cursor, height() ) ) : _painter.drawLine( QPoint( 0, m_cursor ), QPoint( width(), m_cursor ) ); QString valueText = QString().setNum( GetValueAt( m_cursor ) ); if( IsShowCursorValue() ) { QFontMetrics fm( _painter.font() ); _painter.save(); const int cursorMargin = 2; const int edgeMargin = 2; if( IsHorizontal() ) { _painter.translate( m_cursor, IsMarkOnSizeA() ? fm.height() : height() - edgeMargin ); if( m_cursor <= ( width() / 2 ) ) _painter.drawText( cursorMargin, 0, valueText ); else _painter.drawText( -fm.width( valueText ) - cursorMargin, 0, valueText ); } else { _painter.translate( IsMarkOnSizeA() ? fm.height() : width() - edgeMargin, m_cursor ); _painter.rotate( -90 ); if( m_cursor <= ( height() / 2 ) ) _painter.drawText( -fm.width( valueText ) - cursorMargin, 0, valueText ); else _painter.drawText( cursorMargin, 0, valueText ); } _painter.restore(); } }
int cVoronoiMap::GetValueAt(int a_X, int a_Y, int & a_MinDist) { int MinDist2; return GetValueAt(a_X, a_Y, a_MinDist, MinDist2); }
int cVoronoiMap::GetValueAt(int a_X, int a_Y) { int SeedX, SeedY, MinDist2; return GetValueAt(a_X, a_Y, SeedX, SeedY, MinDist2); }
NS_IMETHODIMP nsFileResult::GetLabelAt(PRInt32 index, nsAString & aValue) { return GetValueAt(index, aValue); }
NS_IMETHODIMP nsAutoCompleteSimpleResult::GetLabelAt(int32_t aIndex, nsAString& _retval) { return GetValueAt(aIndex, _retval); }
NS_IMETHODIMP nsFileResult::GetFinalCompleteValueAt(int32_t index, nsAString & aValue) { return GetValueAt(index, aValue); }
// ConvertTypeTo() // Converts the image from it's current type to the new type. This // is NOT an in-place operation; rather, it creates and returns a // new ImageClass, which must be freed by the main program. The // original ImageClass is not modified in any way. For conversion // to indexed images, an optional palette can also be passed in. // Images will be quantized to match the palette as needed. // This function is most useful for image savers and device-dependant // output of images. // Note that if the source image doesn't need to be converted, this // function will return a pointer to the existing image class, so // be sure to check for this. A returned value of NULL means some // error occured ImageClass * ImageClass::ConvertTypeTo( int new_type, int num_reg, IMG_BYTE *pal ) { if( new_type == IMAGE_INVALID_TYPE ) // Invalid type; fail return NULL; if( new_type == type ) // Already in the new mode; return this image return this; ImageClass * new_image = NULL; int x, y; IMG_BYTE *new_pal; const IMG_BYTE *rgb; IMG_BYTE value; switch( new_type ) { case IMAGE_RGB: // Convert to RGB new_image = new ImageClass( width, height, IMAGE_RGB ); if( !new_image || !(*new_image) ) { SetErrorState( IMAGE_OUT_OF_RAM ); delete new_image; return NULL; } for( y=0; y < height; y++ ) { for( x=0; x < width; x++ ) { rgb = GetRGBAt( x, y ); new_image->SetRGBAt( x, y, rgb ); } } return new_image; break; case IMAGE_RGBA: // Convert to RGBA new_image = new ImageClass( width, height, IMAGE_RGBA ); if( !new_image || !(*new_image) ) { SetErrorState( IMAGE_OUT_OF_RAM ); delete new_image; return NULL; } for( y=0; y < height; y++ ) { for( x=0; x < width; x++ ) { rgb = GetRGBAt( x, y ); new_image->SetRGBAt( x, y, rgb ); } } new_image->ClearAlpha(); return new_image; break; case IMAGE_GREY: // Convert to Greyscale new_image = new ImageClass( width, height, IMAGE_GREY ); if( !new_image || !(*new_image) ) { SetErrorState( IMAGE_OUT_OF_RAM ); delete new_image; return NULL; } for( y=0; y < height; y++ ) { for( x=0; x < width; x++ ) { value = GetValueAt( x, y ); new_image->SetValueAt( x, y, value ); } } return new_image; break; case IMAGE_INDEXED: // Convert to Indexed new_image = new ImageClass( width, height, IMAGE_INDEXED, num_reg ); if( !new_image || !(*new_image) ) { SetErrorState( IMAGE_OUT_OF_RAM ); delete new_image; return NULL; } if( pal != NULL ) // Copy the new palette in, if applicable new_image->CopyPaletteFrom( pal ); else if ( type == IMAGE_GREY ) { // Generate a greyscale palette for( int i=0; i < 256; i++ ) { new_image->SetPaletteColor( i, i, i, i ); } } else { // Auto-generate a palette, if needed. new_pal = GeneratePalette( num_reg ); new_image->CopyPaletteFrom( new_pal ); delete new_pal; } for( y=0; y < height; y++ ) { for( x=0; x < width; x++ ) { if( type == IMAGE_GREY ) value = GetValueAt( x, y ); else { rgb = GetRGBAt( x, y ); value = new_image->FindPaletteIndex( rgb, 0, num_registers-1 ); // low/high must be a char, hence the -1. } new_image->SetPaletteIndexAt( x, y, value ); } } return new_image; break; default: return NULL; } }
int cVoronoiMap::GetValueAt(int a_X, int a_Y) { int MinDist1, MinDist2; return GetValueAt(a_X, a_Y, MinDist1, MinDist2); }