×

Discussion Board

Results 1 to 12 of 12
  1. #1
    Nokia Developer Champion
    Join Date
    Dec 2008
    Posts
    2,355

    How to display a part of an Image from Web

    Hi,
    I am trying to display a part of the image. I have an image in web. I can download to c:\\Data\\Images\\ and could also display it on to the screen, but how do I display a part of the image on the screen, as what happens in the MAP. I would like to pass the latitude and longitude to display a part of the image. is there any function for that. i am using LBSSample example where I see that I can pass latitude and longitude to get a part of the google map. In place of google map URL I put _LIT(KGoogleMapURL,"http://abc.com/som/drew.jpg") and could display the image. But do I display a part of the image.

    Please suggest me.

  2. #2
    Nokia Developer Champion
    Join Date
    Jan 2008
    Location
    Moscow, Russia
    Posts
    3,348

    Re: How to display a part of an Image from Web

    Actually for your goals would be better to learn more about using Google Maps API - http://code.google.com/apis/maps/

  3. #3
    Nokia Developer Champion
    Join Date
    Dec 2008
    Posts
    2,355

    Re: How to display a part of an Image from Web

    My goal is not to use the Google MAP rather to display an image. I need to display a part of an Image. any suggessation please.

  4. #4
    Nokia Developer Champion
    Join Date
    Jan 2008
    Location
    Moscow, Russia
    Posts
    3,348

    Re: How to display a part of an Image from Web

    You can use these functions:

    CWindowGc:rawBitmap(const TRect &aDestRect, const CFbsBitmap *aDevice, const TRect &aSourceRect);
    CWindowGc::BitBlt(const TPoint &aDestination, const CFbsBitmap *aBitmap, const TRect &aSource);
    CWindowGc::BitBltMasked(const TPoint &aPoint, const CFbsBitmap *aBitmap, const TRect &aSourceRect, const CFbsBitmap *aMaskBitmap, TBool aInvertMask);

    For getting more details see SDK help.

  5. #5
    Nokia Developer Champion
    Join Date
    Dec 2008
    Posts
    2,355

    Re: How to display a part of an Image from Web

    will it work on BMP images? I need to get a portion of a PNG image.

  6. #6
    Nokia Developer Champion
    Join Date
    Jan 2008
    Location
    Moscow, Russia
    Posts
    3,348

    Re: How to display a part of an Image from Web

    Yes, it will work. How you display image now? Most likely using DrawBitmap() or BitBlt(). So using functions above you can draw only part of original image.

  7. #7
    Nokia Developer Champion
    Join Date
    Dec 2008
    Posts
    2,355

    Re: How to display a part of an Image from Web

    I tried both of this function DrawBitmap() or BitBlt(). But not that much useful for me. I don't want this. Ok let me explain. Let say I have a n image of height = 100, and width =100. how can I display a portion of the Image like, height =(0,0) to (0,50) and width = ( 0,0) to (50,0), where (..) are the co-ordinates.

    Please suggest me something.

  8. #8
    Nokia Developer Champion
    Join Date
    Jan 2008
    Location
    Moscow, Russia
    Posts
    3,348

    Re: How to display a part of an Image from Web

    Can you show how you trying to do this?

  9. #9
    Nokia Developer Champion
    Join Date
    Dec 2008
    Posts
    2,355

    Re: How to display a part of an Image from Web

    Appui.cpp The code below is called first
    HTML Code:
    case ECommand1:
    			{
    			
    			iAppView->GetGPSInfoL();
    			}
    			break;
    appview.cpp
    HTML Code:
    void CLBSSampleAppView::GetGPSInfoL()
    	    {
    	    // create CGpsPositionRequest object and put it into cleanup stack;
    	    // pass application name as argument
    	    CGpsPositionRequest* request = CGpsPositionRequest::NewL(
    	        _L("LBS_0xEA962394"));
    
    	    CleanupStack::PushL( request );
    	    // get current location (this operation can be long up to 30 seconds);
    	    // progress dialog is shown to user during this time
    	    TBool result = request->FetchCurrentPostionL(latitude, longitude);
    
    	    // delete request object
    	    CleanupStack::PopAndDestroy(request);
    
    	    if(result)
    	    	{
    				// Setup a file in the filesystem to download the map
    	    	SetupFileDownload();
    	    	// send HtTp request to download map
    	    	SendHTTPRequestL();
    	    	}
    
    
    	    }
    
    void CLBSSampleAppView::Draw( const TRect& aRect ) const
    	{
    	// Get the standard graphics context
    	CWindowGc& gc = SystemGc();
    
    	// Gets the control's extent
    	TRect drawRect( Rect());
    
    	// Clears the screen
    	gc.Clear( drawRect );
    
    
    	// Display the Map
    	if(iJPG_Reader)
    	 	{
    	 		if(iJPG_Reader->Bitmap())
    	 		{
    	 			if(iJPG_Reader->Bitmap()->Handle())
    	 			{
    	 				gc.DrawBitmap(aRect, iJPG_Reader->Bitmap());
    	 		
    	 			}
    	 		}
    	 	}
    
    	}
    
    void CLBSSampleAppView::SendHTTPRequestL()
    {
    
    
    
    const TInt KMaxFolatLength = 8;
    const TInt KDecimalPos = 5;
    
    TRealFormat format( KMaxFolatLength, KDecimalPos );
    format.iType = KRealFormatFixed | KDoNotUseTriads;
    
    		TBuf8<KDefaultBufferSize> uri8;
    
    		uri8.Append( KGoogleMapURL );
    		//uri8.Append( KGoogleMapKey );
    
    
    
    		HBufC8* longitudeDes = HBufC8::NewLC(257);
    		longitudeDes->Des().Num(longitude,format);
    
    		HBufC8* latitudeDes = HBufC8::NewLC(257);
    		latitudeDes->Des().Num(latitude,format);
    
    
    		TBuf8<KDefaultBufferSize> TempBuffer;
    		TempBuffer.Format(uri8,latitudeDes,longitudeDes);
    
    		CleanupStack::PopAndDestroy(2);
    
    		// Start transaction
    		TRAPD(err, iEngine->IssueHTTPGetL(TempBuffer));
    		// TODO: Error handling
    		if (err)
    		    {
    		    }
    }
    
    // -----------------------------------------------------------------------------
    // CLBSSampleAppView::SetupFileDownload()
    // wset up a file in the filesystem where to download and save the corresponding map
    // -----------------------------------------------------------------------------
    //
    
    void CLBSSampleAppView::SetupFileDownload()
    	{
    
    
    	_LIT(KXMLFilePath, "c:\\Data\\Images\\");
    	 TFileName iCurrentFileName;
    	 iCurrentFileName.Append(KXMLFilePath);
    	iCurrentFileName.Append(_L("drew.jpg"));
    	TInt err=iRLbsImage.Open(CCoeEnv::Static()->FsSession(),iCurrentFileName,EFileWrite);
    
    	if (err==KErrNotFound) // file does not exist - create it
    	{
    
    	err=iRLbsImage.Create(CCoeEnv::Static()->FsSession(),iCurrentFileName,EFileWrite);
    	}
    
    	}
    
    
    	// -----------------------------------------------------------------------------
    	//
    	// 	// Listener from the client engine
    	// -----------------------------------------------------------------------------
    	//
    
    
    
    void CLBSSampleAppView::ClientEvent(const TDesC& aEventDescription)
    	{
    
    	}
    
    
    	// -----------------------------------------------------------------------------
    	//
    	// 	// Listener from the client engine to save map
    	// -----------------------------------------------------------------------------
    	//
    void CLBSSampleAppView::ClientBodyReceived(const TDesC8& aBodyData)
    	{
    
    		TInt aPos=0;
    		iRLbsImage.Seek(ESeekCurrent, aPos);
    		iRLbsImage.Write(aBodyData); //save the file being downloaded
    
    	}
    
    	// -----------------------------------------------------------------------------
    	//
    	// 	// Listener from the client engine saying that map download is completed
    	// -----------------------------------------------------------------------------
    	//
    void CLBSSampleAppView::ClientBodyCompleted()
    	{
    	iRLbsImage.Close();
    //delete	iRLbsImage;
    	SetImage();
    
    
    	}
    
    
    void CLBSSampleAppView::SetImageL()
    	{
    	DrawNow();
    	}
    
    	// -----------------------------------------------------------------------------
    	//
    	// 	// Listener from the CImageReader that creation of the map to be displayed is completed.
    	// -----------------------------------------------------------------------------
    	//
    void CLBSSampleAppView::ImageReadyL(const TInt&  state)
    	{
    	DrawNow();
    	}
    
    
    	// -----------------------------------------------------------------------------
    	//
    	// 	//Start creation of the map to be displayed
    	// -----------------------------------------------------------------------------
    	//
    _LIT(KTxtFileName, "c:\\Data\\Images\\drew.jpg");
    void CLBSSampleAppView::SetImage()
    	{
    	iJPG_Reader = new(ELeave)CImageReader(*this);
    	iJPG_Reader->ConstructL(KTxtFileName);
    
    	}
    HTML Code:
    _LIT(KGoogleMapURL,"http://abc.com/som/image.jpg");
    //global declaration
    I am using LBSSample example http://wiki.forum.nokia.com/index.ph...Api_in_Symbian

    Please suggest me.

  10. #10
    Nokia Developer Champion
    Join Date
    Jan 2008
    Location
    Moscow, Russia
    Posts
    3,348

    Re: How to display a part of an Image from Web

    Code:
    gc.DrawBitmap(aRect, iJPG_Reader->Bitmap());
    So where you are trying to use functions that I've mentioned?

    Try this:
    Code:
    gc.DrawBitmap(aRect, iJPG_Reader->Bitmap(), TRect(TPoint(0,0),TSize(50,50)));

  11. #11
    Nokia Developer Champion
    Join Date
    Dec 2008
    Posts
    2,355

    Re: How to display a part of an Image from Web

    Quote Originally Posted by A.A.M. View Post
    So where you are trying to use functions that I've mentioned?

    Try this:
    Code:
    gc.DrawBitmap(aRect, iJPG_Reader->Bitmap(), TRect(TPoint(0,0),TSize(50,50)));
    i tried this but its not displaying a portion of the image even getting a blank white screen. Rather if I put it in this way
    HTML Code:
    gc.DrawBitmap(TRect(TPoint(35,25), TSize(150,85)), iJPG_Reader->Bitmap());
    the while image displays but the size becomes small.

    please suggest me.

  12. #12
    Nokia Developer Champion
    Join Date
    Dec 2008
    Posts
    2,355

    Re: How to display a part of an Image from Web

    thank you its working now.

Similar Threads

  1. Opening a JPEG Image
    By ummarbhutta in forum Mobile Java Media (Graphics & Sounds)
    Replies: 8
    Last Post: 2007-02-15, 06:34
  2. HELP: Mutable Image to Immutable Image?
    By rj_cybersilver in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2005-03-26, 09:58
  3. Image display
    By zhenwe1 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2003-12-29, 05:18
  4. Game Developement - Display object on a image background
    By kenkwokkam in forum Mobile Java General
    Replies: 0
    Last Post: 2003-02-08, 14:58

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×