// Map the colors of the DIB (using GetNearestPaletteIndex) to a palette //************************************************************************ void CDib::MapToPalette( HPALETTE hpal ) //************************************************************************ { int n, nDibColors; LPBYTE lpBits; LPRGBQUAD lpRgb; BYTE xlat[256]; DWORD SizeImage; BOOL bChanged; if ( !hpal ) return; if ( m_bmiHeader.biBitCount != 8 ) return; if ( GetColorTableType() == DIB_PAL_COLORS ) return; // build a xlat table. from the current DIB colors to the given palette nDibColors = GetNumColors(); lpRgb = GetColors(); bChanged = NO; for ( n=0; n<nDibColors; n++ ) { xlat[n] = (BYTE)GetNearestPaletteIndex( hpal, RGB(lpRgb->rgbRed, lpRgb->rgbGreen, lpRgb->rgbBlue) ); if ( xlat[n] != n ) bChanged = YES; lpRgb++; } if ( !bChanged ) { // Now reset the DIB color table to match the palette SetColorTable( hpal, DIB_RGB_COLORS ); return; } // translate the DIB bits lpBits = (LPBYTE)GetPtr(); SizeImage = GetSizeImage(); switch (m_bmiHeader.biCompression) { case BI_RLE8: xlatRle8(lpBits, SizeImage, xlat); break; case BI_RGB: xlatClut8(lpBits, SizeImage, xlat); break; } // Now reset the DIB color table to match the palette SetColorTable( hpal, DIB_RGB_COLORS ); }
void CDib::CreateDefaultPalette256() { CreateDefaultPalette16(); RGBQUAD rgbColor[256-16] = {0}; LPRGBQUAD pDibQuad = &rgbColor[0]; // Create a color cube 6x6x6 for (int r = 1; r <= 6; r++) { for (int g = 1; g <= 6; g++) { for (int b = 1; b <= 6; b++) { pDibQuad->rgbRed = r * 255 / 7; pDibQuad->rgbGreen = g * 255 / 7; pDibQuad->rgbBlue = b * 255 / 7; pDibQuad++; } } } // Create a grey scale for (int i = 1; i <= 24; i++) { pDibQuad->rgbRed = i * 255 / 25; pDibQuad->rgbGreen = i * 255 / 25; pDibQuad->rgbBlue = i * 255 / 25; pDibQuad++; } SetColorTable(16,256-16, &(rgbColor[0])); }
BOOL CDib::SetPalette( CPalette& palette ) { if( IsIndexed() ) { int iColors = 0; if (!palette.GetObject(sizeof(iColors), &iColors)) { TRACE("Failed to get num palette colors"); return FALSE; } ASSERT(iColors>= 0 && iColors<=256); // iColors = min(iColors, GetColorTableEntries()); PALETTEENTRY pe[256]; palette.GetPaletteEntries(0, iColors, pe); RGBQUAD quad[256] = {0}; for (int i = 0; i < iColors; i++) { quad[i].rgbRed = pe[i].peRed; quad[i].rgbGreen = pe[i].peGreen; quad[i].rgbBlue = pe[i].peBlue; } SetColorTable(0, iColors, &(quad[0])); //update copy of the palette //GetPalette(m_palette); } return TRUE; }
void MainWindow::UpdateImage() { if(!dataloaded) return; int i, j; int pixel; float offset = offsetSpinBox->value(); float cutoff = cutoffSpinBox->value(); image = QImage(datawidth, dataheight, QImage::Format_Indexed8); SetColorTable(); for(i=0; i<datawidth; i++) for(j=0; j<dataheight; j++) { if(referenceComboBox->currentIndex()>0 && refloaded) pixel = (int)((CorrectedArray[i][j]-offset)*255.0/(cutoff-offset)+0.5); else pixel = (int)((DataArray[i][j]-offset)*255.0/(cutoff-offset)+0.5); if(pixel>255) pixel = 255; if(pixel<0) pixel = 0; image.setPixel(i, j, pixel); } pixmap->setPixmap(QPixmap::fromImage(image)); }
CPLErr VRTRasterBand::CopyCommonInfoFrom( GDALRasterBand * poSrcBand ) { SetMetadata( poSrcBand->GetMetadata() ); const char* pszNBits = poSrcBand->GetMetadataItem("NBITS", "IMAGE_STRUCTURE"); SetMetadataItem( "NBITS", pszNBits, "IMAGE_STRUCTURE" ); const char* pszPixelType = poSrcBand->GetMetadataItem("PIXELTYPE", "IMAGE_STRUCTURE"); SetMetadataItem( "PIXELTYPE", pszPixelType, "IMAGE_STRUCTURE" ); SetColorTable( poSrcBand->GetColorTable() ); SetColorInterpretation(poSrcBand->GetColorInterpretation()); if( strlen(poSrcBand->GetDescription()) > 0 ) SetDescription( poSrcBand->GetDescription() ); int bSuccess; double dfNoData; dfNoData = poSrcBand->GetNoDataValue( &bSuccess ); if( bSuccess ) SetNoDataValue( dfNoData ); SetOffset( poSrcBand->GetOffset() ); SetScale( poSrcBand->GetScale() ); SetCategoryNames( poSrcBand->GetCategoryNames() ); if( !EQUAL(poSrcBand->GetUnitType(),"") ) SetUnitType( poSrcBand->GetUnitType() ); return CE_None; }
void CDib::CreateDefaultPalette2() { RGBQUAD rgbColor[2] = {0}; rgbColor[1].rgbRed = rgbColor[1].rgbGreen = rgbColor[1].rgbBlue = 255; SetColorTable(0,2, &(rgbColor[0])); }
void BrightnessCB (Widget w, XtPointer clientData, XtPointer callData) { ImageDisplay *IDdata = (ImageDisplay *)clientData; XmScaleCallbackStruct *call_data = (XmScaleCallbackStruct *) callData; /* read value of scrollbar */ IDdata->value[0] = call_data->value; /* reset color table */ SetColorTable(IDdata); } /* end BrightnessCB */
void CDib::CreateDefaultPalette16() { RGBQUAD rgbColor[16] = {0}; rgbColor[1].rgbRed = 128; rgbColor[2].rgbGreen = 128; rgbColor[3].rgbRed = rgbColor[3].rgbGreen = 128; rgbColor[4].rgbBlue = 128; rgbColor[5].rgbRed = rgbColor[5].rgbBlue = 128; rgbColor[6].rgbGreen = rgbColor[6].rgbBlue = 128; rgbColor[7].rgbRed = rgbColor[7].rgbGreen = rgbColor[7].rgbBlue = 192; rgbColor[8].rgbRed = rgbColor[8].rgbGreen = rgbColor[8].rgbBlue = 128; rgbColor[9].rgbRed = 255; rgbColor[10].rgbGreen = 255; rgbColor[11].rgbRed = rgbColor[11].rgbGreen = 255; rgbColor[12].rgbBlue = 255; rgbColor[13].rgbRed = rgbColor[13].rgbBlue = 255; rgbColor[14].rgbGreen = rgbColor[14].rgbBlue = 255; rgbColor[15].rgbRed = rgbColor[15].rgbGreen = rgbColor[15].rgbBlue = 255; SetColorTable(0,16, &(rgbColor[0])); }
CPLErr VRTRasterBand::CopyCommonInfoFrom( GDALRasterBand * poSrcBand ) { int bSuccess; double dfNoData; SetMetadata( poSrcBand->GetMetadata() ); SetColorTable( poSrcBand->GetColorTable() ); SetColorInterpretation(poSrcBand->GetColorInterpretation()); if( strlen(poSrcBand->GetDescription()) > 0 ) SetDescription( poSrcBand->GetDescription() ); dfNoData = poSrcBand->GetNoDataValue( &bSuccess ); if( bSuccess ) SetNoDataValue( dfNoData ); SetOffset( poSrcBand->GetOffset() ); SetScale( poSrcBand->GetScale() ); SetCategoryNames( poSrcBand->GetCategoryNames() ); if( !EQUAL(poSrcBand->GetUnitType(),"") ) SetUnitType( poSrcBand->GetUnitType() ); return CE_None; }
MainWindow::MainWindow( QWidget * parent) : QMainWindow(parent) { setupUi(this); version = "2015-08-28"; inimage = false; x1drag = false; x2drag = false; y1drag = false; y2drag = false; image = QImage(); pixmap = scene.addPixmap(QPixmap()); pixmap->setZValue(0); QPen pen; pen.setColor(QColor(255,255,0)); pen.setStyle(Qt::DashLine); // limit lines x1line = scene.addLine(QLineF(), pen); x1line->setZValue(1); x2line = scene.addLine(QLineF(), pen); x2line->setZValue(1); y1line = scene.addLine(QLineF(), pen); y1line->setZValue(1); y2line = scene.addLine(QLineF(), pen); y2line->setZValue(1); pen.setColor(QColor(255,0,0)); pen.setStyle(Qt::SolidLine); // projections, beam profile, centroid xprojection = scene.addPath(QPainterPath(), pen); xprojection->setZValue(2); yprojection = scene.addPath(QPainterPath(), pen); yprojection->setZValue(2); ellipse = scene.addEllipse(0,0,0,0, pen); ellipse->setZValue(2); centerAline = scene.addLine(QLineF(), pen); centerAline->setZValue(2); centerBline = scene.addLine(QLineF(), pen); centerBline->setZValue(2); QObject::connect(&scene, SIGNAL(mouseMoved()), this, SLOT(mouseMovedOnScene())); QObject::connect(&scene, SIGNAL(mousePressed()), this, SLOT(mousePressedOnScene())); QObject::connect(&scene, SIGNAL(mouseReleased()), this, SLOT(mouseReleasedOnScene())); QObject::connect(&scene, SIGNAL(mouseLeft()), this, SLOT(mouseLeftScene())); graphicsView->setScene(&scene); graphicsView->setContextMenuPolicy(Qt::CustomContextMenu); X1SpinBox->setRange(0, MAX_HEIGHT-1); X2SpinBox->setRange(0, MAX_HEIGHT-1); Y1SpinBox->setRange(0, MAX_WIDTH-1); Y2SpinBox->setRange(0, MAX_WIDTH-1); scaleLabel->setScaledContents(true); AllocateMemory(); dataloaded = false; refloaded = false; RestoreSession(); LoadRef(reffile); LoadData(datafile); // Scale image scale = QImage(20, 256, QImage::Format_Indexed8); SetColorTable(); for(int i=0; i<20; i++) for(int j=0; j<=255; j++) scale.setPixel(i, j, 255-j); scaleLabel->setPixmap(QPixmap::fromImage(scale)); graphicsView->scale(pow(2,zoom/2), pow(2,zoom/2)); InitializeShortcuts(); UpdateVisibility(); }
void avtPseudocolorPlot::SetAtts(const AttributeGroup *a) { const PseudocolorAttributes *newAtts = (const PseudocolorAttributes *)a; // See if the colors will need to be updated. bool updateColors = (!colorsInitialized) || (atts.GetColorTableName() != newAtts->GetColorTableName()) || (atts.GetInvertColorTable() != newAtts->GetInvertColorTable()) || (atts.GetOpacityType() != newAtts->GetOpacityType()) || (atts.GetOpacityType() == PseudocolorAttributes::Ramp && atts.GetOpacity() != newAtts->GetOpacity()); // See if any attributes that require the plot to be regenerated were // changed and copy the state object. needsRecalculation = atts.ChangesRequireRecalculation(*newAtts); atts = *newAtts; // Update the plot's colors if needed. if(updateColors || atts.GetColorTableName() == "Default") { colorsInitialized = true; SetColorTable(atts.GetColorTableName().c_str()); } else SetOpacityFromAtts(); SetLighting(atts.GetLightingFlag()); SetLegend(atts.GetLegendFlag()); SetScaling(atts.GetScaling(), atts.GetSkewFactor()); SetLimitsMode(atts.GetLimitsMode()); glyphMapper->SetLineWidth(Int2LineWidth(atts.GetLineWidth())); glyphMapper->SetLineStyle(Int2LineStyle(atts.GetLineStyle())); glyphMapper->SetScale(atts.GetPointSize()); // ARS - FIX ME - FIX ME - FIX ME - FIX ME - FIX ME if( atts.GetOpacityType() == PseudocolorAttributes::VariableRange && atts.GetOpacityVariable() != "" && atts.GetOpacityVariable() != "\0") { // glyphMapper->SetVariableOpacity(atts.GetOpacity()); // if( atts.GetOpacityVarMinFlag() ) // glyphMapper->SetVariableMinOpacity(atts.GetOpacityVarMin()); // if( atts.GetOpacityVarMaxFlag() ) // glyphMapper->SetVariableMaxOpacity(atts.GetOpacityVarMax()); if (atts.GetOpacityVariable() == "default") { // if (varname != NULL) // glyphMapper->ScaleOpacityByVar(varname); } else { // glyphMapper->ScaleOpacityByVar(atts.GetOpacityVariable()); } } else { // glyphMapper->OpacityScalingOff(); } // ARS - FIX ME - FIX ME - FIX ME - FIX ME - FIX ME if( //(topoDim == 1 || (topoDim > 1 && atts.GetRenderWireframe())) && atts.GetLineType() == PseudocolorAttributes::Tube && atts.GetTubeRadiusVarEnabled() == true && atts.GetTubeRadiusVar() != "" && atts.GetTubeRadiusVar() != "\0" ) { if (atts.GetTubeRadiusVar() == "default") { // if (varname != NULL) // glyphMapper->ScaleTubesByVar(varname); } else { // glyphMapper->ScaleTubesByVar(atts.GetTubeRadiusVar()); } } else { // glyphMapper->TubeScalingOff(); } if( //(topoDim == 0 || (topoDim > 0 && atts.GetRenderPoints())) && atts.GetPointType() != PseudocolorAttributes::Point && atts.GetPointType() != PseudocolorAttributes::Sphere && atts.GetPointSizeVarEnabled() && atts.GetPointSizeVar() != "" && atts.GetPointSizeVar() != "\0" ) { if (atts.GetPointSizeVar() == "default") { if (varname != NULL) glyphMapper->ScaleByVar(varname); } else { glyphMapper->ScaleByVar(atts.GetPointSizeVar()); } } else { glyphMapper->DataScalingOff(); } if (atts.GetPointType() == PseudocolorAttributes::Box) glyphMapper->SetGlyphType(avtPointGlypher::Box); else if (atts.GetPointType() == PseudocolorAttributes::Axis) glyphMapper->SetGlyphType(avtPointGlypher::Axis); else if (atts.GetPointType() == PseudocolorAttributes::Icosahedron) glyphMapper->SetGlyphType(avtPointGlypher::Icosahedron); else if (atts.GetPointType() == PseudocolorAttributes::Octahedron) glyphMapper->SetGlyphType(avtPointGlypher::Octahedron); else if (atts.GetPointType() == PseudocolorAttributes::Tetrahedron) glyphMapper->SetGlyphType(avtPointGlypher::Tetrahedron); else if (atts.GetPointType() == PseudocolorAttributes::SphereGeometry) glyphMapper->SetGlyphType(avtPointGlypher::SphereGeometry); else if (atts.GetPointType() == PseudocolorAttributes::Point) glyphMapper->SetGlyphType(avtPointGlypher::Point); else if (atts.GetPointType() == PseudocolorAttributes::Sphere) glyphMapper->SetGlyphType(avtPointGlypher::Sphere); SetPointGlyphSize(); if (varname != NULL) { glyphMapper->ColorByScalarOn(std::string(varname)); } }
CPLErr VRTRasterBand::XMLInit( CPLXMLNode * psTree, const char *pszVRTPath ) { /* -------------------------------------------------------------------- */ /* Validate a bit. */ /* -------------------------------------------------------------------- */ if( psTree == NULL || psTree->eType != CXT_Element || !EQUAL(psTree->pszValue,"VRTRasterBand") ) { CPLError( CE_Failure, CPLE_AppDefined, "Invalid node passed to VRTRasterBand::XMLInit()." ); return CE_Failure; } /* -------------------------------------------------------------------- */ /* Set the band if provided as an attribute. */ /* -------------------------------------------------------------------- */ const char* pszBand = CPLGetXMLValue( psTree, "band", NULL); if( pszBand != NULL ) { nBand = atoi(pszBand); } /* -------------------------------------------------------------------- */ /* Set the band if provided as an attribute. */ /* -------------------------------------------------------------------- */ const char *pszDataType = CPLGetXMLValue( psTree, "dataType", NULL); if( pszDataType != NULL ) { eDataType = GDALGetDataTypeByName(pszDataType); } /* -------------------------------------------------------------------- */ /* Apply any band level metadata. */ /* -------------------------------------------------------------------- */ oMDMD.XMLInit( psTree, TRUE ); /* -------------------------------------------------------------------- */ /* Collect various other items of metadata. */ /* -------------------------------------------------------------------- */ SetDescription( CPLGetXMLValue( psTree, "Description", "" ) ); if( CPLGetXMLValue( psTree, "NoDataValue", NULL ) != NULL ) SetNoDataValue( CPLAtofM(CPLGetXMLValue( psTree, "NoDataValue", "0" )) ); if( CPLGetXMLValue( psTree, "HideNoDataValue", NULL ) != NULL ) bHideNoDataValue = CSLTestBoolean( CPLGetXMLValue( psTree, "HideNoDataValue", "0" ) ); SetUnitType( CPLGetXMLValue( psTree, "UnitType", NULL ) ); SetOffset( atof(CPLGetXMLValue( psTree, "Offset", "0.0" )) ); SetScale( atof(CPLGetXMLValue( psTree, "Scale", "1.0" )) ); if( CPLGetXMLValue( psTree, "ColorInterp", NULL ) != NULL ) { const char *pszInterp = CPLGetXMLValue( psTree, "ColorInterp", NULL ); SetColorInterpretation(GDALGetColorInterpretationByName(pszInterp)); } /* -------------------------------------------------------------------- */ /* Category names. */ /* -------------------------------------------------------------------- */ if( CPLGetXMLNode( psTree, "CategoryNames" ) != NULL ) { CPLXMLNode *psEntry; CSLDestroy( papszCategoryNames ); papszCategoryNames = NULL; CPLStringList oCategoryNames; for( psEntry = CPLGetXMLNode( psTree, "CategoryNames" )->psChild; psEntry != NULL; psEntry = psEntry->psNext ) { if( psEntry->eType != CXT_Element || !EQUAL(psEntry->pszValue,"Category") || (psEntry->psChild != NULL && psEntry->psChild->eType != CXT_Text) ) continue; oCategoryNames.AddString( (psEntry->psChild) ? psEntry->psChild->pszValue : ""); } papszCategoryNames = oCategoryNames.StealList(); } /* -------------------------------------------------------------------- */ /* Collect a color table. */ /* -------------------------------------------------------------------- */ if( CPLGetXMLNode( psTree, "ColorTable" ) != NULL ) { CPLXMLNode *psEntry; GDALColorTable oTable; int iEntry = 0; for( psEntry = CPLGetXMLNode( psTree, "ColorTable" )->psChild; psEntry != NULL; psEntry = psEntry->psNext ) { GDALColorEntry sCEntry; sCEntry.c1 = (short) atoi(CPLGetXMLValue( psEntry, "c1", "0" )); sCEntry.c2 = (short) atoi(CPLGetXMLValue( psEntry, "c2", "0" )); sCEntry.c3 = (short) atoi(CPLGetXMLValue( psEntry, "c3", "0" )); sCEntry.c4 = (short) atoi(CPLGetXMLValue( psEntry, "c4", "255" )); oTable.SetColorEntry( iEntry++, &sCEntry ); } SetColorTable( &oTable ); } /* -------------------------------------------------------------------- */ /* Histograms */ /* -------------------------------------------------------------------- */ CPLXMLNode *psHist = CPLGetXMLNode( psTree, "Histograms" ); if( psHist != NULL ) { CPLXMLNode *psNext = psHist->psNext; psHist->psNext = NULL; psSavedHistograms = CPLCloneXMLTree( psHist ); psHist->psNext = psNext; } /* ==================================================================== */ /* Overviews */ /* ==================================================================== */ CPLXMLNode *psNode; for( psNode = psTree->psChild; psNode != NULL; psNode = psNode->psNext ) { if( psNode->eType != CXT_Element || !EQUAL(psNode->pszValue,"Overview") ) continue; /* -------------------------------------------------------------------- */ /* Prepare filename. */ /* -------------------------------------------------------------------- */ char *pszSrcDSName = NULL; CPLXMLNode* psFileNameNode=CPLGetXMLNode(psNode,"SourceFilename"); const char *pszFilename = psFileNameNode ? CPLGetXMLValue(psFileNameNode,NULL, NULL) : NULL; if( pszFilename == NULL ) { CPLError( CE_Warning, CPLE_AppDefined, "Missing <SourceFilename> element in Overview." ); return CE_Failure; } if (EQUALN(pszFilename, "MEM:::", 6) && pszVRTPath != NULL && !CSLTestBoolean(CPLGetConfigOption("VRT_ALLOW_MEM_DRIVER", "NO"))) { CPLError( CE_Failure, CPLE_AppDefined, "<SourceFilename> points to a MEM dataset, which is rather suspect! " "If you know what you are doing, define the VRT_ALLOW_MEM_DRIVER configuration option to YES" ); return CE_Failure; } if( pszVRTPath != NULL && atoi(CPLGetXMLValue( psFileNameNode, "relativetoVRT", "0")) ) { pszSrcDSName = CPLStrdup( CPLProjectRelativeFilename( pszVRTPath, pszFilename ) ); } else pszSrcDSName = CPLStrdup( pszFilename ); /* -------------------------------------------------------------------- */ /* Get the raster band. */ /* -------------------------------------------------------------------- */ int nSrcBand = atoi(CPLGetXMLValue(psNode,"SourceBand","1")); apoOverviews.resize( apoOverviews.size() + 1 ); apoOverviews[apoOverviews.size()-1].osFilename = pszSrcDSName; apoOverviews[apoOverviews.size()-1].nBand = nSrcBand; CPLFree( pszSrcDSName ); } /* ==================================================================== */ /* Mask band (specific to that raster band) */ /* ==================================================================== */ CPLXMLNode* psMaskBandNode = CPLGetXMLNode(psTree, "MaskBand"); if (psMaskBandNode) psNode = psMaskBandNode->psChild; else psNode = NULL; for( ; psNode != NULL; psNode = psNode->psNext ) { if( psNode->eType != CXT_Element || !EQUAL(psNode->pszValue,"VRTRasterBand") ) continue; if( ((VRTDataset*)poDS)->poMaskBand != NULL) { CPLError( CE_Warning, CPLE_AppDefined, "Illegal mask band at raster band level when a dataset mask band already exists." ); break; } const char *pszSubclass = CPLGetXMLValue( psNode, "subclass", "VRTSourcedRasterBand" ); VRTRasterBand *poBand = NULL; if( EQUAL(pszSubclass,"VRTSourcedRasterBand") ) poBand = new VRTSourcedRasterBand( GetDataset(), 0 ); else if( EQUAL(pszSubclass, "VRTDerivedRasterBand") ) poBand = new VRTDerivedRasterBand( GetDataset(), 0 ); else if( EQUAL(pszSubclass, "VRTRawRasterBand") ) poBand = new VRTRawRasterBand( GetDataset(), 0 ); else if( EQUAL(pszSubclass, "VRTWarpedRasterBand") ) poBand = new VRTWarpedRasterBand( GetDataset(), 0 ); else { CPLError( CE_Failure, CPLE_AppDefined, "VRTRasterBand of unrecognised subclass '%s'.", pszSubclass ); break; } if( poBand->XMLInit( psNode, pszVRTPath ) == CE_None ) { SetMaskBand(poBand); } break; } return CE_None; }
void avtStreamlinePlot::SetAtts(const AttributeGroup *a) { renderer->SetAtts(a); needsRecalculation = atts.ChangesRequireRecalculation(*(const StreamlineAttributes*)a); atts = *(const StreamlineAttributes*)a; #ifdef ENGINE // // Set the filter's attributes based on the plot attributes. // switch (atts.GetSourceType()) { case StreamlineAttributes::SpecifiedPoint: streamlineFilter->SetPointSource(atts.GetPointSource()); break; case StreamlineAttributes::SpecifiedPointList: streamlineFilter->SetPointListSource(atts.GetPointList()); break; case StreamlineAttributes::SpecifiedLine: streamlineFilter->SetLineSource(atts.GetLineStart(), atts.GetLineEnd(), atts.GetSampleDensity0(), atts.GetRandomSamples(), atts.GetRandomSeed(), atts.GetNumberOfRandomSamples()); break; case StreamlineAttributes::SpecifiedPlane: streamlineFilter->SetPlaneSource(atts.GetPlaneOrigin(), atts.GetPlaneNormal(), atts.GetPlaneUpAxis(), atts.GetSampleDensity0(), atts.GetSampleDensity1(), atts.GetSampleDistance0(), atts.GetSampleDistance1(), atts.GetFillInterior(), atts.GetRandomSamples(), atts.GetRandomSeed(), atts.GetNumberOfRandomSamples()); break; case StreamlineAttributes::SpecifiedCircle: streamlineFilter->SetCircleSource(atts.GetPlaneOrigin(), atts.GetPlaneNormal(), atts.GetPlaneUpAxis(), atts.GetRadius(), atts.GetSampleDensity0(), atts.GetSampleDensity1(), atts.GetFillInterior(), atts.GetRandomSamples(), atts.GetRandomSeed(), atts.GetNumberOfRandomSamples()); break; case StreamlineAttributes::SpecifiedSphere: streamlineFilter->SetSphereSource(atts.GetSphereOrigin(), atts.GetRadius(), atts.GetSampleDensity0(), atts.GetSampleDensity1(), atts.GetSampleDensity2(), atts.GetFillInterior(), atts.GetRandomSamples(), atts.GetRandomSeed(), atts.GetNumberOfRandomSamples()); break; case StreamlineAttributes::SpecifiedBox: streamlineFilter->SetBoxSource(atts.GetBoxExtents(),atts.GetUseWholeBox(), atts.GetSampleDensity0(), atts.GetSampleDensity1(), atts.GetSampleDensity2(), atts.GetFillInterior(), atts.GetRandomSamples(), atts.GetRandomSeed(), atts.GetNumberOfRandomSamples()); break; case StreamlineAttributes::Selection: streamlineFilter->SetSelectionSource(atts.GetSelection(), atts.GetSampleDensity0(), atts.GetRandomSamples(), atts.GetRandomSeed(), atts.GetNumberOfRandomSamples()); break; } int CMFEType = (atts.GetPathlinesCMFE() == StreamlineAttributes::CONN_CMFE ? PICS_CONN_CMFE : PICS_POS_CMFE); streamlineFilter->SetPathlines(atts.GetPathlines(), atts.GetPathlinesOverrideStartingTimeFlag(), atts.GetPathlinesOverrideStartingTime(), atts.GetPathlinesPeriod(), CMFEType); streamlineFilter->SetIntegrationDirection(atts.GetIntegrationDirection()); streamlineFilter->SetFieldType(atts.GetFieldType()); streamlineFilter->SetFieldConstant(atts.GetFieldConstant()); streamlineFilter->SetVelocitySource(atts.GetVelocitySource()); streamlineFilter->SetIntegrationType(atts.GetIntegrationType()); streamlineFilter->SetParallelizationAlgorithm(atts.GetParallelizationAlgorithmType(), atts.GetMaxProcessCount(), atts.GetMaxDomainCacheSize(), atts.GetWorkGroupSize()); if (atts.GetIntegrationType() == StreamlineAttributes::DormandPrince) { // For DoPri, the max time step is sent in to the PICS filter as the max step length. double step = atts.GetMaxTimeStep(); if (! atts.GetLimitMaximumTimestep()) step = 0; streamlineFilter->SetMaxStepLength(step); } else streamlineFilter->SetMaxStepLength(atts.GetMaxStepLength()); double absTol = 0.; bool doBBox = (atts.GetAbsTolSizeType() == StreamlineAttributes::FractionOfBBox); if (doBBox) absTol = atts.GetAbsTolBBox(); else absTol = atts.GetAbsTolAbsolute(); streamlineFilter->SetTolerances(atts.GetRelTol(), absTol, doBBox); streamlineFilter->SetTermination(atts.GetMaxSteps(), atts.GetTerminateByDistance(), atts.GetTermDistance(), atts.GetTerminateByTime(), atts.GetTermTime()); streamlineFilter->SetDisplayMethod(atts.GetDisplayMethod()); streamlineFilter->IssueWarningForMaxStepsTermination(atts.GetIssueTerminationWarnings()); streamlineFilter->IssueWarningForStiffness(atts.GetIssueStiffnessWarnings()); streamlineFilter->IssueWarningForCriticalPoints(atts.GetIssueCriticalPointsWarnings(), atts.GetCriticalPointThreshold()); streamlineFilter->SetColoringMethod(int(atts.GetColoringMethod()), atts.GetColoringVariable()); if (atts.GetColoringMethod() == StreamlineAttributes::ColorByCorrelationDistance) { bool doBBox = (atts.GetCorrelationDistanceMinDistType() == StreamlineAttributes::FractionOfBBox); double minDist = (doBBox ? atts.GetCorrelationDistanceMinDistBBox() : atts.GetCorrelationDistanceMinDistAbsolute()); double angTol = atts.GetCorrelationDistanceAngTol(); streamlineFilter->SetColorByCorrelationDistanceTol(angTol, minDist, doBBox); } streamlineFilter->SetVelocitiesForLighting(atts.GetLightingFlag()); streamlineFilter->SetReferenceTypeForDisplay(atts.GetReferenceTypeForDisplay()); streamlineFilter->SetCoordinateSystem(atts.GetCoordinateSystem()); streamlineFilter->SetPhiScaling(atts.GetPhiScalingFlag(), atts.GetPhiScaling()); if (atts.GetOpacityType() == StreamlineAttributes::VariableRange) streamlineFilter->SetOpacityVariable(atts.GetOpacityVariable()); if (atts.GetVaryTubeRadius() != StreamlineAttributes::None && !atts.GetVaryTubeRadiusVariable().empty()) streamlineFilter->SetScaleTubeRadiusVariable(atts.GetVaryTubeRadiusVariable()); #endif UpdateMapperAndLegend(); SetColorTable(atts.GetColorTableName().c_str()); if (atts.GetLegendFlag()) { varLegend->LegendOn(); varLegend->SetLookupTable(avtLUT->GetLookupTable()); } else varLegend->LegendOff(); if (atts.GetColoringMethod() == StreamlineAttributes::Solid) avtLUT->SetLUTColors(atts.GetSingleColor().GetColor(), 1); else varLegend->SetLookupTable(avtLUT->GetLookupTable()); SetLighting(atts.GetLightingFlag()); }
HRESULT BitmapUtil::MyCreateFromGdiplusBitmap( Gdiplus::Bitmap& bmSrc ) throw() { Gdiplus::PixelFormat eSrcPixelFormat = bmSrc.GetPixelFormat(); UINT nBPP = 32; DWORD dwFlags = 0; Gdiplus::PixelFormat eDestPixelFormat = PixelFormat32bppRGB; if( eSrcPixelFormat&PixelFormatGDI ) { nBPP = Gdiplus::GetPixelFormatSize( eSrcPixelFormat ); eDestPixelFormat = eSrcPixelFormat; } if( Gdiplus::IsAlphaPixelFormat( eSrcPixelFormat ) ) { nBPP = 32; dwFlags |= createAlphaChannel; eDestPixelFormat = PixelFormat32bppARGB; } BOOL bSuccess = Create( bmSrc.GetWidth(), bmSrc.GetHeight(), nBPP, dwFlags ); if( !bSuccess ) { return( E_FAIL ); } Gdiplus::ColorPalette* pPalette = NULL; if( Gdiplus::IsIndexedPixelFormat( eSrcPixelFormat ) ) { UINT nPaletteSize = bmSrc.GetPaletteSize(); pPalette = static_cast< Gdiplus::ColorPalette* >( _alloca( nPaletteSize ) ); bmSrc.GetPalette( pPalette, nPaletteSize ); RGBQUAD argbPalette[256]; ATLASSERT( (pPalette->Count > 0) && (pPalette->Count <= 256) ); for( UINT iColor = 0; iColor < pPalette->Count; iColor++ ) { Gdiplus::ARGB color = pPalette->Entries[iColor]; argbPalette[iColor].rgbRed = BYTE( color>>RED_SHIFT ); argbPalette[iColor].rgbGreen = BYTE( color>>GREEN_SHIFT ); argbPalette[iColor].rgbBlue = BYTE( color>>BLUE_SHIFT ); argbPalette[iColor].rgbReserved = 0; } SetColorTable( 0, pPalette->Count, argbPalette ); } if( eDestPixelFormat == eSrcPixelFormat ) { // The pixel formats are identical, so just memcpy the rows. Gdiplus::BitmapData data; Gdiplus::Rect rect( 0, 0, GetWidth(), GetHeight() ); bmSrc.LockBits( &rect, Gdiplus::ImageLockModeRead, eSrcPixelFormat, &data ); UINT nBytesPerRow = AtlAlignUp( nBPP*GetWidth(), 8 )/8; BYTE* pbDestRow = static_cast< BYTE* >( GetBits() ); BYTE* pbSrcRow = static_cast< BYTE* >( data.Scan0 ); for( int y = 0; y < GetHeight(); y++ ) { memcpy( pbDestRow, pbSrcRow, nBytesPerRow ); pbDestRow += GetPitch(); pbSrcRow += data.Stride; } bmSrc.UnlockBits( &data ); } else { // Let GDI+ work its magic Gdiplus::Bitmap bmDest( GetWidth(), GetHeight(), GetPitch(), eDestPixelFormat, static_cast< BYTE* >( GetBits() ) ); Gdiplus::Graphics gDest( &bmDest ); gDest.DrawImage( &bmSrc, 0, 0 ); } return( S_OK ); }