B4A Library ScaleImageView - Pan and zoom large images

Caps64

Member
It is true, AND the picture moves in the screen: then now I realize what is the CenterX value, and that this property cannot be used to do what I need in my project, because I dont want that the picture moves in the screen when I swipe on it (I have to use PAN_LIMIT_INSIDE*).
In order to implement a swipe detector, SIV would need at least a Touch event. I tried to link a GestureDetector to the SIV, but it seems that GD eats all events, then as side effect the built in pinch to zoom feature does not work.

* It seems that the default value for PanLimit is PAN_LIMIT_INSIDE (not PAN_LIMIT_CENTER).
 

Rachbob

Member
Licensed User
this is a wonderful Library. but it works just with large image. could this code be modified to support samall and medium image like less than 200 ko for remote BLOB database use ?

thank you
 

agraham

Expert
Licensed User
Longtime User
but it works just with large image
No it doesn't, what makes you think that? It can work with any size image. In particular small images which you have already decoded and have a Bitmap for can be assigned to the Image property and panned and zoomed. Look at the popup help for ScaleImageView.Image.

Note that small images may need a large value of MaxZoom set. The default of 2 is probably a bit low for smaller images.
 
Last edited:

js486dog

Active Member
Licensed User
Longtime User
"agraham"
please is there a way to do transparent polygon (10% ....90%)?

I can create only entire transparent (False) or non transparent (True) polygon with:
B4X:
viewcanvas.DrawPath(Path_bod, Colors.Magenta,True, 2)
 

js486dog

Active Member
Licensed User
Longtime User
I think you mean filled, not transparent.

If you want a transparent colour you can define it using Colours.ARGB.
Thank you very much.
Yes Colors.ARGB is for transparent color:
B4X:
viewcanvas.DrawPath(Path_bod, Colors.ARGB(128,255,127,39),True, 2)
 

js486dog

Active Member
Licensed User
Longtime User
Please "Andrew".
I got a little problem.

CenterX, CenterY is Float
but
SetScaleAndCenterPixels(x and y is Int)

When I read the point position with CenterX, CenterY (as float) and after I would like to find the same position with SetScaleAndCenterPixels (x,y as Int), the result is not accurate.

Please can you change SetScaleAndCenterPixels(x and y as Float) in the source code ?
 

agraham

Expert
Licensed User
Longtime User
Please can you change SetScaleAndCenterPixels(x and y as Float) in the source code ?
There is no point in doing this as pixel values are inherently integer values. What inaccuracy you experiencing? Have you missed
SetScaleAndCenter (scale As Float, x As Float, y As Float, duration As Int)
In general the float values are factors of the image width and height and range from 0 to 1. The pixel values are absolute pixel values. You can transform between the two by mutiplying a float factor value by the image width or height pixel size, or by dividing a pixel value by the image width or height pixel size.
 

js486dog

Active Member
Licensed User
Longtime User
Please look at the attached project.

When you pan map (pic1) - coordinates of center point are calculated in "OnDraw" : ('x y suradnice stredoveho bodu) and displayed in the labels: lbl_yobr, lbl_xobr

When you use Find button (pic2) and you find the same coordinates(wgs) like displayed, there are very innacurate coordinates in the labels: lbl_yobr, lbl_xobr

But try to do disable this line in Sub Button9_Click :

B4X:
'ScaleImageView1.SetScaleAndCenterPixels(ScaleImageView1.Scale,kde_lon_pix, kde_lat_pix, 1)

and coordinates in the labels: lbl_yobr, lbl_xobr are OK.
 

Attachments

  • pic1.jpg
    17.5 KB · Views: 327
  • pic2.jpg
    22.5 KB · Views: 326
  • w_map.zip
    101.3 KB · Views: 328
Last edited:

js486dog

Active Member
Licensed User
Longtime User
I suspect you may have an integer rounding problem as your map is not sufficiently detailed.
I can use the map with 70 zoom.
But why is all OK when I do disable this line in Sub Button9_Click ? :
B4X:
'ScaleImageView1.SetScaleAndCenterPixels(ScaleImageView1.Scale,kde_lon_pix, kde_lat_pix, 1)
 

js486dog

Active Member
Licensed User
Longtime User
Try a map with more pixels. You move the map, suffer the rounding because there aren't enough pixels and the error is reflected in your textbox co-ordinates which are updated when the map is redrawn.
Thank you very much Andrew. Now I understand how it works.
 

agraham

Expert
Licensed User
Longtime User
Version 2.20 of ScaleImageView has the following changes

Added Orientation, DoubleTapZoomDuration, TileBackgroundColor, Recycle and ResetScaleAndCenter.

Internal changes to resolve co-ordinate problems when an app is used as the lower or right app in split screen mode.
 

agraham

Expert
Licensed User
Longtime User
Version 2.30 now has a readable Image property to get the image presently displayed by ScaleImageView. Add this somewhere in the existing demo in the v2.20 archive
B4X:
    Dim b As Bitmap
    b.Initialize3(ScaleImageView1.Image)
    Dim Out As OutputStream
    Out = File.OpenOutput( File.DirRootExternal & "/Download/", "Testxv.jpg", False)
    b.WriteToStream(Out, 90, "JPEG")
    Out.Close
 
Last edited:

GeoT

Active Member
Licensed User
Hello.

I have managed to put these ScaleImageView in the Dominex's SlidingPanels, which are a class. Specifically in its ModeFullScreen format.
Is there a way to capture the Touch event and distinguish it from the SlidingPanels Touch event?
And put some indicator or event as the image of the ScaleImageView is zoomed in?
Would you Agraham want add it to the library?
Would it be feasible?

Regards and thanks.
 
Last edited:

GeoT

Active Member
Licensed User
I want to do as WhatsApp does in its activity to send several images.
Each ScaleImageView contains each image, and the SlidingPanels class changes the display from one image to another.
I want the image to be zoomed in to not be able to change the image. And when it is not, with the horizontal gesture you slide the container panel and its corresponding ScaleImageView.
But that gesture doesn't surface now.

Thanks
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…