Page 1 sur 1

Tableau et 2DDrawing

Publié : sam. 04/avr./2020 11:43
par Ekim
Bonjours à tous

J'ai un souci du style raisonnement logique :oops:

je souhaiterais tout simplement décaler de quelques pixels vers la droite une image se trouvant dans un tableau

mais mon code ne fonctionne pas comme il le devrait pourtant, j'ai beau raisonner simplement durant 3 jours sur ce problème mais rien n'y fait

Code : Tout sélectionner



UseJPEGImageDecoder()
UsePNGImageDecoder()

pic$ = OpenFileRequester("Image indexe",pic$,"",0)

imgx=1000 
imgy=600 

TailleMax = imgx*imgy


Dim TabPic(imgx,imgy)


If OpenWindow(0, 0, 0, imgx+50, imgy+50, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
	
	If LoadImage(0,pic$)
		ResizeImage(0,imgx,imgy,#PB_Image_Smooth)
		
		If CreateImage(1,imgx,imgy,32)
			StartDrawing(ImageOutput(1))
				DrawImage(ImageID(0),0,0)
				
				For x=0 To imgx-1
					For y=0 To imgy-1
						Color1 = Point(x,y)
						TabPic(x,y) = Color1 
					Next y
				Next x
			StopDrawing() 
		EndIf

		;Partie interessante

		If CreateImage(2,imgx,imgy,32)
			StartDrawing(ImageOutput(2))
				
				For x1=30 To imgx-1 ;x1 à 30 pour décaler 
					For y1=0 To imgy-1
						
						Clr2 = TabPic(x1,y1)
						
						Plot(x1,y1,Clr2)
					Next y1
				Next x1
			StopDrawing() 
			
			ImageGadget(0, 0, 0, imgx, imgy, ImageID(2),#PB_Image_Raised)
			
		EndIf
	EndIf
	
	Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf


j'ai fait passer x1 à 30 pour décaler mais sa ne fonctionne pas, au lieu de ça, sa rogne limage et c'est dommage car ce n'est pas logique((

j'attends vos points de vue avec impatience car pour le coup je serais vraiment étonné que vous réussissiez :wink:

Re: Tableau et 2DDrawing

Publié : sam. 04/avr./2020 12:52
par Starwolf20
peut être comme ca ?

Code : Tout sélectionner

      ;Partie interessante

      If CreateImage(2,imgx,imgy,32)
         StartDrawing(ImageOutput(2))
            Decalage=100
            For x1=0 To imgx-1-decalage ;x1 à 100 pour décaler
               For y1=0 To imgy-1
                  
                  Clr2 = TabPic(x1+decalage,y1)
                  
                  Plot(x1,y1,Clr2)
               Next y1
            Next x1
         StopDrawing()
         
         ImageGadget(0, 0, 0, imgx, imgy, ImageID(2),#PB_Image_Raised)
         
      EndIf

Re: Tableau et 2DDrawing

Publié : sam. 04/avr./2020 19:42
par Ekim
Excellent, en fait c'était encore plus simple, j'ai honte :oops:
Merci @Starwolf20
:wink: