• 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

Read pixel data...?

SLotman

Active member
3rd Party Module Dev
Tutorial Author
Joined
Jul 3, 2017
Messages
261
Is it possible to read the pixel data from an image?

I don't care about HTML5 - only iOS/Android/Desktop.

What I need to do is to make 'clickable' images - and only the opaque pixels on those images to be 'clickable' - so I can actually click on object behind another, if it shows through.

As far as I can remember, MOJO1 can only read pixels from the drawing buffer - not from an image. Is it still the case?
 
+1 for the question. AFAIK there's only the "draw to canvas then copy the canvas data to a DataBuffer object" way. You can't to this in OnCreate tho, because on HTML5 the image won't yet be loaded, on Desktop might not yet be loaded and on Android rendering may only take place in OnRender. At least that's my experience, maybe I did something else wrong. But still, that's the way I go.
 
The pattern I tend to use is "Is the pre-processing done" - if not, keep rolling with the pre-processing.
 
If you can get your images onto a mojo2 Canvas, this thread about saving to BMP includes some code that picks through an image's data using canvas.ReadPixels.

I'm surprised to learn that there's not a built-in pixel-perfect image collision method. Here's a mojolabs thread where people were working on one, but the github repo for the code itself seems to have missing. :/
 
Back
Top Bottom