Modules laying around?

Jimmy

Active Member
Joined
Jan 2, 2020
Does anyone have the dimage module by Chris? I lost my copy and would love to have a quick lookk how it was made.

Please if anyone still got the dImage module, the #2 module)in the list here :
 
Last edited:

Jimmy

Active Member
Joined
Jan 2, 2020
I still haven't found the module :( I'm really curious how it is coded.
 

Jimmy

Active Member
Joined
Jan 2, 2020
@Phil7 He ment this:


Second in this list which is linked in the page at the bottom:

Yes exactly, but the link is dead and the web contains no copies anywhere, I've even checked Internet Archive if they happen to save the webpage but no luck.

A Gerry Quinn seem to have it at least. Is he still around here?


chrisc2977
(Posted 2017) [#1]
Dimage is a module that adds some additional functionality to images. Its main feature is being able to access an images argb values and change them.
It should work for Html, Desktop(glfw), ios and android

I got fed up with having to use drawimage / readpixel to return the rgb values of an image. Also it did not work well with alpha.
Hence my Dimage module.

Basic Use (sudo code):
format_code('Import dimage
Global MyImage:Dimage
MyImage = LoadDimage("myimage.png") 'Has to be in OnCreate()
Local argb:Int[] = MyImage.GetArgb() 'Has to be in either OnRender() or OnUpdate()')

Please see the link below fore more details and download
http://www.code33.co.uk/monkey-modules/dimage/

Would like to hear thoughts :)"
 

SLotman

Active Member
Joined
Jul 3, 2017
I looked around, but even "the web archive" doesn't have a backup of his website :(

But looking for Gerry Quinn, I ended up finding this piece of code. I just tested it, and it works on desktop and HTML5. Probably on all targets too.

I know it's not exactly what you wanted - but it is half way there ;)
 

Gerry Quinn

Active Member
Joined
Jun 24, 2017
I just replied to Mike - I hadn't noticed the thread but I don't recognise the code. I remember writing some code sometime to get the alpha of a loaded image, so GetARGB wouldn't be a stretch to write....

Hmm, I found this in a project and I don't know if it is even tested or not, but it seems I'm getting the alpha (mask) by painting the image in black over a white background, and negating one of the RGB channels of the result. Seems workable.


' Call during render
' Image should have no handle
' Returns bytes of rgb and mask, in int form
Method LoadRawImage:Int[]( im:Image )
Local wIm:Int = im.Width()
Local hIm:Int = im.Height()
Local nPixels:Int = wIm * hIm
' TODO: check device width and height are okay for input and output

Local rgbRaw:Int[] = New Int[ nPixels ]
Cls( 0, 0, 0 )
SetColorNull()
DrawImage( 0, 0 )
ReadPixels( rgbRaw, 0, 0, wIm, hIm )
Local rgb:Int[] = New Int[ nPixels * 3 ]
Local index:Int
For Local i:Int = 0 Until nPixels
Local val:Int = rgbRaw[ i ]
rgb[ index ] = val & $000000FF
index += 1
rgb[ index ] = ( val Shr 8 ) & $000000FF
index += 1
rgb[ index ] = ( val Shr 16 ) & $000000FF
Next

Local mask:Int[] = New Int[ nPixels ]
Cls( 255, 255, 255 )
SetColor( 0, 0, 0 )
DrawImage( 0, 0 )
ReadPixels( mask, 0, 0, wIm, hIm )
SetColorNull()
For Local i:Int = 0 Until nPixels
mask[ i ] = ( ~ mask[ i ] ) & $000000FF
Next

End
 
Last edited:
Top Bottom