how do you edit a large image?

BlitzMax Forums/BlitzMax Programming/how do you edit a large image?

D4NM4N(Posted 2006) [#1]
ive tried canvases but you cant make them bigger than the screen, ive tried buffers but they don exist in max.

so, how does someone perform pixel ops on a large image?!?
Speed isnt an issue as its for rendering not realtime.

isnt there something like:
writepixeltoimage (timage,x,y,argb)

i find it a bit dissapointing if there isnt some way of doing something as 'standard' as this.


tonyg(Posted 2006) [#2]
You can lockimage and then writepixel or even load the image as a pixmap to save the conversion process.


D4NM4N(Posted 2006) [#3]
LOCKIMAGE!

lovely jubly

cheers :)


D4NM4N(Posted 2006) [#4]
errr whats the difference between image & pixmap?


Dreamora(Posted 2006) [#5]
Pixmap: RAM based, pixel data array. Is drawn by copying the data into the backbuffer. Does not support alpha and is significantly slower than images due the way it works.

Image: Texture which is in VRAM (if drawn) and drawn by hardware. supports alpha and blending. can't be changed in realtime, only by lockimage or grabimage. due to beeing a texture, its faster than pixmaps

Depending on hardware, pixmap are 10+ times slower than textures.


D4NM4N(Posted 2006) [#6]
What i am trying to do is re render thumbnails of alpha textures to a white background (basically replace the alpha channel with white)

If pixmaps dont support alpha, what are the functions for (see help for create pixmap) Bit confusing if u ask me :O

One question, is there a way of creating a 2d array of alpha values from a png? if i can do this i can prehaps re-render them by mixing the color.


Fabian.(Posted 2006) [#7]
Does not support alpha
It depends on the pixmap format you use:
PF_I8 and PF_RGB888 and PF_BGR888: without alpha
PF_A8 and PF_RGBA8888 and PF_BGRA8888: with alpha


tonyg(Posted 2006) [#8]
LockImage (and CreatePixmap) return RGBA8888 pixmaps.


D4NM4N(Posted 2006) [#9]
I think i need to work out my rgb funcs unfortunately while ok(ish) with geometery my binary maths suck :P

These functions, i think ive got the return argb right with the shl24 but could someone sheck the others for me?

Function ARGB(R%, G%, B%, A%)
; Local res = B + G * 256 + R * 256 * 256
res=(b Or (g Shl 8) Or (r Shl 16) Or (a Shl 24))

 Return res 
End Function

Function getRed(ARGB)
 ;Local res = RGB / (256 * 256) + 256
 res=(ARGB Shr 16) And $ff
 Return res
End Function

Function getGreen(ARGB)
; Local res = (RGB Mod (256 * 256)) / 256 + 256
 res=(ARGB Shr 8) And $ff
 Return res
End Function

Function getBlue(ARGB)
 ;Local res = (RGB Mod (256 * 256)) Mod 256 + 256
res=ARGB And $ff
 Return res
End Function

Function getAlph(ARGB)
res=(ARGB Shr 24) And $ff '<-----do i need this ff if so whats it for?!?
 Return res
End Function





Grey Alien(Posted 2006) [#10]
you need the $ff to filter out all other bits apart from the byte you are wanting to return (i.e. the byte that you have just shifted). I think when you SHR that 0 bits are brought in from the left so maybe the $ff isn't needed when you shift by 24. There is a rotate bits command in assembly and if you were using that the $ff bitmask would be required.


D4NM4N(Posted 2006) [#11]
ahaa

cheers >:)


Jesse(Posted 2006) [#12]
shouldn't it be the bit wise operator "|" not the logical operator "or"?


Dreamora(Posted 2006) [#13]
Yupp it should.

AND / OR are only binary operators, no bit operators. | and & are the ones to use for bit operations as with C (I wonder why << >> aren't supported instead of shl shr ^^)


Jesse(Posted 2006) [#14]
I don't want to understand that. I dont want to understand that. I dont want to understand that....... too late. :-).