This is weird.
I can rotate the bitmap ok, but the actual container doesn't change.
I want to rotate a bitmap that's in portrait mode, to landscape, and save it as that landscape size. It appears that when I rotate the bitmap, and save it, it's saved as the horizontal picture, inside a portrait container, much of which is black above and below the rotated pic. So, in what's saved, I end up with the rotated image the width of which is the width of the portrait container and the height is only a small portion of the portrait picture, but the rotated picture is in the correct proportions.
I've tried several of the things I found on the site, but still come up with the same result. Here's where I am now:
I don't know what to do next. This SHOULD work, shouldn't it? If not, where'd I go wrong here?
I can rotate the bitmap ok, but the actual container doesn't change.
I want to rotate a bitmap that's in portrait mode, to landscape, and save it as that landscape size. It appears that when I rotate the bitmap, and save it, it's saved as the horizontal picture, inside a portrait container, much of which is black above and below the rotated pic. So, in what's saved, I end up with the rotated image the width of which is the width of the portrait container and the height is only a small portion of the portrait picture, but the rotated picture is in the correct proportions.
I've tried several of the things I found on the site, but still come up with the same result. Here's where I am now:
B4X:
Sub RotateView(v As View, bmp As Bitmap, degrees As Float)
Dim c As Canvas
Dim R As Rect
'Dim imgratio As Long
Dim hh2,hw2 As Int
hh2 = v.Height
hw2 = v.Width
c.Initialize(v)
R.Initialize(0,0,v.Height,v.Width)
c.DrawRect(R,Colors.transparent,True,0)
c.DrawBitmapRotated(bmp,Null,R,degrees)
v.SetBackgroundImage(c.Bitmap)
v.Invalidate
Dim out As OutputStream
Dim rfile As String
rfile = "rotatetemp.jpg"
out = File.OpenOutput(File.DirInternal, rfile, False)
c.Bitmap.WriteToStream(out, 100, "JPEG")
out.Close
ResizePreviewPhoto(File.DirInternal,rfile)
SetPreviewLayout
End Sub
Sub SetPreviewLayout '(bwidth As Int, bheight As Int)
'ivPreview.Height = bwidth
'ivPreview.Width = bheight
ivPreview.Top = (btnShoot.Top / 2) - (ivPreview.Height / 2)
ivPreview.Left = iv.Left + ((iv.Width / 2) - (ivPreview.Width / 2) )
DoEvents
btnRotateLeft.Top = (ivPreview.Top + ivPreview.Height / 2) - btnRotateLeft.Height / 2
btnRotateRight.Top = btnRotateLeft.Top
btnRotateLeft.Left = ivPreview.Left - btnRotateLeft.Width - 20dip
btnRotateRight.Left = ivPreview.Left + ivPreview.Width + 20dip
End Sub
Sub ResizePreviewPhoto (Dir As String, FileName As String)
Dim bm2 As Bitmap
bm2.InitializeSample(Dir, FileName, 100dip, 100dip)
hip = bm2.Height
wip = bm2.Width
ivPreview.Bitmap = bm2
If hip = wip Then 'It's Square
ivPreview.Height = 100dip
ivPreview.Width = 100dip
Else If hip > wip Then 'It's Portrait
imageratio = (wip / hip)
ivPreview.Height = 100dip
ivPreview.Width = ivPreview.Height * imageratio '- 20dip
Else 'It's Landscape
imageratio = (hip / wip)
ivPreview.Width = 100dip 'pnl.Width '- 40dip
ivPreview.Height = ivPreview.Width * imageratio
End If
End Sub
I don't know what to do next. This SHOULD work, shouldn't it? If not, where'd I go wrong here?