little or big endian ! [resolu ...enfin je crois ]

Vous débutez et vous avez besoin d'aide ? N'hésitez pas à poser vos questions
Avatar de l’utilisateur
Thyphoon
Messages : 2706
Inscription : mer. 25/août/2004 6:31
Localisation : Eragny
Contact :

little or big endian ! [resolu ...enfin je crois ]

Message 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
Dernière modification par Thyphoon le mar. 26/sept./2006 13:33, modifié 1 fois.
Backup
Messages : 14526
Inscription : lun. 26/avr./2004 0:40

Message par Backup »

a quoi correspond ton "DBufferP" ? :)
Avatar de l’utilisateur
Thyphoon
Messages : 2706
Inscription : mer. 25/août/2004 6:31
Localisation : Eragny
Contact :

Message par Thyphoon »

Dobro a écrit :a quoi correspond ton "DBufferP" ? :)
A oui j'ai oublié de précsier ! voilà :P
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
Avatar de l’utilisateur
Thyphoon
Messages : 2706
Inscription : mer. 25/août/2004 6:31
Localisation : Eragny
Contact :

Message par Thyphoon »

Heu...je crois que mon problème vient de mon code...pourquoi l'info que je cache je ne la retrouve pas ... :cry:

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)
brossden
Messages : 833
Inscription : lun. 26/janv./2004 14:37

Message par brossden »

Parce que tu l'as trop bien cachée !
Denis

Bonne Jounée à tous
Avatar de l’utilisateur
Thyphoon
Messages : 2706
Inscription : mer. 25/août/2004 6:31
Localisation : Eragny
Contact :

Message 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 :D
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... :(
Avatar de l’utilisateur
Thyphoon
Messages : 2706
Inscription : mer. 25/août/2004 6:31
Localisation : Eragny
Contact :

Message par Thyphoon »

Je ne pense que j'ai trouvé ou était mon erreur...voilà la bonne ligne...

Code : Tout sélectionner

col=(col &~ %11) | info ; je cache ma valeur dans la couleur 
Merci a tous ! :P
Répondre