• 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

WritePixels help

Dubbsta

Active member
Joined
Jul 13, 2017
Messages
208
im not sure what the use for createimage , writepixels and readpixels are for or how to use them but this didnt work for me...cant make much sense of the docs and dont know how to set the argb can someone please enlighten me thx.

is this how to change pixels on an image?

Cerberus:
Strict
Import mojo





Class test Extends App

 Field pad:Image
 Field pix:Int[40*40]
 Field img:Image
 
    Method OnCreate:Int()
        SetUpdateRate(60)
         pad = LoadImage("pad.png")
         img = CreateImage(40,40)
        Return 0
    End
    
    
    
    
    Method OnUpdate:Int()
        ReadPixels(pix,40,40,40,40)
    
        Return 0
    End
    
    
    
    
    Method OnRender:Int()
        Cls 0,0,0
        
        DrawImage(pad,40,40)
        
        
        img.GrabImage(100,100,40,40)
        Return 0
    End
    
    
    
End





Function Main:Int()
    
    New test()

    Return 0
End
 
what am i missing? it seems like it should work but doesn't. i get invalid pixel rectangle

dont know if im using it right but just to test it i have a log image , copied a 40 * 40 piece of it and tried to draw it on a blank image i created
is this not how it works ?

Cerberus:
Strict

Import mojo


Class gamename Extends App
 Field log:Image
 Field x:Float =50
 Field y:Float = 50
 Field pix:Int[40*40]
 Field img:Image
 
        Method OnCreate:int()
            SetUpdateRate(60)
            
            log = LoadImage("log1.png")
            img = CreateImage(40,40)
            
            Return 0
        End
        
        
        Method OnUpdate:int()
        
            Return 0
        End
        
        
        Method OnRender:int()
            Cls 0,0,0
            
            DrawImage(log,x,y)
            
            ReadPixels(pix,x,y,40,40)
            
            img.WritePixels(pix,100,100,40,40)
            
            
            
            Return 0
        End
End


Function Main:int()

    New gamename()
    
    Return 0
    
End
 
You started your WritePixel method at the wrong x and y coordinate.

Exchange your Render method with this:
Cerberus:
        Method OnRender:int()
            Cls 0,0,250
            
            DrawImage(log,0,0)
            
            ReadPixels(pix,MouseX(),MouseY(),40,40)
            
            img.WritePixels(pix,0,0,40,40)
            DrawImage(img,0,0)
            
            
            Return 0
        End
 
thx mike. just so i understand writepixels x,y must stay 0,0?
if so would the method have been better written (writepixels(w:int,h:int,x:float = 0 ,y:float = 0 )
so to just deal with width and height? not asking to change just curious thx

also meant to put this in beginner if it makes sense to
 
Sometimes you want to update only a smaller portion of an image, then you need an offset. With your example, you don't need it.
 
Back
Top Bottom