Android Question TouchImageView - ScaleSrcRectToDestRect with bitmaps

brampie66

Member
Licensed User
Longtime User
Hi,

I seem to be facing a very strange problem.

I'm using TouchImageView as sort of a gallery (it loops over jpegs that are pages of a building plan).
Everytime the user goes to the next page I load a new jpeg.
this works,
code is something like
bm = LoadBitmap(File.DirRootExternal,"/documents/" & cid & ".jpg")
TouchImageView1.SetBitmap(bm)
TouchImageView1.ScaleSrcRectToDestRect(SourceImageRect, TouchImageViewRect, "CENTER")

This works ok, however I also need to draw text on those bitmaps so I use:
imgBitmap.InitializeMutable(bm.Width,bm.Height)
MyCanvas.Initialize2(imgBitmap)
rect.Initialize(0,0,imgBitmap.Width,imgBitmap.Height)
MyCanvas.DrawBitmap(bm,Null,rect)
TouchImageView1.SetBitmap(imgBitmap)
TouchImageView1.ScaleSrcRectToDestRect(SourceImageRect, TouchImageViewRect, "CENTER")

This doesn't work, the image doesn't get centered/scaled like it should, I double checked everyhing and width and height are the same.

I can fix the problem by saving and opening the file:
Dim out As OutputStream
out = File.OpenOutput(File.DirRootExternal,"documents/bmp.jpg",False) imgBitmap.WriteToStream(out,100,"JPEG")
out.Close
imgBitmap = LoadBitmap(File.DirRootExternal,"documents/bmp.jpg")

So it seems
TouchImageView1.ScaleSrcRectToDestRect(SourceImageRect, TouchImageViewRect, "CENTER")
only works with a bitmap that is loaded from a file, not one created in the app.

I don't understand what the difference is between a bitmap loaded from a file and one created.

Anyone has some idea about this ?
 
Top