Je m'amuse encore avec les pixel et leurs couleurs.
Je ne pige pas pourquoi la valeur de ma couche Alpha est 0
Elle devrait être de 255 logiquement.
Ce que je veux faire :
1 - Chargement image JPG ou PNG
2 - Encodage en 32bits pour gérer la couche alpha
3 - Point() N pixels et connaître leur valeur Alpha (A) du RGBA() pointé
4 - Plot() ces pixels avec une valeur RGBA(r,g,b,NN) (NN étant le ascii de la lettre souhaitée)
Lien de l'image teste : https://upimg.ldvmultimedia.com/img/vi.jpg
Code réduit au "Point()"
Code : Tout sélectionner
UsePNGImageDecoder()
UseJPEGImageDecoder()
UsePNGImageEncoder()
Structure Car
    min.c
    maj.c
EndStructure
Global NewList mot.car()
Global Fichier$
Global LONG
Global COUL.q
Word$ = "Test"
LONG = Len(Word$)
; Conversion du mot en Ascii
If LONG > 0
    position = 1    
    For i = 1 To LONG
        Lettre$ = Mid(Word$,position,1)
        AddElement(mot())
        mot()\min = Asc(LCase(Lettre$)) ; on s'en fout pour ce test
        Mot()\maj = Asc(UCase(Lettre$)) ; on s'en fout pour ce test
        position +1
    Next
    
Else
    Debug "PrOuT"
    End
    
EndIf
IMAGE$ = ""
Fichier$ = OpenFileRequester("Choisissez une image", "", "Image PNG/JPG (*.png/jpg)|*.png;*.jpg", 0)
If Fichier$ = ""
   End
EndIf 
If LoadImage(0,Fichier$)
    
    ;- Passage de l'image en 32bits pour récupérer/créer l'alpha
    
    *ptr=EncodeImage(0 ,#PB_ImagePlugin_PNG, 0, 32)
    CatchImage(1,*ptr)
    FreeImage(0)
    
    L = ImageWidth(1) - LONG
    H = ImageHeight(1) - 2
    
    StartDrawing(ImageOutput(1))
    DrawingMode(#PB_2DDrawing_AlphaChannel)
    POS = L
    ForEach mot()      
        COUL = Point(POS,H)
        Debug "RGBA = " + Str(Red(POS))+","+ Str(Green(POS))+","+ Str(Blue(POS))+","+ Str(Alpha(POS))
        POS+1
    Next   
    StopDrawing()
    
    End
    
    DS$ = GetPathPart(Fichier$)
    FS$ = GetFilePart(Fichier$,#PB_FileSystem_NoExtension)
    Debug DS$+FS$+".png"
    SaveImage(1,DS$+FS$+".png",#PB_ImagePlugin_PNG,0,32 )
    FreeImage(1)
    
    
EndIf

 

