Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

"Rubber-band" rectangle

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-09-2010, 10:02 PM
Basic4ppc Expert
 
Join Date: May 2008
Location: Berkshire, UK
Posts: 810
Awards Showcase
Beta Tester 
Total Awards: 1
Default "Rubber-band" rectangle

I think that I can see how to elaborate Klaus's "MoveRect" example program to draw a rectangle that the user can drag to cover any part of the screen. (The sort of thing often used to use to specify an area to which to zoom; which is my intended purpose!)

But since this is a common function I thought I'd ask whether anyone has already published such a sample here?

Mike.
Reply With Quote
  #2 (permalink)  
Old 04-10-2010, 06:41 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 4,463
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

Hi Mike,

Attached you'll find an example of zooming a bitmap with a selectable "Rubber-band" rectangle.
The program is based on the ShowZoomBitmap program from the Graphics Tutorial.
You can:
- zoom to a given, user defined, zoom factor 0.05 to 5
- zoom to 100% 1 screen pixel = 1 image pixel
- zoom to make the image width fit the screen width
- zoom to make the image height fit the screen height
- zoom to a "Rubber-band" rectangle

Best regards.
Attached Images
File Type: jpg ShowZoomBitmap1.jpg (23.1 KB, 12 views)
File Type: jpg ShowZoomBitmap2.jpg (20.5 KB, 9 views)
__________________
Klaus
Switzerland

Beginner's Guide / User's Guide

Last edited by klaus : 04-10-2010 at 06:54 PM.
Reply With Quote
  #3 (permalink)  
Old 04-10-2010, 07:03 PM
Basic4ppc Expert
 
Join Date: May 2008
Location: Berkshire, UK
Posts: 810
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Quote:
Originally Posted by klaus View Post
Attached you'll find an example of zooming a bitmap with a selectable "Rubber-band" rectangle. ...
Thanks Klaus, I shall study that. (I'm not sure that my usage will involve any bitmap.)

Just to show I did not sit back waiting, attached is a version of MoveRect.sbp that does what I meant. It uses beta-version features.

Mike.
Attached Files
File Type: sbp RubberRect.sbp (2.5 KB, 12 views)
Reply With Quote
  #4 (permalink)  
Old 04-11-2010, 09:26 AM
Basic4ppc Expert
 
Join Date: May 2008
Location: Berkshire, UK
Posts: 810
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Quote:
Originally Posted by klaus View Post
- zoom to a "Rubber-band" rectangle
Hi Klaus, I have started to cherry-pick the portions that I want from that useful program.

Since I am effectively showing vector graphics (actually GPS tracks) I don't have a bitmap to zoom for-real; what I will be doing is drawing a fresh bitmap.

So I am not sure whether I really need scroll-bars at all. But for now I have left them in. But I initially got an error at line:
Code:
  ' zoome image width smaller than the screen widths
 ScrollX.Value=0        ' ScrollX.Value, ImageX and rectSrc.X = 0
Fortunately I have now found the problem (a simple typo; 'twas ever thus!).

I am going to have to invent some scaling to latitude and longitude, since I do not have an image with real pixels.

Mike.

Last edited by mjcoon : 04-11-2010 at 10:08 AM.
Reply With Quote
  #5 (permalink)  
Old 04-11-2010, 11:21 AM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 4,463
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

The error you got happened with very small images, in that case it could happen that even Scroll.Maximum became negative and if the Scroll.Minimum value is bigger than Scroll.Maximum then Scroll.Minimum is set to Scroll.Maximum.

I hadn't tested the program with small images.

Attached an updated version, 6.90 beta version.

Quote:
I don't have a bitmap to zoom for-real; what I will be doing is drawing a fresh bitmap.
I don't really understand what you do mean with fresh bitmap?

In any case you have a bitmap with a given size and a given scale.
The bitmap could be an empty one or a background map. I'm shure that you will need scrolling and zooming.

You have 2 choices for the zooming:
- zoom the whole bitmap and extract the desired part and copy it to the form.
- extract the desired part from the bitmap, zoom it and copy it to the form

The attached program uses the 2nd method.
For your application I would suggest you to use the first method, it is more efficient if you want to scroll the image. The ZoomScaledImage program from the Graphics tutorial and the ScaledMaps program both use the first method.

Best regards.
__________________
Klaus
Switzerland

Beginner's Guide / User's Guide
Reply With Quote
  #6 (permalink)  
Old 04-11-2010, 11:44 AM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 4,463
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

Attached you'll find a program ZoomScaledImage with the first method, a 6.90 version.
But it doesn't have, yet, the "Rubberband" rectangle zooming.
It is an evolution of the DrawOnScaledImage program from the Graphics tutorial.

Best regards.
__________________
Klaus
Switzerland

Beginner's Guide / User's Guide
Reply With Quote
  #7 (permalink)  
Old 04-11-2010, 04:07 PM
Basic4ppc Expert
 
Join Date: May 2008
Location: Berkshire, UK
Posts: 810
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Quote:
Originally Posted by klaus View Post
I don't really understand what you do mean with fresh bitmap?
Thanks again Klaus (and for subsequent message).

What I'm doing is more like a drawing program, in that, at least to start with I won't have a background image. (We have a terminology problem; of course we are always drawing pixels on the screen. But in a drawing program a zoomed image is not derived from the pixels of an earlier bitmap but is re-drawn on a fresh bitmap.)

BTW on my old Psion I had (still have) an amazingly capable drawing program that came with the attached demo drawing. Zooming took only a fraction of a second.

I'm sure there is stuff about drawing programs too in this forum.

Best regards, Mike.
Attached Images
File Type: jpg TRACTION.jpg (19.6 KB, 14 views)
Reply With Quote
  #8 (permalink)  
Old 04-18-2010, 10:08 PM
Basic4ppc Expert
 
Join Date: May 2008
Location: Berkshire, UK
Posts: 810
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Hi All (and especially Klaus)...

My program is progressing and I have got round to trying it compiled for the device. I can briefly see my map shown on the foreground (my code derives, as I said earlier, from Klaus's) but the painted part of the screen turns black and what I have drawn is invisible. Whereas on the desktop, either under IDE or compiled, what I draw is shown against a grey background (probably the 220,220,220 that is the default form colour).

So where does the black-out come from? [Cracked it; had not properly altered Klaus's code. Don't understand difference between desktop and device, though...]

Mike.

Last edited by mjcoon : 04-18-2010 at 10:27 PM. Reason: Solved problem; my fault!
Reply With Quote
  #9 (permalink)  
Old 04-23-2010, 08:51 AM
Basic4ppc Expert
 
Join Date: May 2008
Location: Berkshire, UK
Posts: 810
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Klaus's rubber-band zoom for images is simple and fast. But it is not "WYSIWYG" in the sense that you can draw a rectangle of any aspect ratio and then rules are applied to adjust the rectangle to fit the screen when zoomed.

But because I am examining data (GPS tracks) I want to display an accurate rectangle to show exactly what will appear when zoomed. And to adjust the rectangle accordingly.

Thus my rectangle manipulation is more like a drawing in which the sides or corners can be "picked up" and moved about, or the rectangle moved bodily. (Just like the IDE Designer.)

Except that the aspect ratio remains fixed. Thus if you move a side the adjacent sides also move. If you move a corner then either of the adjacent sides stay with the pointer but not necessarily the corner itself.

If anyone wants to use these features in an open-source project please let me know and I'll extract the code from my module. But it will take some work, so don't ask if you just want to play with it! N.B. There may still be flaws. A very small rectangle cannot have an accurate aspect ratio!

Mike.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Catching the "Shift", "right" & "left" keys linum Questions (Windows Mobile) 3 08-21-2009 01:22 PM
calling the device's "Programs" or "settings" screens karmba_a Questions (Windows Mobile) 3 03-15-2009 05:41 PM
Intelectual copyright for the UK TV game show "The colour of money" on a pocket PC ;- taximania Chit Chat 0 02-21-2009 07:40 PM
"AddEvent" and "buttonUp/buttonDown" Byak@ Questions (Windows Mobile) 12 09-10-2008 03:04 PM
calling the device's "Programs" or "settings" screens HarleyM Questions (Windows Mobile) 0 12-05-2007 02:59 AM


All times are GMT. The time now is 04:47 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0