• Dear Cerberus X User!

    As we prepare to transition the forum ownership from Mike to Phil (TripleHead GmbH), we need your explicit consent to transfer your user data in accordance with our amended Terms and Rules in order to be compliant with data protection laws.

    Important: If you accept the amended Terms and Rules, you agree to the transfer of your user data to the future forum owner!

    Please read the new Terms and Rules below, check the box to agree, and click "Accept" to continue enjoying your Cerberus X Forum experience. The deadline for consent is April 5, 2024.

    Do not accept the amended Terms and Rules if you do not wish your personal data to be transferred to the future forum owner!

    Accepting ensures:

    - Continued access to your account with a short break for the actual transfer.

    - Retention of your data under the same terms.

    Without consent:

    - You don't have further access to your forum user account.

    - Your account and personal data will be deleted after April 5, 2024.

    - Public posts remain, but usernames indicating real identity will be anonymized. If you disagree with a fictitious name you have the option to contact us so we can find a name that is acceptable to you.

    We hope to keep you in our community and see you on the forum soon!

    All the best

    Your Cerberus X Team

Modules laying around?

I still haven't found the module :( I'm really curious how it is coded.
 
@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 :)"
 
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 ;)
 
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:
Back
Top Bottom