uint16_t tft_t::vsTransformBack(uint16_t y) const { #ifndef NO_CHECK if ((int16_t)y < 0) return y; #endif if (y < topEdge() || y >= bottomEdge()) return y; if (y < upperEdge()) y += vsHeight(); y -= upperEdge(); // Relative to upperEdge y += topEdge(); // Relative to 0 return y; }
void ossimGmlSupportData::getGeoOrigin( const ossimImageGeometry* geom, ossimString& originString, ossimString& offsetVector1String, ossimString& offsetVector2String ) const { if ( geom ) { // Get the gsd and bounding rect: ossimDpt gsd; ossimGrect rect; geom->getDegreesPerPixel( gsd ); geom->getBoundingGroundRect( rect ); ossimDpt halfGsd = gsd/2.0; ossimDpt upperEdge( rect.ul().lon + halfGsd.x, rect.ul().lat + halfGsd.y ); std::ostringstream os; os.precision(15); os << upperEdge.lat << " " << upperEdge.lon; originString = os.str(); std::ostringstream os2; os2.precision(15); os2 << -gsd.y << " " << "0.0"; offsetVector1String = os2.str(); std::ostringstream os3; os3.precision(15); os3 << "0.0" << " " << gsd.x; offsetVector2String = os3.str(); } } // End: ossimGmlSupportData::getGeoOrigin
void ossimGmlSupportData::getGeoBounds( const ossimImageGeometry* geom, ossimString& upperCornerString, ossimString& lowerCornerString ) const { if ( geom != 0 && m_mapProj != 0 ) { // Get the bounding rect: ossimGrect rect; geom->getBoundingGroundRect( rect ); ossimDpt upperEdge( rect.ul().lon, rect.ul().lat ); ossimDpt lowerEdge( rect.lr().lon, rect.lr().lat ); std::ostringstream os; os.precision(5); os << upperEdge.lat << " " << upperEdge.lon; upperCornerString = os.str(); std::ostringstream os2; os2.precision(5); os2 << lowerEdge.lat << " " << lowerEdge.lon; lowerCornerString = os2.str(); } } // End: ossimGmlSupportData::getGeoBounds
void tft_t::rectangle(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t c) { if (!h || !w) return; uint16_t yt, bMask; if (!transform()) goto disp; if (!portrait()) { swap(x, y); swap(w, h); } yt = vsTransformBack(y); if ((int16_t)yt < (int16_t)topEdge() && \ (int16_t)(yt + h) >= (int16_t)topEdge()) { // Top edge clipping h -= topEdge() - yt; y = upperEdge(); yt = vsTransformBack(y); } else if (yt < bottomEdge() && yt + h >= bottomEdge()) // Bottom edge clipping h = bottomEdge() - yt; if (y + h > bottomEdge()) // Transform edge split if (y < bottomEdge()) { if (!portrait()) { rectangle(y, x, bottomEdge() - y, w, c); rectangle(topEdge(), x, h - (bottomEdge() - y), w, c); } else { rectangle(x, y, w, bottomEdge() - y, c); rectangle(x, topEdge(), w, h - (bottomEdge() - y), c); } return; } if (yt < topMask()) { if (yt + h < topMask()) return; h -= topMask() - yt; y = vsTransform(topMask()); } bMask = vsMaximum() - bottomMask(); if (yt >= bMask) return; if (yt + h > bMask) h -= yt + h - bMask; if (!portrait()) { area(y, x, h, w); goto draw; } disp: area(x, y, w, h); draw: start(); while (h--) for (uint16_t xx = 0; xx < w; xx++) write16(c); }
uint16_t tft_t::vsTransform(uint16_t y) const { #ifndef NO_CHECK if ((int16_t)y < 0) return y; #endif if (y < topEdge() || y >= bottomEdge()) return y; y -= topEdge(); // Relative to upperEdge y += upperEdge(); // Relative to 0 if (y >= bottomEdge()) // Transform edge y -= vsHeight(); return y; }
void tft_t::putch(char ch) { #ifndef NO_CHECK if ((int16_t)x() >= (int16_t)width() || (int16_t)y() >= (int16_t)height()) return; #endif if ((int16_t)(x() + FONT_WIDTH * zoom()) < 0) return; uint8_t h = FONT_HEIGHT * zoom(), w = FONT_WIDTH * zoom(); // Display coordinate, start coordinate uint16_t xx = x(), x0 = x(); uint16_t yy = y(), y0 = y(); uint8_t xStart = 0, xStop = w; uint8_t yStart = 0, yStop = h; #if 1 if (transform()) { if (!portrait()) { yy = xx; y0 = x0; yStop = xStop; swap(w, h); } uint16_t yt = vsTransformBack(yy); if ((int16_t)yt < (int16_t)topEdge() && \ (int16_t)(yt + h) >= (int16_t)topEdge()) { // Top edge clipping yStart = topEdge() - yt; yy = upperEdge(); y0 = yy - yStart; yt = vsTransformBack(yy); } else if (yt < bottomEdge() && yt + h >= bottomEdge()) // Bottom edge clipping yStop = bottomEdge() - yt; if (yt < topMask()) { if (yt + yStop - yStart < topMask()) return; yy = vsTransform(topMask()); yStart += topMask() - yt; y0 = yy - yStart; } uint16_t bMask = vsMaximum() - bottomMask(); if (yt >= bMask) return; if (yt + yStop - yStart > bMask) yStop -= yt + yStop - yStart - bMask; if (!portrait()) { swap(w, h); xx = yy; x0 = y0; xStart = yStart; xStop = yStop; yy = y(); y0 = y(); yStart = 0; yStop = h; } } #else if (transform()) { uint16_t xt = vsTransformBack(xx); if ((int16_t)xt < (int16_t)topEdge() && \ (int16_t)(xt + w) >= (int16_t)topEdge()) { // Top edge clipping xStart = topEdge() - xt; xx = upperEdge(); x0 = xx - xStart; xt = vsTransformBack(xx); } else if (xt < bottomEdge() && xt + w >= bottomEdge()) // Bottom edge clipping xStop = bottomEdge() - xt; if (xt < topMask()) { if (xt + xStop - xStart < topMask()) return; xx = vsTransform(topMask()); xStart += topMask() - xt; x0 = xx - xStart; } uint16_t bMask = vsMaximum() - bottomMask(); if (xt >= bMask) return; if (xt + xStop - xStart > bMask) xStop -= xt + xStop - xStart - bMask; } #endif bool xTransform = transform() && !portrait() && x0 < bottomEdge() && x0 + xStop - xStart > bottomEdge(); bool yTransform = transform() && portrait() && y0 < bottomEdge() && y0 + yStop - yStart > bottomEdge(); uint8_t xEnd = xTransform ? bottomEdge() - xx : xStop; draw: area(xx, yy, xEnd - xStart, h); start(); for (uint8_t i = yStart; i < yStop; i++) { if (yTransform && y0 + i == bottomEdge()) { area(x(), topEdge(), w, h); start(); yTransform = false; } unsigned char c; c = pgm_read_byte(&(ascii[ch - ' '][i / zoom()])) << (xStart / zoom()); for (uint8_t j = xStart; j < xEnd; j++) { if (c & 0x80) write16(foreground()); else write16(background()); if (j % zoom() == zoom() - 1) c <<= 1; } } if (xTransform) { xx = topEdge(); xStart = xEnd; xEnd = xStop; xTransform = false; goto draw; } }