Android Question picture degradation during rotation

DALB

Active Member
Licensed User
Hello everyone,
protect yourself face to the tiny virus...not in your computer !!

Here is a problem of degradation of the pictures during their rotations in an imageView.
The code I use is the following one:

picture rotation:
sub rotation

dir=File.DirRootExternal & "/imgBooks"
    filename ="id" & lblId.Text & "_img" & rd & ".jpeg"

    bm.Initialize(dir,filename)
    bm=bm.Rotate(sens)
  
    bm2 =bm
    Dim out As OutputStream
    out = File.OpenOutput(dir, filename, False)
    bm2.WriteToStream(out, 100, "JPEG")
    out.Close
'----------------------
Dim a As Double
Wi = bm.width'150
Hi = bm.height'80
Wv=imv1.Width'100
Hv=imv1.height'100

rw=Wv/Wi'100/150=0.666 --> a =0.666
rh=Hv/Hi'100/80=1.25

If rw>rh Then a=rh Else a=rw'rapport des hauteur et largeur
imv1.Bitmap = LoadBitmapResize(dir, filename, a*Wi, a*Hi, True)
imv1.Gravity = Gravity.CENTER

end sub
imv1 is an imageView
bm is a bitMap

I created a button for the picture rotation.
But after each rotation, the picture loses some pixels...they become gray.
Is it due to the calculation of the internal matrix of rotation or do have I some code to add for keeping the complete quality to the picture ?

When you'll have a moment..thanks much !
 

themr23

Member
Licensed User
Maintain a copy of the loaded bitmap or reload each time.
Use it for every rotation.
You'll never completely preserve the original except at multiples of 90 degrees and if the same height/width is displayed.
 

DALB

Active Member
Licensed User
thanks themr23, I'll try this in a few moment and come back to reply.
 

DALB

Active Member
Licensed User
The code of Colin works well HERE , it's like your idea.
 

DALB

Active Member
Licensed User
With JPEG, I lose quality, but with PNG, I keep it !!! Why ??? Is it due to the algorithm of each one ?

Just a question for understanding how this works !
 

DALB

Active Member
Licensed User
Ah Ok, thanks !
 
Top