Page 1 sur 1
little or big endian ! [resolu ...enfin je crois ]
Publié : mar. 26/sept./2006 7:55
par Thyphoon
Bonjour,
pour chaque pixel d'une image je cache une information dans le code de couleur.
J'utilise le bit de poids faible pour cela. Cette information est une valeur entre 0 et 4(inclu).
Pour écrire l'information
Code : Tout sélectionner
col=PeekL(DBuffer+X*PixelFormat+DBufferP*Y) ; je lis la couleur d'origine
info=4 ; la valeur de l'info que je veux caché
col=(col &~ %11) | (%11*info) ; je cache ma valeur dans la couleur
PokeL(DBuffer+X*PixelFormat+DBufferP*Y,col) ; je réécrit la couleur
pour relire l'information caché il suffit alors de faire
Code : Tout sélectionner
col=PeekL(DBuffer+X*PixelFormat+DBufferP*Y)
info=(col & %11 );je lis mon info caché
Or je me demande si je vais avoir des problèmes avec les cartes graphiques little or big endian ? Si oui comment dois-je procéder ?
comment vertir une valeur pour être sur que ce soit la même sur little ou sur big endian ?
merci
Publié : mar. 26/sept./2006 8:50
par Backup
a quoi correspond ton "DBufferP" ?

Publié : mar. 26/sept./2006 9:06
par Thyphoon
Dobro a écrit :a quoi correspond ton "DBufferP" ?

A oui j'ai oublié de précsier ! voilà
DBuffer = DrawingBuffer()
DBufferP = DrawingBufferPitch()
PixelFormat = DrawingBufferPixelFormat()
Select PixelFormat
Case #PB_PixelFormat_8Bits : PixelFormat=1
Case #PB_PixelFormat_15Bits : PixelFormat=2
Case #PB_PixelFormat_16Bits : PixelFormat=2
Case #PB_PixelFormat_24Bits_RGB : PixelFormat=3
Case #PB_PixelFormat_24Bits_BGR : PixelFormat=3
Case #PB_PixelFormat_32Bits_RGB : PixelFormat=4
Case #PB_PixelFormat_32Bits_BGR : PixelFormat=4
EndSelect
Publié : mar. 26/sept./2006 12:02
par Thyphoon
Heu...je crois que mon problème vient de mon code...pourquoi l'info que je cache je ne la retrouve pas ...
Code : Tout sélectionner
If InitSprite() = 0 Or InitKeyboard()=0 Or InitMouse()=0 Or InitSprite3D()=0
MessageRequester("Error","DirectX 7+ is needed.",0)
EndIf
If OpenWindow(0, 0, 0, 320, 200, "Aliens Story Editor", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
OpenWindowedScreen(WindowID(0),0 ,0, 320, 200, 0, 0, 0)
EndIf
CreateSprite(0,32,32)
StartDrawing(SpriteOutput(0))
DBuffer = DrawingBuffer()
DBufferP = DrawingBufferPitch()
PixelFormat = DrawingBufferPixelFormat()
Select PixelFormat
Case #PB_PixelFormat_8Bits : PixelFormat=1
Case #PB_PixelFormat_15Bits : PixelFormat=2
Case #PB_PixelFormat_16Bits : PixelFormat=2
Case #PB_PixelFormat_24Bits_RGB : PixelFormat=3
Case #PB_PixelFormat_24Bits_BGR : PixelFormat=3
Case #PB_PixelFormat_32Bits_RGB : PixelFormat=4
Case #PB_PixelFormat_32Bits_BGR : PixelFormat=4
EndSelect
StopDrawing()
X=1:Y=1
col=PeekL(DBuffer+X*PixelFormat+DBufferP*Y) ; je lis la couleur d'origine
Debug "couleur:"+Str(col)
info=%01 ; la valeur de l'info que je veux caché
Debug "Info>"+Str(info)
col=(col &~ %11) | (%11*info) ; je cache ma valeur dans la couleur
PokeL(DBuffer+X*PixelFormat+DBufferP*Y,col) ; je réécrit la couleur
info=(col & %11 );je lis mon info caché (vérification)
Debug "couleur:"+Str(col)
Debug "Info>"+Str(info)
Publié : mar. 26/sept./2006 12:06
par brossden
Parce que tu l'as trop bien cachée !
Publié : mar. 26/sept./2006 12:08
par Thyphoon
brossden a écrit :Parce que tu l'as trop bien cachée !
lolllllllllllllllll oui c'est ce que m'a dit ma femme aussi
je cherche ou est mon erreur dans ces quelques lignes
Code : Tout sélectionner
X=1:Y=1
col=PeekL(DBuffer+X*PixelFormat+DBufferP*Y) ; je lis la couleur d'origine
Debug "couleur:"+Str(col)
info=4 ; la valeur de l'info que je veux caché
Debug "Info>"+Str(info)
col=(col &~ %11) | (%11*info) ; je cache ma valeur dans la couleur
PokeL(DBuffer+X*PixelFormat+DBufferP*Y,col) ; je réécrit la couleur
info=(col & %11 );je lis mon info caché (vérification)
Debug "couleur:"+Str(col)
Debug "Info>"+Str(info)
si quelqu'un a une idée...Car je tourne en rond depuis hier soir...

Publié : mar. 26/sept./2006 13:35
par Thyphoon
Je ne pense que j'ai trouvé ou était mon erreur...voilà la bonne ligne...
Merci a tous !
