Low quality of bitmapdata objects

FJS

Active Member
Licensed User
Longtime User
Good afternoon,

I have a problem with the quality of bitmap objects, even with the new issue 2.71 this situation doesnt change.

I use gv. (as gameview) to made a tiny game (45 gv. elements, I am not sure whether it is too much or not) and one layout I have several images (I define these images from designer) and several bitmapdata which are defined in the code:


I load the the bitmapdata like following way:

Dim a as bitmapdata
Dim b as imageview

In both case I use the following sentence to load the picture (not on the designer, but on the code ):

a.Bitmap=LoadBitmap(File.DirAssets,"examplea.png")
b.Bitmap=LoadBitmap(File.DirAssets,"exampleb.png")

But when run the app in the movilphone, I find "b" objets have a good quality, but the "a" objets have a very poor quality, however with the previus issue of program, it didnot happend (with 2.52)

I have found any coments in logs, but there is not any...

Please could you tell me any clue?, I tried write LoadBitmapSample in one object, but it didnt work :( (maybedo i need to load everything like this way?)

Could you help me?
Here after there is a picture, the orange botton are image objets (they have the right quality) and in the left there is a bitmapdata object (with poor quality)
Thank you very much for your support
 

Attachments

  • Screenshot.jpg
    Screenshot.jpg
    17.2 KB · Views: 236
Last edited:

FJS

Active Member
Licensed User
Longtime User
Could I sent you part of the code to you? (which is your email adress?)
Sorry, but this app is a part of a project with more people

Do you need further information?, I thought my previous details were enough:confused:

thank you for your support like always
 
Last edited:
Upvote 0

FJS

Active Member
Licensed User
Longtime User
Good morning,

Yes, it looks great. I checked it and I didnt find anything about those messages. I couldnt find any in green letters and nether in black letters (I unpush the filter, to find more information, but I couldnt find any)
But in any case How can i do to solve not depending on the phone??
I have a HTC desire X. What do you think is the problem? How can i fix it?
I proved with nexus 4 and the result is different, the quality is like your picture. However in my transformer prime (10"), the situation is the same, low quality for bitmapdata objects and very good quality for imageview objects.
this point depends on the phone or depends on the pc??

I am a litte bit missing...

Thank you for your help
 
Last edited:
Upvote 0

FJS

Active Member
Licensed User
Longtime User
With LoadBitmapSample the situation is the same...:sign0148:

But when you say with designer, do you mean inicializating of the bitmapdata on the designer scripts?, I prefer use the normal code... (it is easier for me)

Any other clue?, do you think the density of pixels is important??

Thank you for your support
 
Upvote 0

FJS

Active Member
Licensed User
Longtime User
Erel, please, I need your help to try to fix this issue.

Yes, the result is the same, you can see it on the sent file (by email)

I think about the problem from diffrent point of views:
- The way to resizing of the bitmapdata. When i use the following sentency "tittle.DestRect.Initialize(aleft, atop, aright, abotton)", each value has to be integer, and I check the resizing is not softly in my phone and nether in my table. Maybe that is a clue
- The way to load the information, when the activity starts

What do you say?

As you can imagine, I would like to have the best quality independently on the phone...

Thank you very much for your support
 
Last edited:
Upvote 0

FJS

Active Member
Licensed User
Longtime User
Please try to create a small and simple example with only this image.


Good morning,

I have just to send you a small project with the same results, I hope this proof can give you a clue to try to fix the problem.
As you can see in the previous jpg the huge difference appears when there is any curve.

Thank you for your help and support

Best regards
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4X:
x=Activity.Width/100.000
   y=Activity.Height/100.000
   picture1.Bitmap=LoadBitmapSample(File.DirAssets,"questionbotton_110x130.png",Activity.Width,Activity.Height)
   a=0.23
   picture1.DestRect.Initialize(1*x, 50*x, 1*x+110*x*a, 50*x+130*x*a)
   
   picture2.Delete=False
   picture2.Bitmap=LoadBitmapSample(File.DirAssets,"score_330x110.png",Activity.Width,Activity.Height)
   a=0.23
   picture2.DestRect.Initialize((24.000*x), (50.000*x), (24.000*x+330.000*x*a), (50.000*x+110.000*x*a))
I'm not sure that I understand the above code. Looks incorrect to me.

Note that you can use %x or %y:
50%x (instead of 50 * x).

DestRect size is different than the size you use when you load the bitmap. This will cause distortions.
 
Upvote 0

FJS

Active Member
Licensed User
Longtime User
Good afternoon Erel;

In the next code:

------------------------------------------------------------------------------------------------------------
gv.Initialize("gv")
Activity.AddView(gv, 0, 0, 100%x, 100%y)

gv.BitmapsData.Add(picture1)
gv.BitmapsData.Add(picture2)


Activity.LoadLayout("testpictures")

x=Activity.Width/100.000
y=Activity.Height/100.000

imageview1.Visible=True
a=0.23
imageview1.Width=110*x*a
imageview1.Height=130*x*a
imageview1.Left=1*x
imageview1.Top=20*x

imageview2.Visible=True
a=0.23
imageview2.Width=330*x*a
imageview2.Height=110*x*a
imageview2.Top=20*x
imageview2.Left=24*x

picture1.Delete=False
a=0.23
picture1.Bitmap=LoadBitmapSample(File.DirAssets,"questionbotton_110x130.png",110*1.84,130*1.84)

picture1.DestRect.Initialize(1*x, 50*x, 1*x+110*1.84, 50*x+130*1.84)

picture2.Delete=False
picture2.Bitmap=LoadBitmapSample(File.DirAssets,"score_330x110.png",Activity.Width,Activity.Height)
a=0.23
picture2.DestRect.Initialize((24.000*x), (50.000*x), (24.000*x+330.000*x*a), (50.000*x+110.000*x*a))


'gv.Invalidate

--------------------------------------------------------------------------

I can not understand what happend... why with the imageview object, I can load the image and then resize it, with a great results. However with the bitmapdata, the object seems that it doesnt have enough density of colour and pixers.. and the quality is poor, even with your sugestion..

Sorry for ask you again, but I think this situation affects on several phones and tables.
I can not use imagenview all time, because I want to use the aceleration with the game, so I want to use the bitmapdata as you explain in other foro.

Thank you for your aswer

Best regards
 
Upvote 0

FJS

Active Member
Licensed User
Longtime User
First of all, thank you for your suggestions,

But in any case, the root cause is simple, I design the png, thinking about the table (my table), but I need design thinking about the several sizes regading all the spectrum of possibilities. In other word, first design the png files, and then I need to generate the code to adapt the app to all the possible sizes (my phone, and the rest of unnumerable sizes). For my point of view that is very usual, in fact I use the same phylosophy with the imageview object, and as you know the results are great (very good quality), and it doesnt depend on the size. However the bitmapdata object dont work fine or at least, when you change a little bit its size it doesnt look as well as imageview objects.

Why the behaviour of the bitmapdata cant be like imageview?
My case is the only case in the forum?, this situation occurs with HTC desire and transformer prime table, but not with sansung S3 or nexus 4...

Please, could you show us different ways to resizing bitmapdata objects with good quality?
Thank you as always
 
Last edited:
Upvote 0

FJS

Active Member
Licensed User
Longtime User
I am going to check it again,

But can I create and delete imageview from the code as I can do with bitmapdata??
It is not too hard use imageview objects?
Do you recommend use imageview objects instead of bitmapadata objects?

Many thanks for your help
 
Last edited:
Upvote 0

FJS

Active Member
Licensed User
Longtime User
Please, have a look at the picture. it is from my tablet 10", and the quality of the asteroids are poor for this size.

If you compare with the original one, the resizing of the bitmapdata is lower than imageview objects (as you can see from my example which I sent you several days before).

Maybe, an improvement of the internal proccess resizing could be a good option in order to have the same quality with imageview and bitmapdata as well.
From my humble point of view, I think the quality is a huge point to take into account to develope our apps with basic4android, if B4A give a great quality (like imageview object offers), many more developers will decide to use it, because is simpler than other software.

Thank you for your time
 

Attachments

  • test001.jpg
    test001.jpg
    57.9 KB · Views: 176
Last edited:
Upvote 0

Informatix

Expert
Licensed User
Longtime User
You should try to load your bitmaps with the LoadScaledBitmap function of the AS_ImageUtils class of the Accelerated Surface library. This function resizes exactly the bitmap to the needed dimensions, not roughly as other methods (including LoadBitmapSample). Thus what you get on screen is exactly what you loaded.
 
Upvote 0
Top