Resizing Pixmaps

BlitzMax Forums/BlitzMax Beginners Area/Resizing Pixmaps

Marcell(Posted 2014) [#1]
The following gives EXCEPTION_ACCESS_VIOLATION
Graphics 200,200

Global picture:TPixmap = CreatePixmap(1024,768,PF_RGBA8888,4)
picture = ResizePixmap(picture,40000,40000) 

End


...the following doesn't:
Graphics 200,200

Global picture:TPixmap = CreatePixmap(1024,768,PF_RGBA8888,4)
picture = ResizePixmap(picture,5000,5000) 

End


...and the following doesn't either:
Graphics 200,200

Global picture:TPixmap = CreatePixmap(1024,768,PF_RGBA8888,4)
picture = CreatePixmap(5000,5000,PF_RGBA8888,4)
picture = CreatePixmap(40000,40000,PF_RGBA8888,4)

End


I would like to resize the pixmap in my program.

This is beginner question, but do I waste memory if I use CreatePixmap multiple times for the same TPixmap variable instead of using ResizePixmap?

If I do waste memory by this way, is there anyway to free the memory allocated for a Pixmap?


Jesse(Posted 2014) [#2]
you are creating a 1.5GB+ pixmap! I think exceeding Malloc limit for a 32bit computer language is going to be one of the many problems you will encounter. I suggest you rethink your strategy/logic.


grable(Posted 2014) [#3]
And as a side note.. that 40000*40000*4 will overflow a 32bit signed integer anyway, that it happens to be roughly 2GB is just luck ;)

If you really need that much, you should look into memory mapping and dealing with pointers manually.


Jesse(Posted 2014) [#4]
I just realized that you are creating a 6GB+ Pixmap. way beyond a 32bit computer language and the limits of memory segment allocation for such a language in it's original state.


Marcell(Posted 2014) [#5]
This was just example. :-)

Yes, 40000 x 40000 is unreasonable big. I was just wondering, why the program allowed to create 40000 x 40000 pixmap, but not resize to it.

Edit: To be more precise: I was excepting some exception because Resize caused exception. (I have 64-bit OS)


Jesse(Posted 2014) [#6]
I doubt it's actually creating it. It has to be tested to see if it is actually creating it that size. I suspect there is an error that is not being caught while processing the 40K*40K*4 multiplication.

Local a% = 40000*40000*4
Print a

this code prints:
2105032704
instead of the:
6400000000
that it supposed to due to the 32bit signed integer limit.


Marcell(Posted 2014) [#7]
Yes I doubt it too. I don't really need 40000 x 40000 pixmap, I was just making quick test code. 32-bit signed integer's max limit must be the limit.


Jesse(Posted 2014) [#8]
most data buffers limit to 2GB in 32bit operating system but there are ways to go around that limit, as grable mentioned.


Marcell(Posted 2014) [#9]
In my program I would like to let the user to set the pixmap size. This is why I quickly made a test program to test to create/resize pixmap. The program should survive from any input user gives.

It seems that the legal pixmap buffer size in bytes is less than 2GB (with ResizePixmap).

Anyway in my program it may be safest to set some reasonable limit for the user.


zoqfotpik(Posted 2014) [#10]
!

40000,40000


There's your problem right there.