static bool read_jpeg_image(QImage *outImage, QSize scaledSize, QRect scaledClipRect, QRect clipRect, volatile int inQuality, j_decompress_ptr info, struct my_error_mgr* err ) { if (!setjmp(err->setjmp_buffer)) { // -1 means default quality. int quality = inQuality; if (quality < 0) quality = 75; // If possible, merge the scaledClipRect into either scaledSize // or clipRect to avoid doing a separate scaled clipping pass. // Best results are achieved by clipping before scaling, not after. if (!scaledClipRect.isEmpty()) { if (scaledSize.isEmpty() && clipRect.isEmpty()) { // No clipping or scaling before final clip. clipRect = scaledClipRect; scaledClipRect = QRect(); } else if (scaledSize.isEmpty()) { // Clipping, but no scaling: combine the clip regions. scaledClipRect.translate(clipRect.topLeft()); clipRect = scaledClipRect.intersected(clipRect); scaledClipRect = QRect(); } else if (clipRect.isEmpty()) { // No clipping, but scaling: if we can map back to an // integer pixel boundary, then clip before scaling. if ((info->image_width % scaledSize.width()) == 0 && (info->image_height % scaledSize.height()) == 0) { int x = scaledClipRect.x() * info->image_width / scaledSize.width(); int y = scaledClipRect.y() * info->image_height / scaledSize.height(); int width = (scaledClipRect.right() + 1) * info->image_width / scaledSize.width() - x; int height = (scaledClipRect.bottom() + 1) * info->image_height / scaledSize.height() - y; clipRect = QRect(x, y, width, height); scaledSize = scaledClipRect.size(); scaledClipRect = QRect(); } } else { // Clipping and scaling: too difficult to figure out, // and not a likely use case, so do it the long way. } } // Determine the scale factor to pass to libjpeg for quick downscaling. if (!scaledSize.isEmpty() && info->image_width && info->image_height) { if (clipRect.isEmpty()) { double f = qMin(double(info->image_width) / scaledSize.width(), double(info->image_height) / scaledSize.height()); // libjpeg supports M/8 scaling with M=[1,16]. All downscaling factors // are a speed improvement, but upscaling during decode is slower. info->scale_num = qBound(1, qCeil(8/f), 8); info->scale_denom = 8; } else { info->scale_denom = qMin(clipRect.width() / scaledSize.width(), clipRect.height() / scaledSize.height()); // Only scale by powers of two when clipping so we can // keep the exact pixel boundaries if (info->scale_denom < 2) info->scale_denom = 1; else if (info->scale_denom < 4) info->scale_denom = 2; else if (info->scale_denom < 8) info->scale_denom = 4; else info->scale_denom = 8; info->scale_num = 1; // Correct the scale factor so that we clip accurately. // It is recommended that the clip rectangle be aligned // on an 8-pixel boundary for best performance. while (info->scale_denom > 1 && ((clipRect.x() % info->scale_denom) != 0 || (clipRect.y() % info->scale_denom) != 0 || (clipRect.width() % info->scale_denom) != 0 || (clipRect.height() % info->scale_denom) != 0)) { info->scale_denom /= 2; } } } // If high quality not required, use fast decompression if( quality < HIGH_QUALITY_THRESHOLD ) { info->dct_method = JDCT_IFAST; info->do_fancy_upsampling = FALSE; } (void) jpeg_calc_output_dimensions(info); // Determine the clip region to extract. QRect imageRect(0, 0, info->output_width, info->output_height); QRect clip; if (clipRect.isEmpty()) { clip = imageRect; } else if (info->scale_denom == info->scale_num) { clip = clipRect.intersected(imageRect); } else { // The scale factor was corrected above to ensure that // we don't miss pixels when we scale the clip rectangle. clip = QRect(clipRect.x() / int(info->scale_denom), clipRect.y() / int(info->scale_denom), clipRect.width() / int(info->scale_denom), clipRect.height() / int(info->scale_denom)); clip = clip.intersected(imageRect); } // Allocate memory for the clipped QImage. if (!ensureValidImage(outImage, info, clip.size())) longjmp(err->setjmp_buffer, 1); // Avoid memcpy() overhead if grayscale with no clipping. bool quickGray = (info->output_components == 1 && clip == imageRect); if (!quickGray) { // Ask the jpeg library to allocate a temporary row. // The library will automatically delete it for us later. // The libjpeg docs say we should do this before calling // jpeg_start_decompress(). We can't use "new" here // because we are inside the setjmp() block and an error // in the jpeg input stream would cause a memory leak. JSAMPARRAY rows = (info->mem->alloc_sarray) ((j_common_ptr)info, JPOOL_IMAGE, info->output_width * info->output_components, 1); (void) jpeg_start_decompress(info); while (info->output_scanline < info->output_height) { int y = int(info->output_scanline) - clip.y(); if (y >= clip.height()) break; // We've read the entire clip region, so abort. (void) jpeg_read_scanlines(info, rows, 1); if (y < 0) continue; // Haven't reached the starting line yet. if (info->output_components == 3) { uchar *in = rows[0] + clip.x() * 3; QRgb *out = (QRgb*)outImage->scanLine(y); rgb888ToRgb32ConverterPtr(out, in, clip.width()); } else if (info->out_color_space == JCS_CMYK) { // Convert CMYK->RGB. uchar *in = rows[0] + clip.x() * 4; QRgb *out = (QRgb*)outImage->scanLine(y); for (int i = 0; i < clip.width(); ++i) { int k = in[3]; *out++ = qRgb(k * in[0] / 255, k * in[1] / 255, k * in[2] / 255); in += 4; } } else if (info->output_components == 1) { // Grayscale. memcpy(outImage->scanLine(y), rows[0] + clip.x(), clip.width()); } } } else { // Load unclipped grayscale data directly into the QImage. (void) jpeg_start_decompress(info); while (info->output_scanline < info->output_height) { uchar *row = outImage->scanLine(info->output_scanline); (void) jpeg_read_scanlines(info, &row, 1); } } if (info->output_scanline == info->output_height) (void) jpeg_finish_decompress(info); if (info->density_unit == 1) { outImage->setDotsPerMeterX(int(100. * info->X_density / 2.54)); outImage->setDotsPerMeterY(int(100. * info->Y_density / 2.54)); } else if (info->density_unit == 2) { outImage->setDotsPerMeterX(int(100. * info->X_density)); outImage->setDotsPerMeterY(int(100. * info->Y_density)); } if (scaledSize.isValid() && scaledSize != clip.size()) { *outImage = outImage->scaled(scaledSize, Qt::IgnoreAspectRatio, quality >= HIGH_QUALITY_THRESHOLD ? Qt::SmoothTransformation : Qt::FastTransformation); } if (!scaledClipRect.isEmpty()) *outImage = outImage->copy(scaledClipRect); return !outImage->isNull(); } else return false; }
nsresult imgFrame::InitWithDrawable(gfxDrawable* aDrawable, const nsIntSize& aSize, const SurfaceFormat aFormat, GraphicsFilter aFilter, uint32_t aImageFlags) { // Assert for properties that should be verified by decoders, // warn for properties related to bad content. if (!AllowedImageSize(aSize.width, aSize.height)) { NS_WARNING("Should have legal image size"); mAborted = true; return NS_ERROR_FAILURE; } mImageSize = aSize; mOffset.MoveTo(0, 0); mSize.SizeTo(aSize.width, aSize.height); mFormat = aFormat; mPaletteDepth = 0; RefPtr<DrawTarget> target; bool canUseDataSurface = gfxPlatform::GetPlatform()->CanRenderContentToDataSurface(); if (canUseDataSurface) { // It's safe to use data surfaces for content on this platform, so we can // get away with using volatile buffers. MOZ_ASSERT(!mImageSurface, "Called imgFrame::InitWithDrawable() twice?"); mVBuf = AllocateBufferForImage(mSize, mFormat); if (!mVBuf) { mAborted = true; return NS_ERROR_OUT_OF_MEMORY; } int32_t stride = VolatileSurfaceStride(mSize, mFormat); VolatileBufferPtr<uint8_t> ptr(mVBuf); if (!ptr) { mAborted = true; return NS_ERROR_OUT_OF_MEMORY; } if (mVBuf->OnHeap()) { memset(ptr, 0, stride * mSize.height); } mImageSurface = CreateLockedSurface(mVBuf, mSize, mFormat); target = gfxPlatform::GetPlatform()-> CreateDrawTargetForData(ptr, mSize, stride, mFormat); } else { // We can't use data surfaces for content, so we'll create an offscreen // surface instead. This means if someone later calls RawAccessRef(), we // may have to do an expensive readback, but we warned callers about that in // the documentation for this method. MOZ_ASSERT(!mOptSurface, "Called imgFrame::InitWithDrawable() twice?"); target = gfxPlatform::GetPlatform()-> CreateOffscreenContentDrawTarget(mSize, mFormat); } if (!target) { mAborted = true; return NS_ERROR_OUT_OF_MEMORY; } // Draw using the drawable the caller provided. nsIntRect imageRect(0, 0, mSize.width, mSize.height); nsRefPtr<gfxContext> ctx = new gfxContext(target); gfxUtils::DrawPixelSnapped(ctx, aDrawable, mSize, ImageRegion::Create(imageRect), mFormat, aFilter, aImageFlags); if (canUseDataSurface && !mImageSurface) { NS_WARNING("Failed to create VolatileDataSourceSurface"); mAborted = true; return NS_ERROR_OUT_OF_MEMORY; } if (!canUseDataSurface) { // We used an offscreen surface, which is an "optimized" surface from // imgFrame's perspective. mOptSurface = target->Snapshot(); } // If we reach this point, we should regard ourselves as complete. mDecoded = GetRect(); MOZ_ASSERT(IsImageComplete()); return NS_OK; }
void KisTransformMaskTest::testWeirdFullUpdates() { //TestUtil::ExternalImageChecker chk("mask_with_offset", "transform_mask_updates"); QRect imageRect(0,0,512,512); QRect fillRect(10, 10, 236, 236); TestUtil::MaskParent p(imageRect); p.layer->paintDevice()->fill(fillRect, KoColor(Qt::red, p.layer->colorSpace())); KisPaintLayerSP player1 = new KisPaintLayer(p.image, "pl1", OPACITY_OPAQUE_U8, p.image->colorSpace()); player1->paintDevice()->fill(fillRect, KoColor(Qt::red, p.layer->colorSpace())); p.image->addNode(player1, p.image->root()); KisTransformMaskSP mask1 = new KisTransformMask(); mask1->setName("mask1"); QTransform transform1 = QTransform::fromTranslate(256, 0); mask1->setTransformParams(KisTransformMaskParamsInterfaceSP( new KisDumbTransformMaskParams(transform1))); p.image->addNode(mask1, player1); KisPaintLayerSP player2 = new KisPaintLayer(p.image, "pl2", OPACITY_OPAQUE_U8, p.image->colorSpace()); player2->paintDevice()->fill(fillRect, KoColor(Qt::red, p.layer->colorSpace())); p.image->addNode(player2, p.image->root()); KisTransformMaskSP mask2 = new KisTransformMask(); mask2->setName("mask2"); QTransform transform2 = QTransform::fromTranslate(0, 256); mask2->setTransformParams(KisTransformMaskParamsInterfaceSP( new KisDumbTransformMaskParams(transform2))); p.image->addNode(mask2, player2); KisPaintLayerSP player3 = new KisPaintLayer(p.image, "pl3", OPACITY_OPAQUE_U8, p.image->colorSpace()); player3->paintDevice()->fill(fillRect, KoColor(Qt::red, p.layer->colorSpace())); p.image->addNode(player3, p.image->root()); KisTransformMaskSP mask3 = new KisTransformMask(); mask3->setName("mask3"); QTransform transform3 = QTransform::fromTranslate(256, 256); mask3->setTransformParams(KisTransformMaskParamsInterfaceSP( new KisDumbTransformMaskParams(transform3))); p.image->addNode(mask3, player3); //p.image->initialRefreshGraph(); p.image->refreshGraphAsync(0, QRect(0,0,256,256), QRect()); p.image->waitForDone(); QVERIFY(player1->projection()->extent().isEmpty()); QVERIFY(player1->projection()->exactBounds().isEmpty()); QVERIFY(player2->projection()->extent().isEmpty()); QVERIFY(player2->projection()->exactBounds().isEmpty()); QVERIFY(player3->projection()->extent().isEmpty()); QVERIFY(player3->projection()->exactBounds().isEmpty()); QCOMPARE(p.image->projection()->exactBounds(), QRect(QRect(10,10,236,236))); p.image->refreshGraphAsync(0, QRect(0,256,256,256), QRect()); p.image->waitForDone(); QVERIFY(player1->projection()->extent().isEmpty()); QVERIFY(player1->projection()->exactBounds().isEmpty()); QVERIFY(!player2->projection()->extent().isEmpty()); QVERIFY(!player2->projection()->exactBounds().isEmpty()); QVERIFY(player3->projection()->extent().isEmpty()); QVERIFY(player3->projection()->exactBounds().isEmpty()); QCOMPARE(p.image->projection()->exactBounds(), QRect(QRect(10,10,236,492))); p.image->refreshGraphAsync(0, QRect(256,0,256,256), QRect()); p.image->waitForDone(); QVERIFY(!player1->projection()->extent().isEmpty()); QVERIFY(!player1->projection()->exactBounds().isEmpty()); QVERIFY(!player2->projection()->extent().isEmpty()); QVERIFY(!player2->projection()->exactBounds().isEmpty()); QVERIFY(player3->projection()->extent().isEmpty()); QVERIFY(player3->projection()->exactBounds().isEmpty()); QCOMPARE(p.image->projection()->exactBounds(), QRect(QRect(10,10,492,492))); QVERIFY((p.image->projection()->region() & QRect(256,256,256,256)).isEmpty()); p.image->refreshGraphAsync(0, QRect(256,256,256,256), QRect()); p.image->waitForDone(); QVERIFY(!player1->projection()->extent().isEmpty()); QVERIFY(!player1->projection()->exactBounds().isEmpty()); QVERIFY(!player2->projection()->extent().isEmpty()); QVERIFY(!player2->projection()->exactBounds().isEmpty()); QVERIFY(!player3->projection()->extent().isEmpty()); QVERIFY(!player3->projection()->exactBounds().isEmpty()); QCOMPARE(p.image->projection()->exactBounds(), QRect(QRect(10,10,492,492))); QVERIFY(!(p.image->projection()->region() & QRect(256,256,256,256)).isEmpty()); p.image->waitForDone(); KIS_DUMP_DEVICE_2(p.image->projection(), imageRect, "image_proj", "dd"); }
std::size_t DefaultBitImageCommands::printImage(const ofPixels_<unsigned char>& pixels, ofAlignHorz alignHorz, float ditherThreshold, float ditherQuantWeight, BaseCodes::PrintResolution printResolution, int printHeadWidth, int printHeadHeight) { int numVerticalDots = 0; int maxHorizontalDots = 0; int verticalScale = 1; switch(printResolution) { case BaseCodes::RESOLUTION_8_DOTS_SINGLE_DENSITY: maxHorizontalDots = printHeadWidth / 2; numVerticalDots = 8; break; case BaseCodes::RESOLUTION_8_DOTS_DOUBLE_DENSITY: maxHorizontalDots = printHeadWidth; numVerticalDots = 8; break; case BaseCodes::RESOLUTION_24_DOTS_SINGLE_DENSITY: maxHorizontalDots = printHeadWidth / 2; numVerticalDots = 24; break; case BaseCodes::RESOLUTION_24_DOTS_DOUBLE_DENSITY: maxHorizontalDots = printHeadWidth; numVerticalDots = 24; break; } std::size_t totalBytesWritten = 0; ofRectangle imageRect(0,0,pixels.getWidth(),pixels.getHeight()); ofRectangle rectangle(0,0,maxHorizontalDots,pixels.getHeight()); imageRect.scaleTo(rectangle, OF_ASPECT_RATIO_KEEP, alignHorz, OF_ALIGN_VERT_TOP, alignHorz, OF_ALIGN_VERT_TOP); int width = rectangle.getWidth(); int height = imageRect.getHeight(); // ensure vertical res if(height != numVerticalDots) { int remainder = height % numVerticalDots; if (remainder != 0) { height = height + numVerticalDots - remainder; } } ofPixels pix = pixels; // get a copy ofPixels toPrint; toPrint.allocate(width, height, pix.getNumChannels()); toPrint.setColor(ofColor(255)); pix.resize(imageRect.getWidth(), imageRect.getHeight()); pix.pasteInto(toPrint,imageRect.getX(),imageRect.getY()); toPrint = ImageUtils::dither(toPrint,ditherThreshold,ditherQuantWeight); cout << pix.getWidth() << " / " << pix.getHeight() << endl; ofPixels bandBuffer; bandBuffer.allocate(toPrint.getWidth(), numVerticalDots, toPrint.getNumChannels()); // go into page mode totalBytesWritten += writeByte(BaseCodes::ESC); totalBytesWritten += writeByte('L'); // set the print area / origin totalBytesWritten += setPageModePrintArea(0,0,toPrint.getWidth(),toPrint.getHeight() * 2); // TODO 2 * works for double vert density for(int y = 0; y < height; y += numVerticalDots) { // set the vertical displacement const uint8_t command[3] = { BaseCodes::ESC, '3', numVerticalDots * 2 }; // TODO 2 * works for double vert density totalBytesWritten += writeBytes(command, 3); bandBuffer.clear(); toPrint.cropTo(bandBuffer,0,y,width,numVerticalDots); totalBytesWritten += selectBitImageMode(bandBuffer, printResolution); totalBytesWritten += writeByte(BaseCodes::LF); // feed a line // set vertical displacement back to normal const uint8_t command0[2] = { BaseCodes::ESC, '2' }; totalBytesWritten += writeBytes(command0, 2); } // totalBytesWritten += writeByte(BaseCodes::LF); // feed a line totalBytesWritten += writeByte(BaseCodes::FF); return totalBytesWritten; }
void KisSimpleUpdateQueueTest::testJobProcessing() { KisTestableUpdaterContext context(2); QRect imageRect(0,0,200,200); const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8(); KisImageSP image = new KisImage(0, imageRect.width(), imageRect.height(), cs, "merge test"); KisPaintLayerSP paintLayer = new KisPaintLayer(image, "test", OPACITY_OPAQUE_U8); image->lock(); image->addNode(paintLayer); image->unlock(); QRect dirtyRect1(0,0,50,100); QRect dirtyRect2(0,0,100,100); QRect dirtyRect3(50,0,50,100); QRect dirtyRect4(150,150,50,50); QVector<KisUpdateJobItem*> jobs; KisWalkersList walkersList; /** * Process the queue and look what has been added into * the updater context */ KisTestableSimpleUpdateQueue queue; queue.addJob(paintLayer, dirtyRect1, imageRect); queue.addJob(paintLayer, dirtyRect2, imageRect); queue.addJob(paintLayer, dirtyRect3, imageRect); queue.addJob(paintLayer, dirtyRect4, imageRect); queue.processQueue(context); jobs = context.getJobs(); QVERIFY(checkWalker(jobs[0]->walker(), dirtyRect2)); QVERIFY(checkWalker(jobs[1]->walker(), dirtyRect4)); QCOMPARE(jobs.size(), 2); walkersList = queue.getWalkersList(); QCOMPARE(walkersList.size(), 0); /** * Test blocking the process */ context.clear(); queue.blockProcessing(context); queue.addJob(paintLayer, dirtyRect1, imageRect); queue.addJob(paintLayer, dirtyRect2, imageRect); queue.addJob(paintLayer, dirtyRect3, imageRect); queue.addJob(paintLayer, dirtyRect4, imageRect); jobs = context.getJobs(); QCOMPARE(jobs[0]->walker(), KisBaseRectsWalkerSP(0)); QCOMPARE(jobs[1]->walker(), KisBaseRectsWalkerSP(0)); queue.startProcessing(context); jobs = context.getJobs(); QVERIFY(checkWalker(jobs[0]->walker(), dirtyRect2)); QVERIFY(checkWalker(jobs[1]->walker(), dirtyRect4)); }
/// Draw the item bool InstanceVisual::Draw(wxDC& dc, InstanceCtrl* ctrl, const wxRect& rect, int style) { wxColour backgroundColor = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); wxColour textColor = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); wxColour highlightTextColor = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT); wxColour focus_color = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); wxColour focussedSelection = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); wxRect imageRect(rect.x + (rect.width - 32) / 2, rect.y, 32, 32); if (style & wxINST_SELECTED) { wxBrush brush(focus_color); wxPen pen(focus_color); dc.SetBrush(brush); dc.SetPen(pen); } else { wxBrush brush(backgroundColor); wxPen pen(backgroundColor); dc.SetBrush(brush); dc.SetPen(pen); } // Draw the label wxString name = m_inst->GetName(); if (!name.IsEmpty()) { int margin = ctrl->GetItemMargin(); wxRect textRect; textRect.x = rect.x + margin; textRect.y = rect.y + imageRect.height + 2 * margin; textRect.width = rect.width - 2 * margin; dc.SetFont(ctrl->GetFont()); if (style & wxINST_SELECTED) dc.SetTextForeground(highlightTextColor); else dc.SetTextForeground(textColor); dc.SetBackgroundMode(wxTRANSPARENT); int yoffset = 0; wxSize textsize = dc.GetMultiLineTextExtent(name_wrapped); textRect.height = textsize.GetHeight(); if (style & wxINST_SELECTED) { wxRect hiRect; hiRect.x = rect.x + (rect.width - textsize.x) / 2 - margin; hiRect.y = textRect.y - margin; hiRect.SetSize(textsize + wxSize(2 * margin, 2 * margin)); dc.DrawRectangle(hiRect); } dc.DrawLabel(name_wrapped, textRect, wxALIGN_TOP | wxALIGN_CENTER_HORIZONTAL); } // Draw the icon auto list = InstIconList::Instance(); wxImage icon; if (style & wxINST_SELECTED) icon = list->getHLImageForKey(m_inst->GetIconKey()); else icon = list->getImageForKey(m_inst->GetIconKey()); wxBitmap bmap = wxBitmap(icon); int x = imageRect.x + (imageRect.width - bmap.GetWidth()) / 2; int y = imageRect.y + (imageRect.height - bmap.GetHeight()) / 2; dc.DrawBitmap(bmap , x, y, true); return true; }
void FlatButton::DrawItem(LPDRAWITEMSTRUCT dis) { CDC* dcPaint = CDC::FromHandle(dis->hDC); CRect rectPaint(dis->rcItem); bool disabled = (dis->itemState & ODS_DISABLED) != 0; // Create a bitmap to paint into CDC dc; dc.CreateCompatibleDC(dcPaint); CRect rect(0,0,rectPaint.Width(),rectPaint.Height()); CDibSection bitmap; if (bitmap.CreateBitmap(dc.GetSafeHdc(),rect.Width(),rect.Height()) == FALSE) return; CBitmap* oldBitmap = CDibSection::SelectDibSection(dc,&bitmap); // Draw the background if (dis->itemState & ODS_SELECTED) { // Get the bitmap to indicate a selected button CBitmap selectBitmap; selectBitmap.LoadBitmap(IDR_FLAT_SELECT); CDC selectDC; selectDC.CreateCompatibleDC(&dc); CBitmap* oldBitmap = selectDC.SelectObject(&selectBitmap); // Get the bitmap's dimensions BITMAP bitmapInfo; selectBitmap.GetBitmap(&bitmapInfo); // Stretch the bitmap into the selected item's background dc.StretchBlt(0,0,rect.Width(),rect.Height(), &selectDC,0,0,bitmapInfo.bmWidth,bitmapInfo.bmHeight,SRCCOPY); selectDC.SelectObject(oldBitmap); } else dc.FillSolidRect(rect,::GetSysColor(COLOR_BTNFACE)); // Get the button's text CString text; GetWindowText(text); // Draw the contents of the button if (text == "?<") { CRect imageRect(rect); if (imageRect.Width() > imageRect.Height()) imageRect.DeflateRect((imageRect.Width() - imageRect.Height())/2,0); int gap = imageRect.Height()/6; imageRect.DeflateRect(gap,gap); CDibSection* dib = GetImage("Arrow-left",imageRect.Size(),disabled); bitmap.AlphaBlend(dib,gap,gap,FALSE); } else if (text == "?>") { CRect imageRect(rect); if (imageRect.Width() > imageRect.Height()) imageRect.DeflateRect((imageRect.Width() - imageRect.Height())/2,0); int gap = imageRect.Height()/6; imageRect.DeflateRect(gap,gap); CDibSection* dib = GetImage("Arrow-right",imageRect.Size(),disabled); bitmap.AlphaBlend(dib,gap,gap,FALSE); } // Draw the separator CPen shadowPen(PS_SOLID,0,::GetSysColor(COLOR_BTNSHADOW)); dc.SelectObject(shadowPen); int gap = rect.Height()/6; dc.MoveTo(rect.right-1,gap); dc.LineTo(rect.right-1,rect.bottom-gap); // Draw the control from the bitmap dcPaint->BitBlt(rectPaint.left,rectPaint.top,rectPaint.Width(),rectPaint.Height(),&dc,0,0,SRCCOPY); dc.SelectObject(oldBitmap); }
void GAoiSelector::on_FullFrameButton_clicked() { QRectF imageRect(QPoint(0, 0), m_KnownFullImageSize); InitAoiSelectorItems(imageRect); }
bool ossimH5GridModel::setGridNodes( H5::DataSet* latDataSet, H5::DataSet* lonDataSet, const ossimIrect& validRect ) { bool status = false; if ( latDataSet && lonDataSet ) { m_crossesDateline = ossim_hdf5::crossesDateline( *lonDataSet, validRect ); if ( m_crossesDateline ) { theLonGrid.setDomainType(ossimDblGrid::WRAP_360); } else { theLonGrid.setDomainType(ossimDblGrid::WRAP_180); } // Get dataspace of the dataset. H5::DataSpace latDataSpace = latDataSet->getSpace(); H5::DataSpace lonDataSpace = lonDataSet->getSpace(); const ossim_int32 LAT_DIM_COUNT = latDataSpace.getSimpleExtentNdims(); const ossim_int32 LON_DIM_COUNT = lonDataSpace.getSimpleExtentNdims(); // Number of dimensions of the input dataspace: if ( ( LAT_DIM_COUNT == 2 ) && ( LON_DIM_COUNT == 2 ) ) { const ossim_uint32 ROWS = validRect.height(); const ossim_uint32 COLS = validRect.width(); const ossim_uint32 GRID_SIZE = 4; // Only grab every 4th value. //--- // Get the extents: // dimsOut[0] is height, dimsOut[1] is width: //--- std::vector<hsize_t> latDimsOut(LAT_DIM_COUNT); latDataSpace.getSimpleExtentDims( &latDimsOut.front(), 0 ); std::vector<hsize_t> lonDimsOut(LON_DIM_COUNT); lonDataSpace.getSimpleExtentDims( &lonDimsOut.front(), 0 ); // Verify valid rect within our bounds: if ( (ROWS <= latDimsOut[0] ) && (ROWS <= lonDimsOut[0] ) && (COLS <= latDimsOut[1] ) && (COLS <= lonDimsOut[1] ) ) { //---- // Initialize the ossimDblGrids: //--- ossimDpt dspacing (GRID_SIZE, GRID_SIZE); ossim_uint32 gridRows = ROWS / GRID_SIZE + 1; ossim_uint32 gridCols = COLS / GRID_SIZE + 1; // Round up if size doesn't fall on end pixel. if ( ROWS % GRID_SIZE) ++gridRows; if ( COLS % GRID_SIZE) ++gridCols; ossimIpt gridSize (gridCols, gridRows); // The grid as used in base class, has UV-space always at 0,0 origin ossimDpt gridOrigin(0.0,0.0); const ossim_float64 NULL_VALUE = -999.0; theLatGrid.setNullValue(ossim::nan()); theLonGrid.setNullValue(ossim::nan()); theLatGrid.initialize(gridSize, gridOrigin, dspacing); theLonGrid.initialize(gridSize, gridOrigin, dspacing); std::vector<hsize_t> inputCount(LAT_DIM_COUNT); std::vector<hsize_t> inputOffset(LAT_DIM_COUNT); inputOffset[0] = 0; // row is set below. inputOffset[1] = validRect.ul().x; // col inputCount[0] = 1; // row inputCount[1] = (hsize_t)COLS; // col // Output dataspace dimensions. Reading a line at a time. const ossim_int32 OUT_DIM_COUNT = 3; std::vector<hsize_t> outputCount(OUT_DIM_COUNT); outputCount[0] = 1; // band outputCount[1] = 1; // row outputCount[2] = COLS; // col // Output dataspace offset. std::vector<hsize_t> outputOffset(OUT_DIM_COUNT); outputOffset[0] = 0; outputOffset[1] = 0; outputOffset[2] = 0; ossimScalarType scalar = ossim_hdf5::getScalarType( latDataSet ); if ( scalar == OSSIM_FLOAT32 ) { // Set the return status to true if we get here... status = true; // See if we need to swap bytes: ossimEndian* endian = 0; if ( ( ossim::byteOrder() != ossim_hdf5::getByteOrder( latDataSet ) ) ) { endian = new ossimEndian(); } // Native type: H5::DataType latDataType = latDataSet->getDataType(); H5::DataType lonDataType = lonDataSet->getDataType(); // Output dataspace always the same, width of one line. H5::DataSpace bufferDataSpace( OUT_DIM_COUNT, &outputCount.front()); bufferDataSpace.selectHyperslab( H5S_SELECT_SET, &outputCount.front(), &outputOffset.front() ); // Arrays to hold a single line of latitude longitude values. vector<ossim_float32> latValue(COLS); vector<ossim_float32> lonValue(COLS); hsize_t row = 0; // Line loop: for ( ossim_uint32 y = 0; y < gridRows; ++y ) { // row = line in image space row = y*GRID_SIZE; if ( row < ROWS ) { inputOffset[0] = row + validRect.ul().y; latDataSpace.selectHyperslab( H5S_SELECT_SET, &inputCount.front(), &inputOffset.front() ); lonDataSpace.selectHyperslab( H5S_SELECT_SET, &inputCount.front(), &inputOffset.front() ); // Read data from file into the buffer. latDataSet->read( &(latValue.front()), latDataType, bufferDataSpace, latDataSpace ); lonDataSet->read( &(lonValue.front()), lonDataType, bufferDataSpace, lonDataSpace ); if ( endian ) { // If the endian pointer is initialized(not zero) swap the bytes. endian->swap( &(latValue.front()), COLS ); endian->swap( &(lonValue.front()), COLS ); } // Sample loop: hsize_t col = 0; for ( ossim_uint32 x = 0; x < gridCols; ++x ) { ossim_float32 lat = ossim::nan(); ossim_float32 lon = ossim::nan(); // col = sample in image space col = x*GRID_SIZE; if ( col < COLS ) { if ( (latValue[col] > NULL_VALUE)&&(lonValue[col] > NULL_VALUE) ) { lat = latValue[col]; lon = lonValue[col]; if ( m_crossesDateline ) { if ( lon < 0.0 ) lon += 360; } } else // Nulls in grid! { std::string errMsg = "ossimH5GridModel::setGridNodes encountered nans!"; throw ossimException(errMsg); } } else // Last column is outside of image bounds. { // Get the last two latitude values: ossim_float32 lat1 = theLatGrid.getNode( x-2, y ); ossim_float32 lat2 = theLatGrid.getNode( x-1, y ); // Get the last two longitude values ossim_float32 lon1 = theLonGrid.getNode( x-2, y ); ossim_float32 lon2 = theLonGrid.getNode( x-1, y ); if ( ( lat1 > NULL_VALUE ) && ( lat2 > NULL_VALUE ) ) { // Delta between last two latitude grid values. ossim_float32 latSpacing = lat2 - lat1; // Compute: lat = lat2 + latSpacing; } else // Nulls in grid! { std::string errMsg = "ossimH5GridModel::setGridNodes encountered nans!"; throw ossimException(errMsg); } if ( ( lon1 > NULL_VALUE ) && ( lon2 > NULL_VALUE ) ) { // Delta between last two longitude values. ossim_float32 lonSpacing = lon2 - lon1; // Compute: lon = lon2 + lonSpacing; // Check for wrap: if ( !m_crossesDateline && ( lon > 180 ) ) { lon -= 360.0; } } else // Nulls in grid! { std::string errMsg = "ossimH5GridModel::setGridNodes encountered nans!"; throw ossimException(errMsg); } #if 0 /* Please leave for debug. (drb) */ cout << "lat1: " << lat1 << " lat2 " << lat2 << " lon1 " << lon1 << " lon2 " << lon2 << "\n"; #endif } // Assign the latitude and longitude. theLatGrid.setNode( x, y, lat ); theLonGrid.setNode( x, y, lon ); #if 0 /* Please leave for debug. (drb) */ cout << "x,y,col,row,lat,lon:" << x << "," << y << "," << col << "," << row << "," << theLatGrid.getNode(x, y) << "," << theLonGrid.getNode( x, y) << "\n"; #endif } // End sample loop. } else // Row is outside of image bounds: { // Sample loop: for ( ossim_uint32 x = 0; x < gridCols; ++x ) { ossim_float32 lat = ossim::nan(); ossim_float32 lon = ossim::nan(); ossim_float32 lat1 = theLatGrid.getNode( x, y-2 ); ossim_float32 lat2 = theLatGrid.getNode( x, y-1 ); ossim_float32 lon1 = theLonGrid.getNode( x, y-2 ); ossim_float32 lon2 = theLonGrid.getNode( x, y-1 ); if ( ( lon1 > NULL_VALUE ) && ( lon2 > NULL_VALUE ) ) { // Delta between last two longitude values. ossim_float32 lonSpacing = lon2 - lon1; // Compute: lon = lon2 + lonSpacing; // Check for wrap: if ( !m_crossesDateline && ( lon > 180 ) ) { lon -= 360.0; } } else // Nulls in grid! { std::string errMsg = "ossimH5GridModel::setGridNodes encountered nans!"; throw ossimException(errMsg); } if ( ( lat1 > NULL_VALUE ) && ( lat2 > NULL_VALUE ) ) { // Delta between last two latitude values. ossim_float32 latSpacing = lat2 - lat1; lat = lat2 + latSpacing; } else // Nulls in grid! { std::string errMsg = "ossimH5GridModel::setGridNodes encountered nans!"; throw ossimException(errMsg); } #if 0 /* Please leave for debug. (drb) */ hsize_t col = x*GRID_SIZE; // Sample in image space cout << "lat1: " << lat1 << " lat2 " << lat2 << " lon1 " << lon1 << " lon2 " << lon2 << "\nx,y,col,row,lat,lon:" << x << "," << y << "," << col << "," << row << "," << lat << "," << lon << "\n"; #endif // Assign the latitude:: theLatGrid.setNode( x, y, lat ); // Assign the longitude. theLonGrid.setNode( x, y, lon ); } // End sample loop. } // Matches if ( row < imageRows ){...}else{ } // End line loop. latDataSpace.close(); lonDataSpace.close(); if ( status ) { theSeedFunction = ossim_hdf5::getBilinearProjection( *latDataSet,*lonDataSet, validRect ); // Bileaner projection to handle ossimDrect imageRect(validRect); initializeModelParams(imageRect); // debugDump(); } if ( endian ) { delete endian; endian = 0; } } // Matches: if ( scalar == OSSIM_FLOAT32 ) } // Matches: if ( (latDimsOut[0] == imageRows) ... } // Matches: if ( ( LAT_DIM_COUNT == 2 ) ... } // Matches: if ( latDataSet && lonDataSet return status; } // End: bool ossimH5GridModel::setGridNodes( H5::DataSet* latDataSet, ... )
void QgsMapCanvas::mapUpdateTimeout() { const QImage& img = mJob->renderedImage(); mMap->setContent( img, imageRect( img, mJob->mapSettings() ) ); }
void FileView::paint(QPainter* painter, const QRect& rect, const QPalette& palette, DisplayMode displayMode) const { painter->save(); painter->setRenderHint(QPainter::Antialiasing, true); painter->translate(rect.x(), rect.y()); if(displayMode == DM_Selected) painter->setBrush(palette.highlightedText()); else painter->setBrush(palette.foreground()); painter->setPen(QPen(painter->brush(), 1)); int textFlags = Qt::AlignLeft | Qt::AlignVCenter; QFont font(painter->font()); font.setBold(true); painter->setFont(font); QString nameDisplay = (mode == TM_Send) ? tr("To: ") : tr("From: "); nameDisplay.append(userName); QRect textRect = QRect(54, 0, rect.width() - 58, 18); QString text = painter->fontMetrics().elidedText(nameDisplay, Qt::ElideRight, textRect.width()); painter->drawText(textRect, textFlags, text); font.setBold(false); painter->setFont(font); textRect = QRect(54, 18, rect.width() - 58, 18); text = painter->fontMetrics().elidedText(fileDisplay, Qt::ElideMiddle, textRect.width()); painter->drawText(textRect, textFlags, text); bool drawProgress = false; QString stateDisplay; switch(state) { case TS_Send: stateDisplay = timeDisplay + " left - " + posDisplay + " of " + sizeDisplay + " (" + speedDisplay + ")"; drawProgress = true; break; case TS_Receive: stateDisplay = timeDisplay + " left - " + posDisplay + " of " + sizeDisplay + " (" + speedDisplay + ")"; drawProgress = true; break; case TS_Complete: stateDisplay = tr("Completed"); break; case TS_Cancel: stateDisplay = tr("Canceled"); break; case TS_Abort: stateDisplay = tr("Interrupted"); break; default: break; } textRect = QRect(54, 36, rect.width() - 58, 18); text = painter->fontMetrics().elidedText(stateDisplay, Qt::ElideRight, textRect.width()); painter->drawText(textRect, textFlags, text); if(drawProgress) { int spanAngle = ((double)position / (double)fileSize) * 360; painter->setBrush(QBrush(QColor(230, 230, 230))); painter->setPen(QPen(QColor(230, 230, 230))); painter->drawPie(4, 4, 46, 46, (90 - spanAngle) * 16, -(360 - spanAngle) * 16); painter->setBrush(QBrush(QColor(150, 225, 110))); painter->setPen(QPen(QColor(150, 225, 110))); painter->drawPie(4, 4, 46, 46, 90 * 16, -spanAngle * 16); painter->setBrush(QBrush(QColor(255, 255, 255))); painter->setPen(QPen(QColor(255, 255, 255), 2)); painter->drawLine(27, 5, 27, 49); painter->drawLine(5, 27, 49, 27); painter->drawLine(11, 11, 42, 42); painter->drawLine(42, 11, 11, 42); } QRect imageRect(11, 11, 32, 32); painter->drawPixmap(imageRect, icon); painter->restore(); }
bool ossimHdfGridModel::setGridNodes( H5::DataSet* latDataSet, H5::DataSet* lonDataSet, ossim_uint32 imageRows, ossim_uint32 imageCols ) { bool status = false; if ( latDataSet && lonDataSet ) { const ossim_uint32 GRID_SIZE = 32; // Only grab every 32nd value. // Get dataspace of the dataset. H5::DataSpace latDataSpace = latDataSet->getSpace(); H5::DataSpace lonDataSpace = lonDataSet->getSpace(); const ossim_int32 LAT_DIM_COUNT = latDataSpace.getSimpleExtentNdims(); const ossim_int32 LON_DIM_COUNT = latDataSpace.getSimpleExtentNdims(); // Number of dimensions of the input dataspace: if ( ( LAT_DIM_COUNT == 2 ) && ( LON_DIM_COUNT == 2 ) ) { //--- // Get the extents: // dimsOut[0] is height, dimsOut[1] is width: //--- std::vector<hsize_t> latDimsOut(LAT_DIM_COUNT); latDataSpace.getSimpleExtentDims( &latDimsOut.front(), 0 ); std::vector<hsize_t> lonDimsOut(LON_DIM_COUNT); lonDataSpace.getSimpleExtentDims( &lonDimsOut.front(), 0 ); // Verify same as image: if ( (latDimsOut[0] == imageRows) && (lonDimsOut[0] == imageRows) && (latDimsOut[1] == imageCols) && (lonDimsOut[1] == imageCols) ) { //--- // Capture the rectangle: // dimsOut[0] is height, dimsOut[1] is width: //--- ossimIrect rect = ossimIrect( 0, 0, static_cast<ossim_int32>( latDimsOut[1]-1 ), static_cast<ossim_int32>( latDimsOut[0]-1 ) ); //---- // Initialize the ossimDblGrids: //--- ossimDpt dspacing (GRID_SIZE, GRID_SIZE); ossim_uint32 gridRows = imageRows / GRID_SIZE + 1; ossim_uint32 gridCols = imageCols / GRID_SIZE + 1; // Round up if size doesn't fall on end pixel. if ( imageRows % GRID_SIZE) ++gridRows; if ( imageCols % GRID_SIZE) ++gridCols; ossimIpt gridSize (gridCols, gridRows); // The grid as used in base class, has UV-space always at 0,0 origin ossimDpt gridOrigin(0.0,0.0); const ossim_float64 NULL_VALUE = -999.0; theLatGrid.setNullValue(ossim::nan()); theLonGrid.setNullValue(ossim::nan()); theLatGrid.initialize(gridSize, gridOrigin, dspacing); theLonGrid.initialize(gridSize, gridOrigin, dspacing); std::vector<hsize_t> inputCount(LAT_DIM_COUNT); std::vector<hsize_t> inputOffset(LAT_DIM_COUNT); inputOffset[0] = 0; // row inputOffset[1] = 0; // col inputCount[0] = 1; // row inputCount[1] = (hsize_t)imageCols; // col // Output dataspace dimensions. Reading a line at a time. const ossim_int32 OUT_DIM_COUNT = 3; std::vector<hsize_t> outputCount(OUT_DIM_COUNT); outputCount[0] = 1; // band outputCount[1] = 1; // row outputCount[2] = imageCols; // col // Output dataspace offset. std::vector<hsize_t> outputOffset(OUT_DIM_COUNT); outputOffset[0] = 0; outputOffset[1] = 0; outputOffset[2] = 0; ossimScalarType scalar = ossim_hdf5::getScalarType( latDataSet ); if ( scalar == OSSIM_FLOAT32 ) { // Set the return status to true if we get here... status = true; // See if we need to swap bytes: ossimEndian* endian = 0; if ( ( ossim::byteOrder() != ossim_hdf5::getByteOrder( latDataSet ) ) ) { endian = new ossimEndian(); } // Native type: H5::DataType latDataType = latDataSet->getDataType(); H5::DataType lonDataType = lonDataSet->getDataType(); // Output dataspace always the same, width of one line. H5::DataSpace bufferDataSpace( OUT_DIM_COUNT, &outputCount.front()); bufferDataSpace.selectHyperslab( H5S_SELECT_SET, &outputCount.front(), &outputOffset.front() ); // Arrays to hold a single line of latitude longitude values. vector<ossim_float32> latValue(imageCols); vector<ossim_float32> lonValue(imageCols); hsize_t row = 0; // Line loop: for ( ossim_uint32 y = 0; y < gridRows; ++y ) { // row = line in image space row = y*GRID_SIZE; bool hitNans = false; if ( row < imageRows ) { inputOffset[0] = row; latDataSpace.selectHyperslab( H5S_SELECT_SET, &inputCount.front(), &inputOffset.front() ); lonDataSpace.selectHyperslab( H5S_SELECT_SET, &inputCount.front(), &inputOffset.front() ); // Read data from file into the buffer. latDataSet->read( &(latValue.front()), latDataType, bufferDataSpace, latDataSpace ); lonDataSet->read( &(lonValue.front()), lonDataType, bufferDataSpace, lonDataSpace ); if ( endian ) { // If the endian pointer is initialized(not zero) swap the bytes. endian->swap( &(latValue.front()), imageCols ); endian->swap( &(lonValue.front()), imageCols ); } // Sample loop: hsize_t col = 0; for ( ossim_uint32 x = 0; x < gridCols; ++x ) { ossim_float32 lat = ossim::nan(); ossim_float32 lon = ossim::nan(); // col = sample in image space col = x*GRID_SIZE; if ( col < imageCols ) { if ( (latValue[col] > NULL_VALUE)&&(lonValue[col] > NULL_VALUE) ) { lat = latValue[col]; lon = lonValue[col]; } else { hitNans = true; } } else // Last column is outside of image bounds. { ossim_float32 latSpacing = ossim::nan(); ossim_float32 lonSpacing = ossim::nan(); // Get the last two latitude values: ossim_float32 lat1 = latValue[imageCols-2]; ossim_float32 lat2 = latValue[imageCols-1]; // Get the last two longitude values ossim_float32 lon1 = lonValue[imageCols-2]; ossim_float32 lon2 = lonValue[imageCols-1]; if ( ( lat1 > NULL_VALUE ) && ( lat2 > NULL_VALUE ) ) { // Delta between last two latitude values. latSpacing = lat2 - lat1; // Compute: lat = lat2 + ( col - (imageCols-1) ) * latSpacing; } else { hitNans = true; } if ( ( lon1 > NULL_VALUE ) && ( lon2 > NULL_VALUE ) ) { // Consider dateline crossing. if ( (lon1 > 0.0) && ( lon2 < 0.0 ) ) { lon2 += 360.0; } // Delta between last two longitude values. lonSpacing = lon2 - lon1; // Compute: lon = lon2 + ( col - (imageCols-1) ) * lonSpacing; // Check for wrap: if ( lon > 180 ) { lon -= 360.0; } } else { hitNans = true; } #if 0 /* Please leave for debug. (drb) */ cout << "lat1: " << lat1 << " lat2 " << lat2 << " lon1 " << lon1 << " lon2 " << lon2 << "\n"; #endif } if ( hitNans ) { std::string errMsg = "ossimHdfGridModel::setGridNodes encountered nans!"; throw ossimException(errMsg); } // Assign the latitude and longitude. theLatGrid.setNode( x, y, lat ); theLonGrid.setNode( x, y, lon ); #if 0 /* Please leave for debug. (drb) */ cout << "x,y,col,row,lat,lon:" << x << "," << y << "," << col << "," << row << "," << theLatGrid.getNode(x, y) << "," << theLonGrid.getNode( x, y) << "\n"; #endif } // End sample loop. } else // Row is outside of image bounds: { // Read the last two rows in. vector<ossim_float32> latValue2(imageCols); vector<ossim_float32> lonValue2(imageCols); inputOffset[0] = imageRows-2; // 2nd to last line latDataSpace.selectHyperslab( H5S_SELECT_SET, &inputCount.front(), &inputOffset.front() ); lonDataSpace.selectHyperslab( H5S_SELECT_SET, &inputCount.front(), &inputOffset.front() ); // Read data from file into the buffer. latDataSet->read( &(latValue.front()), latDataType, bufferDataSpace, latDataSpace ); lonDataSet->read( &(lonValue.front()), lonDataType, bufferDataSpace, lonDataSpace ); inputOffset[0] = imageRows-1; // last line latDataSpace.selectHyperslab( H5S_SELECT_SET, &inputCount.front(), &inputOffset.front() ); lonDataSpace.selectHyperslab( H5S_SELECT_SET, &inputCount.front(), &inputOffset.front() ); // Read data from file into the buffer. latDataSet->read( &(latValue2.front()), latDataType, bufferDataSpace, latDataSpace ); lonDataSet->read( &(lonValue2.front()), lonDataType, bufferDataSpace, lonDataSpace ); if ( endian ) { // If the endian pointer is initialized(not zero) swap the bytes. endian->swap( &(latValue.front()), imageCols ); endian->swap( &(lonValue.front()), imageCols ); endian->swap( &(latValue2.front()), imageCols ); endian->swap( &(lonValue2.front()), imageCols ); } // Sample loop: hsize_t col = 0; for ( ossim_uint32 x = 0; x < gridCols; ++x ) { col = x*GRID_SIZE; // Sample in image space. ossim_float32 lat = ossim::nan(); ossim_float32 lat1 = ossim::nan(); ossim_float32 lat2 = ossim::nan(); ossim_float32 latSpacing = ossim::nan(); ossim_float32 lon = ossim::nan(); ossim_float32 lon1 = ossim::nan(); ossim_float32 lon2 = ossim::nan(); ossim_float32 lonSpacing = ossim::nan(); if ( col < imageCols ) { lat1 = latValue[col]; lat2 = latValue2[col]; lon1 = lonValue[col]; lon2 = lonValue2[col]; } else // Very last grid point. { // Compute the missing column for the last two image lines: lat1 = latValue[imageCols-1] + ( col - (imageCols-1)) * ( latValue[imageCols-1] - latValue[imageCols-2] ); lat2 = latValue2[imageCols-1] + ( col - (imageCols-1)) * ( latValue2[imageCols-1] - latValue2[imageCols-2] ); lon1 = lonValue[imageCols-1] + ( col - (imageCols-1)) * ( lonValue[imageCols-1] - lonValue[imageCols-2] ); lon2 = lonValue2[imageCols-1] + ( col - (imageCols-1)) * ( lonValue2[imageCols-1] - lonValue2[imageCols-2] ); } #if 0 /* Please leave for debug. (drb) */ cout << "lat1: " << lat1 << " lat2 " << lat2 << " lon1 " << lon1 << " lon2 " << lon2 << "\n"; #endif if ( ( lon1 > NULL_VALUE ) && ( lon2 > NULL_VALUE ) ) { // Consider dateline crossing. if ( (lon1 > 0.0) && ( lon2 < 0.0 ) ) { lon2 += 360.0; } // Delta between last two longitude values. lonSpacing = lon2 - lon1; // Compute: lon = lon2 + ( row - (imageRows-1) ) * lonSpacing; // Check for wrap: if ( lon > 180 ) { lon -= 360.0; } } else { hitNans = true; } if ( ( lat1 > NULL_VALUE ) && ( lat2 > NULL_VALUE ) ) { // Delta between last two latitude values. latSpacing = lat2 - lat1; // Compute: lat = lat2 + ( row - (imageRows-1) ) * latSpacing; } else { hitNans = true; } if ( hitNans ) { std::string errMsg = "ossimHdfGridModel::setGridNodes encountered nans!"; throw ossimException(errMsg); } // Assign the latitude:: theLatGrid.setNode( x, y, lat ); // Assign the longitude. theLonGrid.setNode( x, y, lon ); #if 0 /* Please leave for debug. (drb) */ cout << "x,y,col,row,lat,lon:" << x << "," << y << "," << col << "," << row << "," << lat << "," << lon << "\n"; #endif } // End sample loop. } // Matches if ( row < imageRows ){...}else{ } // End line loop. latDataSpace.close(); lonDataSpace.close(); if ( status ) { theLatGrid.enableExtrapolation(); theLonGrid.enableExtrapolation(); theHeightEnabledFlag = false; ossimDrect imageRect(rect); initializeModelParams(imageRect); // debugDump(); } } // Matches: if ( scalar == OSSIM_FLOAT32 ) } // Matches: if ( (latDimsOut[0] == imageRows) ... } // Matches: if ( ( LAT_DIM_COUNT == 2 ) ... } // Matches: if ( latDataSet && lonDataSet return status; } // End: bool ossimHdfGridModel::setGridNodes( H5::DataSet* latDataSet, ... )