GcCollect and GetTotalMemory are added to BitmapEx. These are intended for possible diagnostic use and should not be required in normal use.
Ah, I had forgotten that was there! That Dispose in New1 actually does nothing!I looked into the source of ImageLibEx and I don't understand why I get the OutOfMemory Exception because when the New1() Method is called the old bitmap gets disposed and a new one is created.
BmpEx1.New1(filename) ' creates a new instance of a BitmapEx and calls New1
....
BmpEx1.New1(filename)' creates another new instance of a BitmapEx and calls New1
BmpEx1.New1(filename)
....
BmpEx1.Dispose
AddObject("BmpEx", "BitmapEx")
BmpEx1.New1(filename)' creates another new instance of a BitmapEx and calls New1
Yes, normally you should let the GC do its' job.Am I right that this is normally not a problem (because the GC will handle this)
It's only really a problem for things like (and it's the only example I can think of) Bitmaps where the ratio of unmanaged memory used by the underlying native object is very large in relation to the small amount of managed memory used to encapsulate it for .NET use. Before reusing the same object name the only things other than Bitmap and BitmapEx that I would rooutinely Dispose would be Drawer andDrawerEx that are really GDI Graphics objects.but it's a bad idea for objects that use unmanaged memory or implement IDisposable?
Ah yes, thats the problem :BangHead:. I thought the resulting bitmap has the same size and would be cropped. I changed the test program so that it calculates rectSource and rectDest sizes and positions after the rotation correctly and now it works well.I think that you are overlooking the fact that the bitmap grows when it is rotated
maps.item(5) = AppPath & "\maps\nim1663.jpg"
drawer.New1("form7",False)
mapsrc.New1(600,400,1000,1000)
x = 0
y = 0
mapdst.New1(x,y,x+600,y+600)
drawer.DrawImage(maps.Item(5),mapsrc.Value,mapdst.Value,False)
mapsrc.New1(600,400,1000,1000)
mapdst.New1(x,y,x+600,y+600)
mapdst.New1(x,y,600,600)
mapsrc.New1(0,0,600,600)
mapdst.New1(0,0,600,600)
mapsrc.X=x
mapsrc.Y=y
px = (x_itm - x1 )* zoom * mapwidth /(x2-x1)
py = (y_itm - y1 )* zoom * mapheight /(y2-y1)
drx.New1("Form7",False)
mapdst.New1(0,0,form7.Width,form7.height)
mapsrc.New1(px-center_x/zoom,PY-center_y/zoom,form7.Width/zoom,form7.height/zoom)
drx.DrawImage(mapslist.Item(5),mapsrc.Value,mapdst.Value,False)
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?