B4J Question Blurry ImageView after Rotation

xulihang

Well-Known Member
Licensed User
Longtime User
I am trying to rotate an ImageView with the following code:

B4X:
Dim view As B4XView = ImageView2
view.Rotation = -10

But the image becomes blurry. Are there any ideas on how to solve this?

I've also attached a test project.
 

Attachments

  • ViewRotation.zip
    2.2 KB · Views: 37

teddybear

Well-Known Member
Licensed User
Try this code

B4X:
    ImageView2.As(JavaObject).RunMethod("setSmooth",Array(False))
    ImageView2.SetImage(Label1.Snapshot)
    Dim view As B4XView = ImageView2
    view.Rotation = -10
 
Upvote 0

xulihang

Well-Known Member
Licensed User
Longtime User
1756361495728.png


It is still blurry.

B4X:
    Dim jo As JavaObject = ImageView2
    jo.RunMethod("setSmooth",Array(False))
    ImageView1.SetImage(Label1.Snapshot)
    ImageView2.SetImage(Label1.Snapshot)
    Dim view As B4XView = ImageView2
    view.Rotation = -10
 
Upvote 0

xulihang

Well-Known Member
Licensed User
Longtime User
I think it is inevitable that the text will become blurry after rotation because the image is resampled. The image has to be upscaled before rotation to solve the blurry problem.
 
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
... because the image is resampled.

But also with a truly horizontal or vertical line the character edge can be a transition between "fully on" and "fully off" pixels. If you want sloped text lines then you either retain fully on/off pixels and create a "stepped" effect, or you use partially coloured (antialiased) pixels which is what I think you are describibg as "blurry". Surely sloped text will always be less sharp overall than horizontal text.
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
Got to be honest they don't look blurry to me after running your example. Maybe it's the display - at 4K they are just as sharp, rotated or not.

you could try (for imageview)
B4X:
    Dim view As B4XView = ImageView2
    view.As(JavaObject).RunMethod("setSmooth",Array(False))
    view.Rotation = -15
to see if it improves the image
 
Last edited:
Upvote 0

xulihang

Well-Known Member
Licensed User
Longtime User
Rotate the label and then take the snapshot instead of directly rotating the imageview. This seems to be the solution for me.

B4X:
Dim lbl As B4XView = Label2
lbl.Rotation = -10
ImageView2.SetImage(Label2.Snapshot)
 
Upvote 0
Top