Imageview strange behaviour

copiloto

Member
Licensed User
Longtime User
Hi everybody,

I have extracted a piece of code from forum to manipulate pictures or images. However, it shows a strange behaviour (or I can't see my error)...

The code:

Dim c As Canvas
Dim b As Bitmap
Dim i As ImageView

b.Initialize(File.DirRootExternal, "picture.jpg")
i.Initialize("")
Activity.AddView( i, 0, 0, 4000,3000)
c.Initialize(i)

--It seems that "b" bitmap hasn't anything to be with the rest of code, but...

If "i" dimensions are big (like the example), i get a imageview error: "imageview has stopped" and program closes. But not in case of small dimensions, like 1500x1000.

First, I thought that it was a imageview memory problem. However, if I delete b.initialize(File.Dir........) line, now none error shows and the program runs fine...

What could I do to avoid deleting this line and enabling adding big views?

Erel, could it be that i use ICS instead of Gingerbread?

Thanks!
 

copiloto

Member
Licensed User
Longtime User
Hi Erel,

I checked the logs and yes, it shows a out of memory message.

My project is easy: charging a internal (from dirroot) photo into a view. Then, use Canvas, to play with the picture. Finally, save it to phone memory.

But first of all, I would need to load the original picture without losing quality into a view, so, I suppose the view should be resized as the picture size,

Please, a little help would be appreciated.

Best regards.
 
Upvote 0

copiloto

Member
Licensed User
Longtime User
Erel, all pictures are 3264x2448 pixels.

Some time ago, I worked with this code using Gingerbread. I have recovered it and it's exactly the same that in the first post. It worked fine using that OS, and using the same resolution: before had a SG2 and now a SG3, but photos are always taken in max resolution (about 3 Mb per photo).

Dim c As Canvas
Dim b As Bitmap
Dim i As ImageView
Dim brect As Rect


b.Initialize(File.DirRootExternal, "picture1.jpg")

i.Initialize("")
Activity.AddView( i, 0, 0, b.Width, b.Height)
i.Visible=False

brect.Initialize(0,0,b.Width, b.Height)

c.Initialize(i)

c.DrawColor(Colors.White)
c.DrawBitmap(b, brect, brect)


please, any idea?

Thanks you Erel

Best regards.
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
You can also save a lot of memory by reducing the colors and removing the alpha channel. It does not change a lot the visual quality (personnaly, I can't see the difference on most images). Drawback: your images cannot be transparent.
To do this, use the BitmapPlus library provided with the CustomGallery class. There's a function named ReduceColors.
 
Upvote 0

copiloto

Member
Licensed User
Longtime User
Thanks you Informatix for your support.

Still I don't know that libray (fortunately, there are so much :) ), but seems another solution to my code. You say that the two images are practically equals... good news!

I'll test Erel and you code and report here my results.

Best regards friend!
 
Upvote 0
Top