Example #1
0
      Size PureProjection::GetTileMatrixSizeXY(const int &zoom)
      {
         Size sMin = GetTileMatrixMinXY(zoom);
         Size sMax = GetTileMatrixMaxXY(zoom);

         return  Size(sMax.Width() - sMin.Width() + 1, sMax.Height() - sMin.Height() + 1);
      }
void WindowManager::MapCoords(unsigned int& x, unsigned int& y)
{
   Size windowSize = m_spRootWindow->GetSize();

   // translate to window coords
   x = static_cast<unsigned int>((double(windowSize.Width()) / m_screenSize.Width()) * x);
   y = static_cast<unsigned int>((double(windowSize.Height()) / m_screenSize.Height()) * y);
}
void TextTexture::UpdateText(Font& font,
   const CString& cszText, const Size& s, T_enTextAlignment enTextAlignment,
   Color cForeground, Color cBackground)
{
   unsigned int uiLenPx = font.MeasureString(cszText);
   unsigned int uiPosX = 0;

   if (enTextAlignment == textAlignCenter)
      uiPosX = uiLenPx < unsigned(s.Width()) ? (unsigned(s.Width()) - uiLenPx) / 2 : 0;

   unsigned int uiPosY = font.Height() < unsigned(s.Height()) ? (unsigned(s.Height()) - font.Height()) / 2 : 0;

   Bitmap bmp(s.Width(), s.Height(), cBackground);
   font.Write(cszText, bmp, uiPosX, uiPosY, cForeground, cBackground);

   if (m_tex.Id() == 0)
      m_tex.Generate();

   m_tex.Upload(bmp, false);
}
internals::PointLatLng MercatorProjection::FromPixelToLatLng(const int &x, const int &y, const int &zoom)
{
    internals::PointLatLng ret;// = internals::PointLatLng.Empty;

    Size s = GetTileMatrixSizePixel(zoom);
    double mapSizeX = s.Width();
    double mapSizeY = s.Height();

    double xx = (Clip(x, 0, mapSizeX - 1) / mapSizeX) - 0.5;
    double yy = 0.5 - (Clip(y, 0, mapSizeY - 1) / mapSizeY);

    ret.SetLat(90 - 360 * atan(exp(-yy * 2 * M_PI)) / M_PI);
    ret.SetLng(360 * xx);

    return ret;
}
Example #5
0
/**
 * @brief MercatorProjection::FromPixelToLatLng Referenced from top-left of globe, so the lat-lon (0,0), i.e. the intersection of the equator and prime meridian, would be [1<<(zoom-1), 1<<(zoom-1)]
 * @param x Horizontal location in [pixels], referenced from left edge of global map
 * @param y Vertical location in [pixels], referenced from top edge of global map
 * @param zoom
 * @return Latitude and Longitude in [degrees]
 */
internals::PointLatLng MercatorProjection::FromPixelToLatLng(const qint64 &x,const qint64 &y,const int &zoom)
{
    internals::PointLatLng ret;// = internals::PointLatLng.Empty;

    Size s = GetTileMatrixSizePixel(zoom);
    double mapSizeX = s.Width();
    double mapSizeY = s.Height();

    //Calculate the percentage distance between top and bottom, and left and right
    double xx = (bound(x, 0, mapSizeX - 1) / mapSizeX) - 0.5;
    double yy = 0.5 - (bound(y, 0, mapSizeY - 1) / mapSizeY);

    ret.SetLat(90 - 360 * atan(exp(-yy * 2 * M_PI)) / M_PI);
    ret.SetLng(360 * xx);

    return ret;
}
void WindowManager::Render()
{
   // setup orthogonal projection
   glMatrixMode(GL_PROJECTION);
   glPushMatrix();
   glLoadIdentity();
   Size s = m_spRootWindow->GetSize();
   gluOrtho2D(0, s.Width(), s.Height(), 0);

   glMatrixMode(GL_MODELVIEW);
   glPushMatrix();
   glLoadIdentity();

   // set states
   glDisable(GL_DEPTH_TEST);
   glEnable(GL_BLEND);
   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
   glDisable(GL_LIGHTING);

   // set up texturing
   glEnable(GL_TEXTURE_2D);

   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

   glColor3ub(255, 255, 255);

   // render root window; all child windows are rendered recursively
   Rect rectArea(Point(0,0), m_spRootWindow->GetSize());
   m_spRootWindow->Render(rectArea);

   // restore previous projection
   glMatrixMode(GL_PROJECTION);
   glPopMatrix();

   glMatrixMode(GL_MODELVIEW);
   glPopMatrix();

   glDisable(GL_BLEND);
   glEnable(GL_DEPTH_TEST);
   glDisable(GL_TEXTURE_2D);
}
Point MercatorProjection::FromLatLngToPixel(double lat, double lng, const int &zoom)
{
    Point ret;// = Point.Empty;

    lat = Clip(lat, MinLatitude, MaxLatitude);
    lng = Clip(lng, MinLongitude, MaxLongitude);

    double x = (lng + 180) / 360;
    double sinLatitude = sin(lat * M_PI / 180);
    double y = 0.5 - log((1 + sinLatitude) / (1 - sinLatitude)) / (4 * M_PI);

    Size s = GetTileMatrixSizePixel(zoom);
    int mapSizeX = s.Width();
    int mapSizeY = s.Height();

    ret.SetX((int) Clip(x * mapSizeX + 0.5, 0, mapSizeX - 1));
    ret.SetY((int) Clip(y * mapSizeY + 0.5, 0, mapSizeY - 1));

    return ret;
}
void Checkbox::UpdateTexture() throw()
{
    try
    {
        Font& font = GetFont();

        Size s = GetSize();
        int iOffset = int(s.Height() * 1.1);
        s.Width(s.Width() - iOffset);

        CString cszText = GetAttr(CheckboxAttr::Text);
        Color cText = GetAttrAsColor(CheckboxAttr::Color);
        Color cBack = GetAttrAsColor(CheckboxAttr::BackColor);

        m_text.UpdateText(font, cszText, s, TextTexture::textAlignLeft, cText, cBack);
    }
    catch (...)
    {
    }
}
Example #9
0
 Size PureProjection::GetTileMatrixSizePixel(const int &zoom)
 {
    Size s = GetTileMatrixSizeXY(zoom);
    return Size(s.Width() * TileSize().Width(), s.Height() * TileSize().Height());
 }
Example #10
0
 int PureProjection::GetTileMatrixItemCount(const int &zoom)
 {
    Size s = GetTileMatrixSizeXY(zoom);
    return (s.Width() * s.Height());
 }
Example #11
0
 Point::Point(Size sz)
 {
     this->x=sz.Width();
     this->y=sz.Height();
     empty=false;
 }
void MediaDispatcherImpl::OnVideoDecode(VideoDecodeEventArgs const& e)
{
	VideoSource const& s = e.Source();
	
	int32 channel = s.Channel(); 

	if (mNeedWaitI[channel])
	{
		if (s.Type() == VideoType_H264_IFrame)
			mNeedWaitI[channel] = false;
		else
			return;
	}
		
	if (mVideoMode[channel].Width() != s.Width() || mVideoMode[channel].Height() != s.Height())
	{
		mVideoMode[channel] = Size(s.Width(), s.Height());
		DisposeVideoDecoder(channel);
	}

	JNIEnv* env = GetJNIEnvAttachThread();

	if (mVideoDecoder[channel] == NULL)
		CreateVideoDecoder(env, channel, s.Width(), s.Height()); // create decoder and buffer

	
	jintArray outputSize = env->NewIntArray(3);
	jint* _outputSize = env->GetIntArrayElements(outputSize, 0);

	
	//
	
	jobjectArray videoBuffer2d = env->CallObjectMethod(mObject, methods.MediaDispatcher_GetVideoBuffer, channel);

	jbyteArray y = (jbyteArray) env->GetObjectArrayElement(videoBuffer2d, (jsize) 0);
	jbyteArray u = (jbyteArray) env->GetObjectArrayElement(videoBuffer2d, (jsize) 1);
	jbyteArray v = (jbyteArray) env->GetObjectArrayElement(videoBuffer2d, (jsize) 2);
	jbyte* _y = env->GetByteArrayElements(y, 0); // not copy array
	jbyte* _u = env->GetByteArrayElements(u, 0); // not copy array
	jbyte* _v = env->GetByteArrayElements(v, 0); // not copy array

	byte*  output[3] = { (byte*) _y, (byte*) _u, (byte*) _v };
	//
	
	Size      resolution;
	Thickness cropped;
	
	if (mVideoDecoder[channel]->Decode(s.Buffer(), s.BufferLength(), VideoPixelFormat_I420, output, _outputSize, resolution, cropped))
	{
		int32 dstW = resolution.Width() - cropped.Left() - cropped.Right();
		int32 dstH = resolution.Height() - cropped.Top() - cropped.Bottom();
		env->CallVoidMethod(mObject, methods.VideoFrameDecodedListener_OnVideoOneFrameDecoded, channel, 
						dstW, dstH, outputSize, VideoPixelFormat_I420, cropped.Left(), cropped.Top());
	}

	else
	{
		LOGE("decode error: %d", channel);
	}

	
	
	env->ReleaseByteArrayElements(y, _y, 0);
	env->ReleaseByteArrayElements(u, _u, 0);
	env->ReleaseByteArrayElements(v, _v, 0);
	env->DeleteLocalRef(y);
	env->DeleteLocalRef(u);
	env->DeleteLocalRef(v);
	env->DeleteLocalRef(videoBuffer2d);
	
	env->ReleaseIntArrayElements(outputSize, _outputSize, 0); // mode: copy back the content and free the elems buffer
	                                                          // MUST to free the elems buffer, because elems buffer holds
															  // a local reference, which needs to delete
	env->DeleteLocalRef(outputSize);
	
	JNIEnvDeattachThread();
}