Un photoshop Like !

Programmation d'applications complexes
Avatar de l’utilisateur
Ar-S
Messages : 9539
Inscription : dim. 09/oct./2005 16:51
Contact :

Re: Un photoshop Like !

Message par Ar-S »

Vraiment pas mal.
Reste à ajouter une icone pour fermer les fenetres indépendamment.
Ce serait bien aussi de tester une des fenetres avec une image jpg que l'on chargerait du dd.

Pour l'aide des gadgets tu parles d'aide graphique ou bien ?
~~~~Règles du forum ~~~~
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
Avatar de l’utilisateur
Thyphoon
Messages : 2706
Inscription : mer. 25/août/2004 6:31
Localisation : Eragny
Contact :

Re: Un photoshop Like !

Message par Thyphoon »

Ar-S a écrit :Vraiment pas mal.
Reste à ajouter une icone pour fermer les fenetres indépendamment.
Ce serait bien aussi de tester une des fenetres avec une image jpg que l'on chargerait du dd.
là ça marche actuellement je reposterais un code des qu'onpourra charger une image via Drag 'n Drop :P
Ar-S a écrit :Pour l'aide des gadgets tu parles d'aide graphique ou bien ?
Pour l'instant au niveau Code, Mais une fois que le code sera fonctionnel un coup de main graphique pour faire des zolies icones pourquoi pas !! :o)

Je viens de résoudre un problème ! lorsqu'on zoomait, l'image était lissé ....Avec Drawimage() lorsqu'on la redimensionne et bien ça lisse obligatoirement..donc j'ai du utiliser resizeimage() avec l'option Raw !!

Mais un truc me tracasse ! est ce que ça marche avec une tablette graphique là ?
Avatar de l’utilisateur
Thyphoon
Messages : 2706
Inscription : mer. 25/août/2004 6:31
Localisation : Eragny
Contact :

Re: Un photoshop Like !

Message par Thyphoon »

Bon avec ce code vous pouvez charger une image
a la ligne 528 vous pouvez faire un NewDocument("C:\image.jpg")
Ou bien charger une image via un Drag'N Drop sur la fenêter de l'application ...
Bon faut que j'étudie ça... mais j'ai l'impression que les tailles d'image importante risque de poser problème, a essayer et a optimiser ....

donnez moi votre avis

Code : Tout sélectionner

UseJPEG2000ImageDecoder()
UseJPEG2000ImageEncoder()
UseJPEGImageDecoder()
UseJPEGImageEncoder()
UsePNGImageDecoder()
UsePNGImageEncoder()
UseTGAImageDecoder()
UseTIFFImageDecoder()
InitSprite() : InitKeyboard() : InitMouse()

;-WorkBench
Structure Layer
  Active.b          ; #True ou #False si ce calque est affiché ou pas
  Image.l           ; Image originale

  Opacity.l         ; Transparence global de l'image : ConstAlpha de la function DrawAlphaImage()
  BlendingMode.l    ; Je sais pas si c'est gérable il y a un exemple d'utilisation sur le forum Anglais
  FusionMaskImage.l ; Image comportant le Mask de fusion si il y a !
  ;http://www.purebasic.fr/english/viewtopic.php?f=13&t=36311
EndStructure

#Max_Layer=255
Structure Document
  FileName.s        ;Nom de l'image
  Window.i          ;Fenêtre contenant l'image
  GdtImage.i        ;N° du Gadget contenant l'image
  GdtScrollBarV.i   ;N° du Gadget pour le Scrolling de l'image Verticalement
  GdtScrollBarH.i   ;N°du Gadget pour le Scrolling de l'image Horizontalement
  RenderImage.l     ;Image de rendu des layers
  Zoom.f            ;Zoom de l'image
  WorkImage.l       ; Image redimensionné et affiché !
  Depth.b           ;Profondeur de l'image (peut être n'en a t'on pas besoin ImageDepth() suffit
  ImageSelection.l  ;Image comportant le Masque de Selection
  Layer.l           ;Numero du layer selectionné
  NbLayer.l         ;Nombre de Layer
  Layers.Layer[#Max_Layer] ;Les informations sur les layers mais je ne sais pas si c'est la bonne façon de faire
EndStructure

Global NewList Workbench.Document()

;Variable général aux outils (a voir si ces infos devraient pas être propre a chaque outil)
Structure ToolsInfo
  FrontColor.l      ;Couleur de premier plan
  BackgroundColor.l ;Couleur d'arrière plan
  ToolRenderMode.l  ;Mode de rendu des outils voir enumeration si dessous Couleur/Gradiant/Pattern
EndStructure

Global ToolsInfo.ToolsInfo

Structure InterfaceInfo
  WinMain.i         ;N° de la fenêtre principal
  WinTools.i
EndStructure

Global InterfaceInfo.InterfaceInfo

;Mode de rendu d'un outil
Enumeration
  #ModeCouleur    ;On utilise les couleur de premier et arrière plan
  #ModeGradiant   ;On utilise un dégradé
  #ModePattern    ;On utilise un motif
EndEnumeration

;-EX GUI

Structure Ex
  CLRFACE.l
  CLRHILIGHT.l
  CLRLIGHT.l
  CLRSHADOW.l
  CLRDKSHADOW.l
 
  WINDRAG.b
  WINZONE.l
EndStructure

Global Ex.Ex
Ex\CLRFACE = RGB(113,113,113);32
Ex\CLRHILIGHT = RGB(145,145,145);42
Ex\CLRLIGHT = RGB(113,113,113);32
Ex\CLRSHADOW = RGB(88,88,88);25
Ex\CLRDKSHADOW = RGB(71,71,71);20

;-ExWindows
Structure ExWindow
  Sprite.i
  X.l
  Y.l
  Width.l
  Height.l
  Title.s
EndStructure

Global NewList ExWindow.ExWindow()

Procedure ExDrawRect(X,Y,Width,Height,Mode)
  Select Mode
    Case 0
      Box(X,Y,Width,Height,Ex\CLRDKSHADOW)
      Box(X + 1,Y + 1,Width - 2,Height - 2,Ex\CLRSHADOW)
      Box(X + 2,Y + 2,Width - 4,Height - 4,Ex\CLRFACE)     
    Case 1
      Box(X,Y,Width,Height,Ex\CLRDKSHADOW)
      Box(X,Y,Width - 1,Height - 1,Ex\CLRLIGHT)
      Box(X + 1,Y + 1,Width - 2,Height - 2,Ex\CLRSHADOW)
      Box(X + 1,Y + 1,Width - 3,Height - 3,Ex\CLRHILIGHT)
      Box(X + 2,Y + 2,Width - 4,Height - 4,Ex\CLRFACE)
    Case 2
      Box(X,Y,Width,Height,Ex\CLRDKSHADOW)
  EndSelect 
EndProcedure

Declare RenderExGadget()

Procedure RenderExWindow()
  StartDrawing(SpriteOutput(ExWindow()\Sprite))
    DrawingMode(#PB_2DDrawing_Transparent)
     
   Box(0,0,ExWindow()\Width,ExWindow()\Height,Ex\CLRDKSHADOW)   
   Box(0,0,ExWindow()\Width - 1,ExWindow()\Height - 1,Ex\CLRLIGHT)
   Box(1,1,ExWindow()\Width - 2,25,Ex\CLRSHADOW)
   Box(1,1,ExWindow()\Width - 3,24,Ex\CLRHILIGHT)
   Box(2,2,ExWindow()\Width - 4,23,Ex\CLRLIGHT)
   Box(1,26,ExWindow()\Width - 2,ExWindow()\Height - 27,Ex\CLRSHADOW)
   Box(1,26,ExWindow()\Width - 3,ExWindow()\Height - 28,Ex\CLRHILIGHT)
   Box(2,27,ExWindow()\Width - 4,ExWindow()\Height - 29,Ex\CLRFACE)
   
   ;GUI_DrawGradient(2,2,Width - 4,23,GUI_CLRSHADOW,GUI_CLRFACE)
   ;GUI_DrawGradient(2,27,Width - 4,Height - 29,GUI_CLRFACE,GUI_CLRSHADOW)
   
   ;DrawingFont(FontID(#GUI_Font_Icon))
   ;GUI_DrawRect(Width - 23,6,17,16)   
   ;DrawText(Width - 20,9,"r",RGB(230,200,180))
   
   ;DrawingFont(FontID(#GUI_Font_Caption))
   DrawText(12,8,ExWindow()\Title,RGB(60,0,0))
   DrawText(10,6,ExWindow()\Title,#White)
   RenderExGadget()
  StopDrawing()
EndProcedure




Procedure OpenExWindow(X,Y,Width,Height,Title.s,Option.l=0)
  AddElement(ExWindow())
  ExWindow()\Sprite = CreateSprite(#PB_Any,Width,Height,#PB_Sprite_Memory) 
  ExWindow()\X=X
  ExWindow()\Y=Y
  ExWindow()\Width=Width
  ExWindow()\Height=Height
  ExWindow()\Title=Title
  RenderExWindow()
  ProcedureReturn ExWindow()
EndProcedure

Procedure ExResizeWindow(Handle,Width,Height)
  If Handle<>0
    ChangeCurrentElement(ExWindow(),Handle)   
  EndIf
  If Width<10:Width=10:EndIf
  If Height<25:Height=25:EndIf
   
  ExWindow()\Width=Width
  ExWindow()\Height=Height
  FreeSprite(ExWindow()\Sprite)
  ExWindow()\Sprite=CreateSprite(#PB_Any,Width,Height,#PB_Sprite_Memory)
  UseBuffer(Sprite)
  RenderExWindow()
EndProcedure

Procedure SetExWindowTitle(Handle,Title.s)
  If Handle<>0
    ChangeCurrentElement(ExWindow(),Handle)   
  EndIf
  ExWindow()\Title=Title
  RenderExWindow()
EndProcedure

Procedure ExWindowX(Handle=0)
  If Handle<>0
    ChangeCurrentElement(ExWindow(),Handle)   
  EndIf
  ProcedureReturn ExWindow()\X
EndProcedure

Procedure ExWindowY(Handle=0)
  If Handle<>0
    ChangeCurrentElement(ExWindow(),Handle)   
  EndIf
  ProcedureReturn ExWindow()\Y
EndProcedure

Procedure ExWindowWidth(Handle=0)
  If Handle<>0
    ChangeCurrentElement(ExWindow(),Handle)   
  EndIf
  ProcedureReturn ExWindow()\Width
EndProcedure

Procedure ExWindowHeight(Handle=0)
  If Handle<>0
    ChangeCurrentElement(ExWindow(),Handle)   
  EndIf
  ProcedureReturn ExWindow()\Height
EndProcedure

Procedure GetActiveExWindow()
   LastElement(ExWindow())
   ProcedureReturn ExWindow()
EndProcedure

Procedure ExamineExGUI()
Static MouseX.l,MouseY.l

StartDrawing(ScreenOutput())
  ForEach ExWindow()
    DisplaySprite(ExWindow()\Sprite,ExWindow()\X,ExWindow()\Y)
  Next
StopDrawing()

If Ex\WINZONE=0 And MouseButton(#PB_MouseButton_Left)
  LastElement(ExWindow())
  Repeat
    If MouseX()>ExWindow()\X And MouseX()<ExWindow()\X+ExWindow()\Width And MouseY()>ExWindow()\Y And MouseY()<ExWindow()\Y+ExWindow()\Height
      If MouseY()>ExWindow()\Y And MouseY()<ExWindow()\Y+25:Ex\WINZONE=1:EndIf
      If MouseX()>ExWindow()\X+ExWindow()\Width-25 And MouseY()>ExWindow()\Y+ExWindow()\Height-25:Ex\WINZONE=2:EndIf
      *FirstElement = ExWindow()
      LastElement(ExWindow())
      *LastElement = ExWindow()
      If *FirstElement=*LastElement
        Break;
      Else
        SwapElements(ExWindow(),*FirstElement,*LastElement)
        Break;
      EndIf
    EndIf
  Until PreviousElement(ExWindow())=0
  LastElement(ExWindow())
EndIf

If MouseButton(#PB_MouseButton_Left)
  If Ex\WINZONE=1 And Ex\WINDRAG=#True
    ExWindow()\X=ExWindow()\X+MouseX()-MouseX
    ExWindow()\Y=ExWindow()\Y+MouseY()-MouseY
  ElseIf Ex\WINZONE=2 And Ex\WINDRAG=#True
    ExResizeWindow(0,ExWindow()\Width+MouseX()-MouseX,ExWindow()\Height+MouseY()-MouseY)
  EndIf

  MouseX=MouseX()
  MouseY=MouseY()
  Ex\WINDRAG=#True
Else
  Ex\WINDRAG=#False
  Ex\WINZONE=0
EndIf
EndProcedure
;-ExMenu
Procedure RenderExMenu()
  StartDrawing(ScreenOutput())
   Box(0,0,WindowWidth(0),25,Ex\CLRDKSHADOW)   
   Box(0,0,WindowWidth(0) - 1,24,Ex\CLRLIGHT)
   Box(1,1,WindowWidth(0) - 2,25,Ex\CLRSHADOW)
   Box(1,1,WindowWidth(0) - 3,24,Ex\CLRHILIGHT)
   Box(2,2,WindowWidth(0) - 4,23,Ex\CLRLIGHT)
  StopDrawing()
EndProcedure

;-ExGadget
Structure ExGadget
  WinHandle.i
  Type.l
  X.l
  Y.l
  Width.l
  Height.l
 
  Name.s
  ValueA.f
  ValueB.f
  ValueC.f
  ValueD.f
  Option.l
EndStructure
Global NewList ExGadget.ExGadget()

Procedure ScrollBarExGadget(x.l, y.l, Width.l, Height.l, Min.l, Max.l, Len.l , Options=0)
  AddElement(ExGadget())
  ExGadget()\WinHandle=ExWindow()
  ExGadget()\X=x
  ExGadget()\Y=y
  ExGadget()\Width=width
  ExGadget()\Height=height
  ExGadget()\ValueA=Min
  ExGadget()\ValueB=Max
  ExGadget()\ValueC=Len
EndProcedure

Procedure ResizeExGadget(Handle.l,x.l, y.l, Width.l, Height.l)
  If Handle<>0
    ChangeCurrentElement(ExGadget(),Handle)   
  EndIf
  If x<>#PB_Ignore:ExGadget()\X=x:EndIf
  If y<>#PB_Ignore:ExGadget()\X=y:EndIf
  If Width<>#PB_Ignore:ExGadget()\X=Width:EndIf
  If Height<>#PB_Ignore:ExGadget()\X=Height:EndIf
EndProcedure

Procedure RenderExGadget()
  ForEach ExGadget()
    If ExGadget()\WinHandle=ExWindow()
      Select ExGadget()\Type
        Case 0
          If Option=0
          ExDrawRect(ExGadget()\X,ExGadget()\Y,ExGadget()\Height,ExGadget()\Height,0)
          ExDrawRect(ExGadget()\X+ExGadget()\Width-ExGadget()\Height,ExGadget()\Y,ExGadget()\Height,ExGadget()\Height,0)
          ExDrawRect(ExGadget()\X+ExGadget()\Height,ExGadget()\Y,ExGadget()\Width-ExGadget()\Height*2,ExGadget()\Height,2)
          bwidth=(ExGadget()\Width-ExGadget()\Height*2)-(ExGadget()\ValueB-ExGadget()\ValueA)
         
          ExDrawRect(ExGadget()\X+ExGadget()\Height,ExGadget()\Y+2,bwidth,ExGadget()\Height-4,1)
         
          EndIf
      EndSelect
    EndIf
  Next
EndProcedure




;-WorkBench Procedure
Procedure AddLayer(Image.i=0)
  ;si on a pas de n° d'image dans les paramètres alors on créer l'image en fonction de l'image de rendu
  If Image=0
    Image=CreateImage(#PB_Any,ImageWidth(Workbench()\RenderImage),ImageHeight(Workbench()\RenderImage),ImageDepth(Workbench()\RenderImage))
  EndIf
  Workbench()\NbLayer+1 ;On ajoute un calque
  Workbench()\Layers.Layer[Workbench()\NbLayer]\Active=#True  ;On l'active
  Workbench()\Layers.Layer[Workbench()\NbLayer]\Image=Image   ;l'image du calque
  Workbench()\Layers.Layer[Workbench()\NbLayer]\Opacity=255   ;L'opacité du calque
  Workbench()\Layer=Workbench()\NbLayer ; Et part defaut on selectionne le calque qu'on vient d'ajouter
EndProcedure

;Rendu des calques
Procedure RenderLayers()
  Protected z.l
  ;Le rendu des calques se fait sur l'image de rendu
  StartDrawing(ImageOutput(Workbench()\RenderImage))
  For z=1 To Workbench()\NbLayer ; je dessine chaque calque
    ;Si le calque est bien visible(activé)
    DrawingMode(#PB_2DDrawing_AlphaClip)
    If Workbench()\Layers.Layer[z]\Active=#True
      DrawAlphaImage(ImageID(Workbench()\Layers.Layer[z]\Image),0,0,Workbench()\Layers.Layer[z]\Opacity)
    EndIf
  Next
  StopDrawing()
EndProcedure


;Pour écrire sur le calque selectionné
Procedure WriteLayerPixel(x.l,y.l,Color.l)
  Select ToolsInfo\ToolRenderMode

    ;Si l'outil doit écrire avec une couleur
    Case #ModeCouleur
       Protected Image.i=Workbench()\Layers.Layer[Workbench()\Layer]\Image
         Protected Width.l,Height.l
  Width=ExWindowWidth(Workbench()\Window)-20
  If Width>ImageWidth(Workbench()\RenderImage)*Workbench()\Zoom
    Width=ImageWidth(Workbench()\RenderImage)*Workbench()\Zoom
  EndIf
  If Width<1
    Width=1
  EndIf

  Height=ExWindowHeight(Workbench()\Window)-20
  If Height>ImageHeight(Workbench()\RenderImage)*Workbench()\Zoom
    Height=ImageHeight(Workbench()\RenderImage)*Workbench()\Zoom
  EndIf
  If Height<1
    Height=1
  EndIf
       Dx=(ExWindowWidth(Workbench()\Window)-Width)/2
       Dy=26+(ExWindowHeight(Workbench()\Window)-Height-26)/2
        x=(x-ExWindowX(Workbench()\Window)-Dx)/Workbench()\Zoom
        y=(y-ExWindowY(Workbench()\Window)-Dy)/Workbench()\Zoom
        StartDrawing(ImageOutput(Image))
          If x>0 And x<ImageWidth(Image) And y>0 And y<ImageHeight(Image)
            Plot(x,y,Color)
          EndIf
        StopDrawing()
   
    ;Si l'outil doit écrire avec un dégradé
    Case #ModeGradiant
   
    ;Si l'outil doit écrire avec un motif
    Case #ModePattern
   
  EndSelect
EndProcedure

Procedure RefreshWindow()
  Protected Max.l,DeltaX.l,DeltaY.l
  ;Je modifie le nom de la fenêtre car elle contient des informations sur le nom le zoom et la profondeur de l'image

  SetExWindowTitle(Workbench()\Window, GetFilePart(Workbench()\FileName)+" @ "+Str(Abs(Workbench()\Zoom*100))+"%"+" (Layer"+Str(Workbench()\Layer)+",???/"+Str(ImageDepth(Workbench()\RenderImage))+")")

  ;Dans le cas d'un redimensionnement de la fenêtre je redimenssione les ScrollBar
  ResizeExGadget(Workbench()\GdtScrollBarV,ExWindowWidth(Workbench()\Window)-20, 0, 20, ExWindowHeight(Workbench()\Window))
  Max=ImageHeight(Workbench()\RenderImage)*Workbench()\Zoom-ExWindowHeight(Workbench()\Window)-20
  If Max<0:Max=0:EndIf
  ;SetGadgetAttribute(Workbench()\GdtScrollBarV,#PB_ScrollBar_Maximum,Max)

  ResizeExGadget(Workbench()\GdtScrollBarH,100, ExWindowHeight(Workbench()\Window)-20, ExWindowWidth(Workbench()\Window)-120, 20)
  Max=ImageWidth(Workbench()\RenderImage)*Workbench()\Zoom-ExWindowWidth(Workbench()\Window)-20
  If Max<0:Max=0:EndIf
  ;SetGadgetAttribute(Workbench()\GdtScrollBarH,#PB_ScrollBar_Maximum,Max)

  RenderLayers();Je fait un rendu complet

;Une fois le rendu finit je créer l'image qui sera affiché dans la fenêtre
  If IsImage(Workbench()\WorkImage)
    FreeImage(Workbench()\WorkImage)
  EndIf

  ;Position des ScrollsBar
  DeltaX=0;GetGadgetState(Workbench()\GdtScrollBarH)
  DeltaY=0;GetGadgetState(Workbench()\GdtScrollBarV)

  ;Calcul de la taille de l'image affiché dans la fenêtre
  Protected Width.l,Height.l
  Width=ExWindowWidth(Workbench()\Window)-20
  If Width>ImageWidth(Workbench()\RenderImage)*Workbench()\Zoom
    Width=ImageWidth(Workbench()\RenderImage)*Workbench()\Zoom
  EndIf
  If Width<1
    Width=1
  EndIf

  Height=ExWindowHeight(Workbench()\Window)-20
  If Height>ImageHeight(Workbench()\RenderImage)*Workbench()\Zoom
    Height=ImageHeight(Workbench()\RenderImage)*Workbench()\Zoom
  EndIf
  If Height<1
    Height=1
  EndIf

  tmp=CopyImage(Workbench()\RenderImage,#PB_Any)
  ClipI
  ResizeImage(tmp,ImageWidth(Workbench()\RenderImage)*Workbench()\Zoom,ImageHeight(Workbench()\RenderImage)*Workbench()\Zoom,#PB_Image_Raw)
  Workbench()\WorkImage=CreateImage(#PB_Any,Width,Height,ImageDepth(Workbench()\RenderImage)) ; je créer l'image
  ;On affiche la partie de l'image qui est visible
  StartDrawing(ImageOutput(Workbench()\WorkImage))
    DrawImage(ImageID(tmp),-DeltaX,-DeltaY,ImageWidth(Workbench()\RenderImage)*Workbench()\Zoom,ImageHeight(Workbench()\RenderImage)*Workbench()\Zoom)
  StopDrawing()
  FreeImage(tmp)
  ;
   StartDrawing(SpriteOutput(ExWindow()\Sprite))
    XImage=(ExWindowWidth(Workbench()\Window)-Width)/2
    YImage=26+(ExWindowHeight(Workbench()\Window)-Height-26)/2
    Box(XImage-1,YImage-1,Width+2,Height+2,#Black)
    DrawImage(ImageID(Workbench()\WorkImage),XImage,YImage,Width,Height)
   
    ;Grille
    If Workbench()\Zoom>3
      z.f=0
      Repeat
        z=z+Workbench()\Zoom
        Line(XImage+z,YImage,1,Height,#Black)
      Until z>=Width
      z=0
      Repeat
        z=z+Workbench()\Zoom
        Line(XImage,YImage+z,Width,1,#Black)
      Until z>=Height
    EndIf
  StopDrawing()

EndProcedure

;Ouverdure d'une image ou creation d'un nouveau document
Procedure NewDocument(Name.s="")
  Protected Image.i
  AddElement(Workbench())
  If Name=""
    Name.s="Untitled "+Str(ListSize(Workbench()))
  EndIf
  Workbench()\FileName=Name

    If FileSize(Workbench()\FileName)>0
      Image=LoadImage(#PB_Any,Workbench()\FileName)
    Else
      Image=CreateImage(#PB_Any,320,200,32);Il faudra ici mettre des variables pour la taille part defaut (peut être prendre la taille de l'image si dans le presse papier)
      StartDrawing(ImageOutput(Image))
        Box(0,0,320,200,#Red)
        Circle(50,50,25,#Blue)
      StopDrawing()
    EndIf
   
    ;Ouverture de la fenêtre contenant l'image
    Workbench()\Window=OpenExWindow(ExWindowWidth(InterfaceInfo\WinTools)+ListIndex(Workbench())*16, 25+ListIndex(Workbench())*16, 640, 480, "",#PB_Window_Tool|#PB_Window_TitleBar|#PB_Window_SizeGadget|#PB_Window_SystemMenu)
    ;Creation des gadgets
    ;Workbench()\GdtScrollBarV=ScrollBarExGadget(ExWindowWidth(Workbench()\Window)-20, 0, 20, ExWindowHeight(Workbench()\Window),0,0,10,#PB_ScrollBar_Vertical)
    Workbench()\GdtScrollBarH=ScrollBarExGadget(100, ExWindowHeight(Workbench()\Window)-20, ExWindowWidth(Workbench()\Window)-120, 20,0,0,10)
    ;On definit une Image pour le rendu final des calques
    Workbench()\RenderImage=CreateImage(#PB_Any,ImageWidth(Image),ImageHeight(Image),ImageDepth(Image))
    ;On definit le Zoom en fonction de la taille de l'image et de la fenêtre
    Workbench()\Zoom=ExWindowWidth(Workbench()\Window)/ImageWidth(Image)
    AddLayer(Image);On créer le premier calque du document
    RefreshWindow();On rafraichissement


    *FirstElement = ExWindow()
    LastElement(ExWindow())
    *LastElement = ExWindow()
    SwapElements(ExWindow(),*FirstElement,*LastElement)

EndProcedure


; Open Screen
OpenWindow(0,0,0,1024,768,"PBPhoto",#PB_Window_SystemMenu | #PB_Window_ScreenCentered |#PB_Window_SizeGadget)
OpenWindowedScreen(WindowID(0),0,0,1024,768,0,0,0)

InterfaceInfo\WinTools=OpenExWindow(0,25,100,250,"Tools")

EnableWindowDrop(0,#PB_Drop_Files,#PB_Drag_Copy)

NewDocument("1-avatar.jpg")
;NewDocument()
;NewDocument()
; Mouse Pointer
lpBuffer = AllocateMemory(630)
UnpackMemory(?Cursor,lpBuffer)
CatchSprite(0,lpBuffer)
TransparentSpriteColor(0,RGB(0,128,128))
FreeMemory(lpBuffer)

Repeat
  Event = WindowEvent()   
   
  If inscreen
    If MouseX()>WindowWidth(0)-2 Or MouseY()>WindowHeight(0)-2 Or MouseX()<1 Or MouseY()<1
      ReleaseMouse(1)
      inscreen = #False
    EndIf
  Else
    ;
    ;************************************
    ;    Handle #PB_Event_Gadget Here
    ;************************************
    If Event= #PB_Event_SizeWindow
      ;OpenWindowedScreen(WindowID(0),0,0,WindowWidth(0)+10,WindowHeight(0)+10,0,0,0)
    EndIf
    
    If Event = #PB_Event_WindowDrop 
      Debug "Coucou"
       Debug EventDropFiles()
    EndIf
    
    If Event = #PB_Event_Gadget
      If EventGadget() = 1
        MessageRequester("","You pressed the button!")
      EndIf
    EndIf
   
    ;On verifie si on est dans l'ecran
    mx = WindowMouseX(0):my = WindowMouseY(0)
    If mx < WindowWidth(0)-2 And mx > 0 And my > 0 And my < WindowHeight(0)-2
      ReleaseMouse(0)
      MouseLocate(mx,my)
      inscreen = #True
    EndIf
  EndIf
 
  ;On Se positionne sur le bon Document
  If LastWindow<>GetActiveExWindow()
    ForEach Workbench() ;On cherche a retrouver le document propre a la fenêtre   active
      If Workbench()\Window=GetActiveExWindow() ;Hop on l'a trouvé
         Break;
      EndIf
    Next
   LastWindow=GetActiveExWindow();Je mémorise la fenêtre histoire de ne pas faire la recherche a chaque boucle
  EndIf 
   
   
  ClearScreen(Ex\CLRHILIGHT)
  ExamineKeyboard()
  ExamineExGUI():RenderExMenu()
   
  If inscreen  ; manage mouse events only if mouse is inside screen
    Event=WindowEvent()
    
    If Event = #PB_Event_WindowDrop 
      Debug "Coucou"
      Debug EventDropFiles()
      NewDocument(EventDropFiles())
    EndIf
    
    ExamineMouse()

    If MouseButton(#PB_MouseButton_Left) And Ex\WINZONE=0
      RefreshWindow()
      WriteLayerPixel(MouseX(),MouseY(),#Red)
    EndIf

    If MouseWheel()
      If Workbench()\Zoom+MouseWheel()*0.1>0
      Workbench()\Zoom+MouseWheel()*0.1
      
      EndIf
      RefreshWindow()
    EndIf
  DisplayTransparentSprite(0,MouseX(),MouseY())
  EndIf
 
  LastElement(ExWindow())
  
  FlipBuffers()

Until KeyboardPushed(1) Or Event = #PB_Event_CloseWindow
   
   
   
   ;   ExamineKeyboard() : ExamineMouse() :ExamineExGUI():RenderExMenu()
  ;

; -------------------------------------------------------------------
; DATA SECTION
; -------------------------------------------------------------------

DataSection
   Cursor:
   Data.l $0276434A,$4A720000,$A9B7AACC,$146320D0,$284A6811,$01232023,$9188409D,$F3000461,$20492601,$0A0401E0
   Data.l $E00081C0,$FFC0E015,$09302024,$409C3C04,$66013801,$FE4D02B6,$91FB77FB,$B7C236B7,$BDF63086,$BFEC1EC1
   Data.l $C0F36107,$0F625EF7,$008A083D,$87FFF581,$C4592A11,$4287C926,$3EC90540,$69F6974F,$21E5E328,$DDDE6107
   Data.l $50B353C6,$0FB86C06,$0000D893
   Data.b $90,$48
EndDataSection
Avatar de l’utilisateur
Thyphoon
Messages : 2706
Inscription : mer. 25/août/2004 6:31
Localisation : Eragny
Contact :

Re: Un photoshop Like !

Message par Thyphoon »

je viens de mette a jour le code au dessus ça marche mieux avec les grosses images....
Le problème reside dans le zoom du grande image
mais j'ai une idée ....
Avatar de l’utilisateur
Thyphoon
Messages : 2706
Inscription : mer. 25/août/2004 6:31
Localisation : Eragny
Contact :

Re: Un photoshop Like !

Message par Thyphoon »

Voilà ça marche beaucoup mieux ..Une bonne optimisation du zoom pour les grosses images ....
c'est pas encore parfait mais c'est bien mieux ! :)

Code : Tout sélectionner

UseJPEG2000ImageDecoder()
UseJPEG2000ImageEncoder()
UseJPEGImageDecoder()
UseJPEGImageEncoder()
UsePNGImageDecoder()
UsePNGImageEncoder()
UseTGAImageDecoder()
UseTIFFImageDecoder()
InitSprite() : InitKeyboard() : InitMouse()

;-WorkBench
Structure Layer
  Active.b          ; #True ou #False si ce calque est affiché ou pas
  Image.l           ; Image originale

  Opacity.l         ; Transparence global de l'image : ConstAlpha de la function DrawAlphaImage()
  BlendingMode.l    ; Je sais pas si c'est gérable il y a un exemple d'utilisation sur le forum Anglais
  FusionMaskImage.l ; Image comportant le Mask de fusion si il y a !
  ;http://www.purebasic.fr/english/viewtopic.php?f=13&t=36311
EndStructure

#Max_Layer=255
Structure Document
  FileName.s        ;Nom de l'image
  Window.i          ;Fenêtre contenant l'image
  GdtImage.i        ;N° du Gadget contenant l'image
  GdtScrollBarV.i   ;N° du Gadget pour le Scrolling de l'image Verticalement
  GdtScrollBarH.i   ;N°du Gadget pour le Scrolling de l'image Horizontalement
  RenderImage.l     ;Image de rendu des layers
  Zoom.f            ;Zoom de l'image
  WorkImage.l       ; Image redimensionné et affiché !
  Depth.b           ;Profondeur de l'image (peut être n'en a t'on pas besoin ImageDepth() suffit
  ImageSelection.l  ;Image comportant le Masque de Selection
  Layer.l           ;Numero du layer selectionné
  NbLayer.l         ;Nombre de Layer
  Layers.Layer[#Max_Layer] ;Les informations sur les layers mais je ne sais pas si c'est la bonne façon de faire
EndStructure

Global NewList Workbench.Document()

;Variable général aux outils (a voir si ces infos devraient pas être propre a chaque outil)
Structure ToolsInfo
  FrontColor.l      ;Couleur de premier plan
  BackgroundColor.l ;Couleur d'arrière plan
  ToolRenderMode.l  ;Mode de rendu des outils voir enumeration si dessous Couleur/Gradiant/Pattern
EndStructure

Global ToolsInfo.ToolsInfo

Structure InterfaceInfo
  WinMain.i         ;N° de la fenêtre principal
  WinTools.i
EndStructure

Global InterfaceInfo.InterfaceInfo

;Mode de rendu d'un outil
Enumeration
  #ModeCouleur    ;On utilise les couleur de premier et arrière plan
  #ModeGradiant   ;On utilise un dégradé
  #ModePattern    ;On utilise un motif
EndEnumeration

;-EX GUI

Structure Ex
  CLRFACE.l
  CLRHILIGHT.l
  CLRLIGHT.l
  CLRSHADOW.l
  CLRDKSHADOW.l
 
  WINDRAG.b
  WINZONE.l
EndStructure

Global Ex.Ex
Ex\CLRFACE = RGB(113,113,113);32
Ex\CLRHILIGHT = RGB(145,145,145);42
Ex\CLRLIGHT = RGB(113,113,113);32
Ex\CLRSHADOW = RGB(88,88,88);25
Ex\CLRDKSHADOW = RGB(71,71,71);20

;-ExWindows
Structure ExWindow
  Sprite.i
  X.l
  Y.l
  Width.l
  Height.l
  Title.s
EndStructure

Global NewList ExWindow.ExWindow()

Procedure ExDrawRect(X,Y,Width,Height,Mode)
  Select Mode
    Case 0
      Box(X,Y,Width,Height,Ex\CLRDKSHADOW)
      Box(X + 1,Y + 1,Width - 2,Height - 2,Ex\CLRSHADOW)
      Box(X + 2,Y + 2,Width - 4,Height - 4,Ex\CLRFACE)     
    Case 1
      Box(X,Y,Width,Height,Ex\CLRDKSHADOW)
      Box(X,Y,Width - 1,Height - 1,Ex\CLRLIGHT)
      Box(X + 1,Y + 1,Width - 2,Height - 2,Ex\CLRSHADOW)
      Box(X + 1,Y + 1,Width - 3,Height - 3,Ex\CLRHILIGHT)
      Box(X + 2,Y + 2,Width - 4,Height - 4,Ex\CLRFACE)
    Case 2
      Box(X,Y,Width,Height,Ex\CLRDKSHADOW)
  EndSelect 
EndProcedure

Declare RenderExGadget()

Procedure RenderExWindow()
  StartDrawing(SpriteOutput(ExWindow()\Sprite))
    DrawingMode(#PB_2DDrawing_Transparent)
     
   Box(0,0,ExWindow()\Width,ExWindow()\Height,Ex\CLRDKSHADOW)   
   Box(0,0,ExWindow()\Width - 1,ExWindow()\Height - 1,Ex\CLRLIGHT)
   Box(1,1,ExWindow()\Width - 2,25,Ex\CLRSHADOW)
   Box(1,1,ExWindow()\Width - 3,24,Ex\CLRHILIGHT)
   Box(2,2,ExWindow()\Width - 4,23,Ex\CLRLIGHT)
   Box(1,26,ExWindow()\Width - 2,ExWindow()\Height - 27,Ex\CLRSHADOW)
   Box(1,26,ExWindow()\Width - 3,ExWindow()\Height - 28,Ex\CLRHILIGHT)
   Box(2,27,ExWindow()\Width - 4,ExWindow()\Height - 29,Ex\CLRFACE)
   
   ;GUI_DrawGradient(2,2,Width - 4,23,GUI_CLRSHADOW,GUI_CLRFACE)
   ;GUI_DrawGradient(2,27,Width - 4,Height - 29,GUI_CLRFACE,GUI_CLRSHADOW)
   
   ;DrawingFont(FontID(#GUI_Font_Icon))
   ;GUI_DrawRect(Width - 23,6,17,16)   
   ;DrawText(Width - 20,9,"r",RGB(230,200,180))
   
   ;DrawingFont(FontID(#GUI_Font_Caption))
   DrawText(12,8,ExWindow()\Title,RGB(60,0,0))
   DrawText(10,6,ExWindow()\Title,#White)
   RenderExGadget()
  StopDrawing()
EndProcedure




Procedure OpenExWindow(X,Y,Width,Height,Title.s,Option.l=0)
  AddElement(ExWindow())
  ExWindow()\Sprite = CreateSprite(#PB_Any,Width,Height,#PB_Sprite_Memory) 
  ExWindow()\X=X
  ExWindow()\Y=Y
  ExWindow()\Width=Width
  ExWindow()\Height=Height
  ExWindow()\Title=Title
  RenderExWindow()
  ProcedureReturn ExWindow()
EndProcedure

Procedure ExResizeWindow(Handle,Width,Height)
  If Handle<>0
    ChangeCurrentElement(ExWindow(),Handle)   
  EndIf
  If Width<10:Width=10:EndIf
  If Height<25:Height=25:EndIf
   
  ExWindow()\Width=Width
  ExWindow()\Height=Height
  FreeSprite(ExWindow()\Sprite)
  ExWindow()\Sprite=CreateSprite(#PB_Any,Width,Height,#PB_Sprite_Memory)
  UseBuffer(Sprite)
  RenderExWindow()
EndProcedure

Procedure SetExWindowTitle(Handle,Title.s)
  If Handle<>0
    ChangeCurrentElement(ExWindow(),Handle)   
  EndIf
  ExWindow()\Title=Title
  RenderExWindow()
EndProcedure

Procedure ExWindowX(Handle=0)
  If Handle<>0
    ChangeCurrentElement(ExWindow(),Handle)   
  EndIf
  ProcedureReturn ExWindow()\X
EndProcedure

Procedure ExWindowY(Handle=0)
  If Handle<>0
    ChangeCurrentElement(ExWindow(),Handle)   
  EndIf
  ProcedureReturn ExWindow()\Y
EndProcedure

Procedure ExWindowWidth(Handle=0)
  If Handle<>0
    ChangeCurrentElement(ExWindow(),Handle)   
  EndIf
  ProcedureReturn ExWindow()\Width
EndProcedure

Procedure ExWindowHeight(Handle=0)
  If Handle<>0
    ChangeCurrentElement(ExWindow(),Handle)   
  EndIf
  ProcedureReturn ExWindow()\Height
EndProcedure

Procedure GetActiveExWindow()
   LastElement(ExWindow())
   ProcedureReturn ExWindow()
EndProcedure

Procedure ExamineExGUI()
Static MouseX.l,MouseY.l

StartDrawing(ScreenOutput())
  ForEach ExWindow()
    DisplaySprite(ExWindow()\Sprite,ExWindow()\X,ExWindow()\Y)
  Next
StopDrawing()

If Ex\WINZONE=0 And MouseButton(#PB_MouseButton_Left)
  LastElement(ExWindow())
  Repeat
    If MouseX()>ExWindow()\X And MouseX()<ExWindow()\X+ExWindow()\Width And MouseY()>ExWindow()\Y And MouseY()<ExWindow()\Y+ExWindow()\Height
      If MouseY()>ExWindow()\Y And MouseY()<ExWindow()\Y+25:Ex\WINZONE=1:EndIf
      If MouseX()>ExWindow()\X+ExWindow()\Width-25 And MouseY()>ExWindow()\Y+ExWindow()\Height-25:Ex\WINZONE=2:EndIf
      *FirstElement = ExWindow()
      LastElement(ExWindow())
      *LastElement = ExWindow()
      If *FirstElement=*LastElement
        Break;
      Else
        SwapElements(ExWindow(),*FirstElement,*LastElement)
        Break;
      EndIf
    EndIf
  Until PreviousElement(ExWindow())=0
  LastElement(ExWindow())
EndIf

If MouseButton(#PB_MouseButton_Left)
  If Ex\WINZONE=1 And Ex\WINDRAG=#True
    ExWindow()\X=ExWindow()\X+MouseX()-MouseX
    ExWindow()\Y=ExWindow()\Y+MouseY()-MouseY
  ElseIf Ex\WINZONE=2 And Ex\WINDRAG=#True
    ExResizeWindow(0,ExWindow()\Width+MouseX()-MouseX,ExWindow()\Height+MouseY()-MouseY)
  EndIf

  MouseX=MouseX()
  MouseY=MouseY()
  Ex\WINDRAG=#True
Else
  Ex\WINDRAG=#False
  Ex\WINZONE=0
EndIf
EndProcedure
;-ExMenu
Procedure RenderExMenu()
  StartDrawing(ScreenOutput())
   Box(0,0,WindowWidth(0),25,Ex\CLRDKSHADOW)   
   Box(0,0,WindowWidth(0) - 1,24,Ex\CLRLIGHT)
   Box(1,1,WindowWidth(0) - 2,25,Ex\CLRSHADOW)
   Box(1,1,WindowWidth(0) - 3,24,Ex\CLRHILIGHT)
   Box(2,2,WindowWidth(0) - 4,23,Ex\CLRLIGHT)
  StopDrawing()
EndProcedure

;-ExGadget
Structure ExGadget
  WinHandle.i
  Type.l
  X.l
  Y.l
  Width.l
  Height.l
 
  Name.s
  ValueA.f
  ValueB.f
  ValueC.f
  ValueD.f
  Option.l
EndStructure
Global NewList ExGadget.ExGadget()

Procedure ScrollBarExGadget(x.l, y.l, Width.l, Height.l, Min.l, Max.l, Len.l , Options=0)
  AddElement(ExGadget())
  ExGadget()\WinHandle=ExWindow()
  ExGadget()\X=x
  ExGadget()\Y=y
  ExGadget()\Width=width
  ExGadget()\Height=height
  ExGadget()\ValueA=Min
  ExGadget()\ValueB=Max
  ExGadget()\ValueC=Len
EndProcedure

Procedure ResizeExGadget(Handle.l,x.l, y.l, Width.l, Height.l)
  If Handle<>0
    ChangeCurrentElement(ExGadget(),Handle)   
  EndIf
  If x<>#PB_Ignore:ExGadget()\X=x:EndIf
  If y<>#PB_Ignore:ExGadget()\X=y:EndIf
  If Width<>#PB_Ignore:ExGadget()\X=Width:EndIf
  If Height<>#PB_Ignore:ExGadget()\X=Height:EndIf
EndProcedure

Procedure RenderExGadget()
  ForEach ExGadget()
    If ExGadget()\WinHandle=ExWindow()
      Select ExGadget()\Type
        Case 0
          If Option=0
          ExDrawRect(ExGadget()\X,ExGadget()\Y,ExGadget()\Height,ExGadget()\Height,0)
          ExDrawRect(ExGadget()\X+ExGadget()\Width-ExGadget()\Height,ExGadget()\Y,ExGadget()\Height,ExGadget()\Height,0)
          ExDrawRect(ExGadget()\X+ExGadget()\Height,ExGadget()\Y,ExGadget()\Width-ExGadget()\Height*2,ExGadget()\Height,2)
          bwidth=(ExGadget()\Width-ExGadget()\Height*2)-(ExGadget()\ValueB-ExGadget()\ValueA)
         
          ExDrawRect(ExGadget()\X+ExGadget()\Height,ExGadget()\Y+2,bwidth,ExGadget()\Height-4,1)
         
          EndIf
      EndSelect
    EndIf
  Next
EndProcedure




;-WorkBench Procedure
Procedure AddLayer(Image.i=0)
  ;si on a pas de n° d'image dans les paramètres alors on créer l'image en fonction de l'image de rendu
  If Image=0
    Image=CreateImage(#PB_Any,ImageWidth(Workbench()\RenderImage),ImageHeight(Workbench()\RenderImage),ImageDepth(Workbench()\RenderImage))
  EndIf
  Workbench()\NbLayer+1 ;On ajoute un calque
  Workbench()\Layers.Layer[Workbench()\NbLayer]\Active=#True  ;On l'active
  Workbench()\Layers.Layer[Workbench()\NbLayer]\Image=Image   ;l'image du calque
  Workbench()\Layers.Layer[Workbench()\NbLayer]\Opacity=255   ;L'opacité du calque
  Workbench()\Layer=Workbench()\NbLayer ; Et part defaut on selectionne le calque qu'on vient d'ajouter
EndProcedure

;Rendu des calques
Procedure RenderLayers()
  Protected z.l
  ;Le rendu des calques se fait sur l'image de rendu
  StartDrawing(ImageOutput(Workbench()\RenderImage))
  For z=1 To Workbench()\NbLayer ; je dessine chaque calque
    ;Si le calque est bien visible(activé)
    DrawingMode(#PB_2DDrawing_AlphaClip)
    If Workbench()\Layers.Layer[z]\Active=#True
      DrawAlphaImage(ImageID(Workbench()\Layers.Layer[z]\Image),0,0,Workbench()\Layers.Layer[z]\Opacity)
    EndIf
  Next
  StopDrawing()
EndProcedure


;Pour écrire sur le calque selectionné
Procedure WriteLayerPixel(x.l,y.l,Color.l)
  Select ToolsInfo\ToolRenderMode

    ;Si l'outil doit écrire avec une couleur
    Case #ModeCouleur
       Protected Image.i=Workbench()\Layers.Layer[Workbench()\Layer]\Image
         Protected Width.l,Height.l
  Width=ExWindowWidth(Workbench()\Window)-20
  If Width>ImageWidth(Workbench()\RenderImage)*Workbench()\Zoom
    Width=ImageWidth(Workbench()\RenderImage)*Workbench()\Zoom
  EndIf
  If Width<1
    Width=1
  EndIf

  Height=ExWindowHeight(Workbench()\Window)-20
  If Height>ImageHeight(Workbench()\RenderImage)*Workbench()\Zoom
    Height=ImageHeight(Workbench()\RenderImage)*Workbench()\Zoom
  EndIf
  If Height<1
    Height=1
  EndIf
       Dx=(ExWindowWidth(Workbench()\Window)-Width)/2
       Dy=26+(ExWindowHeight(Workbench()\Window)-Height-26)/2
        x=(x-ExWindowX(Workbench()\Window)-Dx)/Workbench()\Zoom
        y=(y-ExWindowY(Workbench()\Window)-Dy)/Workbench()\Zoom
        StartDrawing(ImageOutput(Image))
          If x>0 And x<ImageWidth(Image) And y>0 And y<ImageHeight(Image)
            Plot(x,y,Color)
          EndIf
        StopDrawing()
   
    ;Si l'outil doit écrire avec un dégradé
    Case #ModeGradiant
   
    ;Si l'outil doit écrire avec un motif
    Case #ModePattern
   
  EndSelect
EndProcedure

Procedure RefreshWindow()
  Protected Max.l,DeltaX.l,DeltaY.l
  ;Je modifie le nom de la fenêtre car elle contient des informations sur le nom le zoom et la profondeur de l'image

  SetExWindowTitle(Workbench()\Window, GetFilePart(Workbench()\FileName)+" @ "+Str(Abs(Workbench()\Zoom*100))+"%"+" (Layer"+Str(Workbench()\Layer)+",???/"+Str(ImageDepth(Workbench()\RenderImage))+")")

  ;Dans le cas d'un redimensionnement de la fenêtre je redimenssione les ScrollBar
  ResizeExGadget(Workbench()\GdtScrollBarV,ExWindowWidth(Workbench()\Window)-20, 0, 20, ExWindowHeight(Workbench()\Window))
  Max=ImageHeight(Workbench()\RenderImage)*Workbench()\Zoom-ExWindowHeight(Workbench()\Window)-20
  If Max<0:Max=0:EndIf
  ;SetGadgetAttribute(Workbench()\GdtScrollBarV,#PB_ScrollBar_Maximum,Max)

  ResizeExGadget(Workbench()\GdtScrollBarH,100, ExWindowHeight(Workbench()\Window)-20, ExWindowWidth(Workbench()\Window)-120, 20)
  Max=ImageWidth(Workbench()\RenderImage)*Workbench()\Zoom-ExWindowWidth(Workbench()\Window)-20
  If Max<0:Max=0:EndIf
  ;SetGadgetAttribute(Workbench()\GdtScrollBarH,#PB_ScrollBar_Maximum,Max)

  RenderLayers();Je fait un rendu complet

;Une fois le rendu finit je créer l'image qui sera affiché dans la fenêtre
  If IsImage(Workbench()\WorkImage)
    FreeImage(Workbench()\WorkImage)
  EndIf

  ;Position des ScrollsBar
  DeltaX=0;GetGadgetState(Workbench()\GdtScrollBarH)
  DeltaY=0;GetGadgetState(Workbench()\GdtScrollBarV)

  ;Calcul de la taille de l'image affiché dans la fenêtre
  Protected Width.l,Height.l
  Width=ImageWidth(Workbench()\RenderImage)*Workbench()\Zoom
  If Width>ExWindowWidth(Workbench()\Window)
    Width=ExWindowWidth(Workbench()\Window)
  EndIf
  If Width<1
    Width=1
  EndIf

  Height=ImageHeight(Workbench()\RenderImage)*Workbench()\Zoom
  If Height>ExWindowHeight(Workbench()\Window)
    Height=ExWindowHeight(Workbench()\Window)
  EndIf
  If Height<1
    Height=1
  EndIf

  ;tmp=GrabImage(Workbench()\RenderImage,#PB_Any,0)
  
  Workbench()\WorkImage=GrabImage(Workbench()\RenderImage,#PB_Any,0,0,Width/Workbench()\Zoom,Height/Workbench()\Zoom)
  ResizeImage(Workbench()\WorkImage,Width,Height,#PB_Image_Raw)
  ;Workbench()\WorkImage=CreateImage(#PB_Any,Width,Height,ImageDepth(Workbench()\RenderImage)) ; je créer l'image
  ;On affiche la partie de l'image qui est visible
  ;StartDrawing(ImageOutput(Workbench()\WorkImage))
  ;  DrawImage(ImageID(tmp),-DeltaX,-DeltaY,ImageWidth(Workbench()\RenderImage)*Workbench()\Zoom,ImageHeight(Workbench()\RenderImage)*Workbench()\Zoom)
  ;StopDrawing()
  ;FreeImage(tmp)
  ;
   StartDrawing(SpriteOutput(ExWindow()\Sprite))
    XImage=(ExWindowWidth(Workbench()\Window)-Width)/2
    YImage=26+(ExWindowHeight(Workbench()\Window)-Height-26)/2
    Box(XImage-1,YImage-1,Width+2,Height+2,#Black)
    DrawImage(ImageID(Workbench()\WorkImage),XImage,YImage,Width,Height)
   
    ;Grille
    If Workbench()\Zoom>3
      z.f=0
      Repeat
        z=z+Workbench()\Zoom
        Line(XImage+z,YImage,1,Height,#Black)
      Until z>=Width
      z=0
      Repeat
        z=z+Workbench()\Zoom
        Line(XImage,YImage+z,Width,1,#Black)
      Until z>=Height
    EndIf
  StopDrawing()

EndProcedure

;Ouverdure d'une image ou creation d'un nouveau document
Procedure NewDocument(Name.s="")
  Protected Image.i
  AddElement(Workbench())
  If Name=""
    Name.s="Untitled "+Str(ListSize(Workbench()))
  EndIf
  Workbench()\FileName=Name

    If FileSize(Workbench()\FileName)>0
      Image=LoadImage(#PB_Any,Workbench()\FileName)
    Else
      Image=CreateImage(#PB_Any,320,200,32);Il faudra ici mettre des variables pour la taille part defaut (peut être prendre la taille de l'image si dans le presse papier)
      StartDrawing(ImageOutput(Image))
        Box(0,0,320,200,#Red)
        Circle(50,50,25,#Blue)
      StopDrawing()
    EndIf
   
    ;Ouverture de la fenêtre contenant l'image
    Workbench()\Window=OpenExWindow(ExWindowWidth(InterfaceInfo\WinTools)+ListIndex(Workbench())*16, 25+ListIndex(Workbench())*16, 640, 480, "",#PB_Window_Tool|#PB_Window_TitleBar|#PB_Window_SizeGadget|#PB_Window_SystemMenu)
    ;Creation des gadgets
    ;Workbench()\GdtScrollBarV=ScrollBarExGadget(ExWindowWidth(Workbench()\Window)-20, 0, 20, ExWindowHeight(Workbench()\Window),0,0,10,#PB_ScrollBar_Vertical)
    Workbench()\GdtScrollBarH=ScrollBarExGadget(100, ExWindowHeight(Workbench()\Window)-20, ExWindowWidth(Workbench()\Window)-120, 20,0,0,10)
    ;On definit une Image pour le rendu final des calques
    Workbench()\RenderImage=CreateImage(#PB_Any,ImageWidth(Image),ImageHeight(Image),ImageDepth(Image))
    ;On definit le Zoom en fonction de la taille de l'image et de la fenêtre
    Workbench()\Zoom=ExWindowWidth(Workbench()\Window)/ImageWidth(Image)
    AddLayer(Image);On créer le premier calque du document
    RefreshWindow();On rafraichissement


    *FirstElement = ExWindow()
    LastElement(ExWindow())
    *LastElement = ExWindow()
    SwapElements(ExWindow(),*FirstElement,*LastElement)

EndProcedure


; Open Screen
OpenWindow(0,0,0,1024,768,"PBPhoto",#PB_Window_SystemMenu | #PB_Window_ScreenCentered |#PB_Window_SizeGadget)
OpenWindowedScreen(WindowID(0),0,0,1024,768,0,0,0)

InterfaceInfo\WinTools=OpenExWindow(0,25,100,250,"Tools")

EnableWindowDrop(0,#PB_Drop_Files,#PB_Drag_Copy)

NewDocument("1-avatar.jpg")
;NewDocument()
;NewDocument()
; Mouse Pointer
lpBuffer = AllocateMemory(630)
UnpackMemory(?Cursor,lpBuffer)
CatchSprite(0,lpBuffer)
TransparentSpriteColor(0,RGB(0,128,128))
FreeMemory(lpBuffer)

Repeat
  Event = WindowEvent()   
   
  If inscreen
    If MouseX()>WindowWidth(0)-2 Or MouseY()>WindowHeight(0)-2 Or MouseX()<1 Or MouseY()<1
      ReleaseMouse(1)
      inscreen = #False
    EndIf
  Else
    ;
    ;************************************
    ;    Handle #PB_Event_Gadget Here
    ;************************************
    If Event= #PB_Event_SizeWindow
      ;OpenWindowedScreen(WindowID(0),0,0,WindowWidth(0)+10,WindowHeight(0)+10,0,0,0)
    EndIf
    
    If Event = #PB_Event_WindowDrop 
      Debug "Coucou"
       Debug EventDropFiles()
    EndIf
    
    If Event = #PB_Event_Gadget
      If EventGadget() = 1
        MessageRequester("","You pressed the button!")
      EndIf
    EndIf
   
    ;On verifie si on est dans l'ecran
    mx = WindowMouseX(0):my = WindowMouseY(0)
    If mx < WindowWidth(0)-2 And mx > 0 And my > 0 And my < WindowHeight(0)-2
      ReleaseMouse(0)
      MouseLocate(mx,my)
      inscreen = #True
    EndIf
  EndIf
 
  ;On Se positionne sur le bon Document
  If LastWindow<>GetActiveExWindow()
    ForEach Workbench() ;On cherche a retrouver le document propre a la fenêtre   active
      If Workbench()\Window=GetActiveExWindow() ;Hop on l'a trouvé
         Break;
      EndIf
    Next
   LastWindow=GetActiveExWindow();Je mémorise la fenêtre histoire de ne pas faire la recherche a chaque boucle
  EndIf 
   
   
  ClearScreen(Ex\CLRHILIGHT)
  ExamineKeyboard()
  ExamineExGUI():RenderExMenu()
   
  If inscreen  ; manage mouse events only if mouse is inside screen
    Event=WindowEvent()
    
    If Event = #PB_Event_WindowDrop 
      Debug "Coucou"
      Debug EventDropFiles()
      NewDocument(EventDropFiles())
    EndIf
    
    ExamineMouse()

    If MouseButton(#PB_MouseButton_Left) And Ex\WINZONE=0
      RefreshWindow()
      WriteLayerPixel(MouseX(),MouseY(),#Red)
    EndIf

    If MouseWheel()
      If Workbench()\Zoom+MouseWheel()*0.1>0
      Workbench()\Zoom+MouseWheel()*0.1
      
      EndIf
      RefreshWindow()
    EndIf
  DisplayTransparentSprite(0,MouseX(),MouseY())
  EndIf
 
  LastElement(ExWindow())
  
  FlipBuffers()

Until KeyboardPushed(1) Or Event = #PB_Event_CloseWindow
   
   
   
   ;   ExamineKeyboard() : ExamineMouse() :ExamineExGUI():RenderExMenu()
  ;

; -------------------------------------------------------------------
; DATA SECTION
; -------------------------------------------------------------------

DataSection
   Cursor:
   Data.l $0276434A,$4A720000,$A9B7AACC,$146320D0,$284A6811,$01232023,$9188409D,$F3000461,$20492601,$0A0401E0
   Data.l $E00081C0,$FFC0E015,$09302024,$409C3C04,$66013801,$FE4D02B6,$91FB77FB,$B7C236B7,$BDF63086,$BFEC1EC1
   Data.l $C0F36107,$0F625EF7,$008A083D,$87FFF581,$C4592A11,$4287C926,$3EC90540,$69F6974F,$21E5E328,$DDDE6107
   Data.l $50B353C6,$0FB86C06,$0000D893
   Data.b $90,$48
EndDataSection
Avatar de l’utilisateur
Ar-S
Messages : 9539
Inscription : dim. 09/oct./2005 16:51
Contact :

Re: Un photoshop Like !

Message par Ar-S »

super :)

2 petits bugs

1 - Le menuhaut de la fenêtre est tronqué lorsqu'on drag n drop une image
http://ldvmultimedia.free.fr/temp/err1.jpg

2 - Si l'image drag n dropé as le focus et que l'on clique sur la tool barre, la tool barre passe au 1er plan mais la fenêtre 2 aussi
http://ldvmultimedia.free.fr/temp/err2.jpg

voilou :)
~~~~Règles du forum ~~~~
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
Avatar de l’utilisateur
Thyphoon
Messages : 2706
Inscription : mer. 25/août/2004 6:31
Localisation : Eragny
Contact :

Re: Un photoshop Like !

Message par Thyphoon »

Ar-S a écrit :super :)
mais il reste du boulot :p
Ar-S a écrit : 2 petits bugs

1 - Le menuhaut de la fenêtre est tronqué lorsqu'on drag n drop une image
http://ldvmultimedia.free.fr/temp/err1.jpg
Oui j'avais vu ça ... vu que j'ai changé ma façon de zoomer je dois aussi revoir la façon dont je dessine cette fenêtre
Ar-S a écrit : 2 - Si l'image drag n dropé as le focus et que l'on clique sur la tool barre, la tool barre passe au 1er plan mais la fenêtre 2 aussi
http://ldvmultimedia.free.fr/temp/err2.jpg
voilou :)
Oui car en verité actuellement la fenêtre qui perd le focus se retrouve tout derrière ...

Bon ba il me reste du boulot lollllllllllllll
Le Soldat Inconnu
Messages : 4312
Inscription : mer. 28/janv./2004 20:58
Localisation : Clermont ferrand OU Olsztyn
Contact :

Re: Un photoshop Like !

Message par Le Soldat Inconnu »

Je reprends le sujets après un petit moment sans l'avoir lu (j'ai pas tout lu d'ailleurs, j'ai repris la fin du sujet), te me sembles partis sur une interface bien compliquée.

Pour quoi ne pas utiliser un MDIGadget, ce serait tellement plus simple ?
Je te fais un truc vite fais
Je ne suis pas à moitié Polonais mais ma moitié est polonaise ... Vous avez suivi ?

[Intel quad core Q9400 2.66mhz, ATI 4870, 4Go Ram, XP (x86) / 7 (x64)]
Le Soldat Inconnu
Messages : 4312
Inscription : mer. 28/janv./2004 20:58
Localisation : Clermont ferrand OU Olsztyn
Contact :

Re: Un photoshop Like !

Message par Le Soldat Inconnu »

Comme cela

Code : Tout sélectionner

UsePNGImageDecoder()
UsePNGImageEncoder()
UseJPEGImageDecoder()
UseJPEGImageEncoder()
UseJPEG2000ImageDecoder()
UseJPEG2000ImageEncoder()

#Image_StatusBar_Field1_Width = 128
#Image_StatusBar_Field2_Width = 128
#Image_Window_MinimumHeight = 128
#Image_Window_MinimumWidth = 256

Structure StructurePaper
	Window.i ; To link this paper to one image
	Image.i ; Image ID
	Order.i ; Paper order
	x.i ; Paper display position
	y.i
EndStructure
Global NewList Paper.StructurePaper()
Structure StructureWindowInfo
	Window.i
	StatusBar.i
	Compile.i
	Title.s
	File.s
	Zoom.l
	SaveNeeded.b
	Width.l
	Height.l
EndStructure
Global NewList Image.StructureWindowInfo()

Global NewList Zoom.l()
AddElement(Zoom()) : Zoom() = 1
AddElement(Zoom()) : Zoom() = 2
AddElement(Zoom()) : Zoom() = 5
AddElement(Zoom()) : Zoom() = 10
AddElement(Zoom()) : Zoom() = 25
AddElement(Zoom()) : Zoom() = 50
AddElement(Zoom()) : Zoom() = 75
AddElement(Zoom()) : Zoom() = 100
AddElement(Zoom()) : Zoom() = 150
AddElement(Zoom()) : Zoom() = 200
AddElement(Zoom()) : Zoom() = 300
AddElement(Zoom()) : Zoom() = 400
AddElement(Zoom()) : Zoom() = 500
AddElement(Zoom()) : Zoom() = 600
AddElement(Zoom()) : Zoom() = 800
AddElement(Zoom()) : Zoom() = 1000


Enumeration
	#Editor
	#Editor_MDI
	#Editor_StatusBar
	#Editor_Menu
	#Editor_Menu_File_New
	#Editor_Menu_File_Open
	#Editor_Menu_File_Save
	#Editor_Menu_File_SaveAs
	#Editor_Menu_File_Close
	#Editor_Menu_File_RecentFiles
	#Editor_Menu_Window_Minimize
	#Editor_Menu_Window_Maximize
	#Editor_Menu_Window_Vertically
	#Editor_Menu_Window_Horizontally
	#Editor_Menu_Window_Cascade
EndEnumeration

Procedure Image_Display()
	StartDrawing(WindowOutput(Image()\Window))
		
	StopDrawing()
EndProcedure
Procedure Image_Compile()
	StartDrawing(ImageOutput(Image()\Compile))
		
	StopDrawing()
EndProcedure
Procedure Image_SizeWindow()
	
EndProcedure
Procedure Image_Save(SaveAs.b = 0)
	; Here, save image
	; Return 0 if save is cancelled, else 1
	ProcedureReturn 1
EndProcedure
Procedure Image_Close()
	If Image()\SaveNeeded
		If Image_Save() = 0
			ProcedureReturn
		EndIf
	EndIf
	; Close all data from this image
	ForEach Paper()
		If Paper()\Window = Image()\Window
			FreeImage(Paper()\Image)
			DeleteElement(Paper())
		EndIf
		CloseWindow(Image()\Window)
		FreeImage(Image()\Compile)
		DeleteElement(Image())
	Next
EndProcedure
Procedure Image_StatusBar()
	StatusBarText(Image()\StatusBar, 0, "Zoom " + Str(Image()\Zoom) + "%", #PB_StatusBar_BorderLess)
	StatusBarText(Image()\StatusBar, 1, Str(Image()\Width) + "x" + Str(Image()\Height), #PB_StatusBar_BorderLess)
EndProcedure
Procedure.l Image_ZoomAuto()
	ForEach Zoom()
		If Zoom() = 100
			Break
		EndIf
	Next
	MaxWidth = WindowWidth(Image()\Window)
	MaxHeight = WindowHeight(Image()\Window) - StatusBarHeight(Image()\StatusBar)
	While Image()\Height * Zoom() / 100 > MaxHeight And Zoom() > 1
		PreviousElement(Zoom())
	Wend
	While Image()\Width * Zoom() / 100 > MaxWidth And Zoom() > 1
		PreviousElement(Zoom())
	Wend
	ProcedureReturn Zoom()
EndProcedure

Procedure Editor_NewImage(File.s = "")
	If File
		Image = LoadImage(#PB_Any, File)
	EndIf
	If File And Image And IsImage(Image) ; Open image
		Title.s = GetFilePart(File)
		SaveNeeded = 0
	Else ; Create new image
		; Here, display window to select image size and title
		Title.s = "Nouveau"
		Image = CreateImage(#PB_Any, 100, 100, 32)
		SaveNeeded = 1
	EndIf
	
	AddElement(Image())
	Image()\File = File
	Image()\Title = Title
	Image()\Window = AddGadgetItem(#Editor_MDI, #PB_Any, Title, 0, #PB_Window_SizeGadget | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget)
	If Image()\Window
		WindowBounds(Image()\Window, #Image_Window_MinimumWidth, #Image_Window_MinimumHeight, #PB_Ignore, #PB_Ignore)
		Image()\StatusBar = CreateStatusBar(#PB_Any, WindowID(Image()\Window))
		If Image()\StatusBar
			AddStatusBarField(#Image_StatusBar_Field1_Width)
			AddStatusBarField(#Image_StatusBar_Field2_Width)
		EndIf
		Image()\Width = ImageWidth(Image)
		Image()\Height = ImageHeight(Image)
		Image()\Zoom = Image_ZoomAuto()
		ResizeWindow(Image()\Window, #PB_Ignore, #PB_Ignore, Image()\Width * Image()\Zoom / 100, Image()\Height * Image()\Zoom / 100 + StatusBarHeight(Image()\StatusBar))
		Image()\SaveNeeded = SaveNeeded
		Image()\Compile = CreateImage(#PB_Any, Image()\Width, Image()\Height, 32)
		AddElement(Paper())
		Paper()\Window = Image()\Window
		Paper()\Image = Image
		Image_StatusBar()
	Else
	DeleteElement(Image())
EndIf
EndProcedure
Procedure Editor_OpenImage()
	File.s = OpenFileRequester("Ouvrir une image", "", "Tous les formats d'image supportés" + "|*.jpg;*.png;*.bmp", 1, #PB_Requester_MultiSelection)
	While File And FileSize(File) > 0
		Editor_NewImage(File)
		File = NextSelectedFileName()
	Wend
EndProcedure




If OpenWindow(#Editor, 0, 0, 500, 500, "PurePhoto", #PB_Window_MaximizeGadget | #PB_Window_Maximize | #PB_Window_MinimizeGadget | #PB_Window_SizeGadget | #PB_Window_WindowCentered)
	
	If CreateStatusBar(#Editor_StatusBar, WindowID(#Editor))
		
	EndIf
	If CreateMenu(#Editor_Menu, WindowID(#Editor))
		MenuTitle("Fichier")
		MenuItem(#Editor_Menu_File_New, "Nouvelle" + Chr(9) + "Ctrl+N")
		MenuItem(#Editor_Menu_File_Open, "Ouvrir" + Chr(9) + "Ctrl+O")
		AddKeyboardShortcut(#Editor, #PB_Shortcut_Control | #PB_Shortcut_O, #Editor_Menu_File_Open)
		MenuBar()
		MenuItem(#Editor_Menu_File_Save, "Enregistrer" + Chr(9) + "Ctrl+S")
		MenuItem(#Editor_Menu_File_SaveAs, "Enregistrer sous" + Chr(9) + "Ctrl+Maj+S")
		MenuBar()
		MenuItem(#Editor_Menu_File_Close, "Fermer" + Chr(9) + "Alt+F4")
		
		MenuTitle("Fenêtres")			
		MenuItem(#Editor_Menu_Window_Maximize, "Agrandir")
		MenuItem(#Editor_Menu_Window_Minimize, "Réduire")
		MenuBar()
		MenuItem(#Editor_Menu_Window_Cascade, "Cascade")
		MenuItem(#Editor_Menu_Window_Vertically, "Mosaique verticalle")
		MenuItem(#Editor_Menu_Window_Horizontally, "Mosaique horizontalle")
		
	EndIf
	MDIGadget(#Editor_MDI, 0, 0, 100, 100, 1, 6, #PB_MDI_BorderLess | #PB_MDI_AutoSize)
	
	Quit = 0
	Repeat
		Event = WaitWindowEvent()
		Select EventWindow()
			Case #Editor ; Main window event
				Select Event
					Case #PB_Event_CloseWindow
						ForEach Image() ; Close all Image
							Image_Close()
						Next
						If ListSize(Image()) = 0 ; If all image are closed, we can quit program
							Quit = 1
						EndIf
						
					Case #PB_Event_Menu
						Select EventMenu()
							Case #Editor_Menu_File_New
								Editor_NewImage()
							Case #Editor_Menu_File_Open
								Editor_OpenImage()
						EndSelect
				EndSelect
				
				
			Default
				ForEach Image() ; Acion on image window
					If Image()\Window = EventWindow()
						Select Event
							Case #PB_Event_CloseWindow
								Image_Close()
							Case #PB_Event_Repaint
								Image_Display()
							Case #PB_Event_SizeWindow
								Image_SizeWindow()
						EndSelect
					EndIf
				Next
		EndSelect
		
		
	Until Quit = 1
	
EndIf
Vous pouvez ouvrir un image, créer une nouvelle image.
L'image se charge mais ne s'affiche pas. Il faut voir comment faire, j'ai pas fouiller.
La procedure Image_Compile() doit assembler tous les calques
et Image_Display() doit afficher l'image sur la fenêtre
Je ne suis pas à moitié Polonais mais ma moitié est polonaise ... Vous avez suivi ?

[Intel quad core Q9400 2.66mhz, ATI 4870, 4Go Ram, XP (x86) / 7 (x64)]
Avatar de l’utilisateur
venom
Messages : 3128
Inscription : jeu. 29/juil./2004 16:33
Localisation : Klyntar
Contact :

Re: Un photoshop Like !

Message par venom »

oui moi j'avais penser a ce genre d'interface au départ avec les fenêtres mère fille.
Comme sa même en cas de zoom tu as automatiquement les scrollbar :wink: ce n'est qu'un détail mais bon.
sa t'évite de tout dessiné et je pense que sa prend plus de mémoire non ?
fin après tu voie Thyphoon :P







@++
Windows 10 x64, PureBasic 5.73 x86 & x64
GPU : radeon HD6370M, CPU : p6200 2.13Ghz
Avatar de l’utilisateur
Thyphoon
Messages : 2706
Inscription : mer. 25/août/2004 6:31
Localisation : Eragny
Contact :

Re: Un photoshop Like !

Message par Thyphoon »

Merci SLI :D ! J'avais abandonné les fenêtres MDI car c'est Windows Only ! Mais c'est vrai que sinon c'est ce qui a de plus pratique.
Helas il y a d'autre problème... j'étais aller un peu plus loin que toi durant mon test, si tu utilises cette technique alors faudra faire appel aux APIs pour détecter si une touche est actionné et pour quelques manques de PB (Et j'avoue que je ne suis pas du tout fan des APIs, (portabilité du code, et peut être aussi part méconnaissance))! Sans compter des problèmes de clignotement de l'image dans la fenêtre, et quelques autres truc que j'ai vu durant mes tests. Comme le bug de ButtonImageGadget et compagnie ...

J'aimerais bien prouvé qu'on peut faire du code multiplateforme ! Qu'en penses tu ? :|

j'avais proposé plusieurs code, pour demandé un avis. Un code utilisant que les fenêtre, un autre avec Fenêtre et openwindowscreen, et un autre avec un ScreenGUi. Et il fallait faire un choix, c'est pour ça que je me suis tourné au final vers une ScreenGui (faut tout faire, mais on a tout ce qu'il faut avec les commandes PB d'origine).
Mais j'aurais peut être du attendre plus d'avis...

Je vais attendre un peu voir ce que tu me reponds, et au besoin continuer ton code voir le fusionner avec le mien ! 8)
Le Soldat Inconnu
Messages : 4312
Inscription : mer. 28/janv./2004 20:58
Localisation : Clermont ferrand OU Olsztyn
Contact :

Re: Un photoshop Like !

Message par Le Soldat Inconnu »

Et tu as essayé avec OpenWindow3D ? j'ai jamais essayé.

Sinon, cela signifie qu'il faut émuler le MDI sur Linux et Mac. ce pas sorcier je pense de créer des fenêtres filles et de les positionner au dessus de la principale.
Autant partir sur de la fenêtre émuler depuis le début.


Ensuite coté affichage, tu me parles de clignotement.

J'ai pensé à ceci :
Fenêtre sans le focus, on affiche dans un ImageGadget
Fenêtre avec le focus, on affiche dans OpenWindowedScreen.
Donc un OpenWindowedScreen que l'on bascule d'une fenêtre à l'autre en fonction de la fenêtre qui a le focus.

C'est juste une idée
Je ne suis pas à moitié Polonais mais ma moitié est polonaise ... Vous avez suivi ?

[Intel quad core Q9400 2.66mhz, ATI 4870, 4Go Ram, XP (x86) / 7 (x64)]
Avatar de l’utilisateur
Thyphoon
Messages : 2706
Inscription : mer. 25/août/2004 6:31
Localisation : Eragny
Contact :

Re: Un photoshop Like !

Message par Thyphoon »

Le Soldat Inconnu a écrit :Et tu as essayé avec OpenWindow3D ? j'ai jamais essayé.
J'avoue que nom ! mais je crois que ça utilise le moteur de Ogre non ? pas trop lourd d'utiliser ça pour une application de dessin ? Que que ...Faut que je regarde ça de plus prêt
Le Soldat Inconnu a écrit : Sinon, cela signifie qu'il faut émuler le MDI sur Linux et Mac. ce pas sorcier je pense de créer des fenêtres filles et de les positionner au dessus de la principale.
Autant partir sur de la fenêtre émuler depuis le début.
Pas idiot ! ....mais il reste un problème
http://www.purebasic.fr/french/viewtopic.php?f=6&t=9996

Le Soldat Inconnu a écrit : Ensuite coté affichage, tu me parles de clignotement.

J'ai pensé à ceci :
Fenêtre sans le focus, on affiche dans un ImageGadget
Fenêtre avec le focus, on affiche dans OpenWindowedScreen.
Donc un OpenWindowedScreen que l'on bascule d'une fenêtre à l'autre en fonction de la fenêtre qui a le focus.

C'est juste une idée
J'ai déjà eu exactement la même idée, le code est d'ailleurs dans ce sujet (a condition que ça ne soit pas celui que j'ai mis a jour hier part erreur)
Il n'aime pas trop qu'on ouvre et qu'on ferme l'openwindowed Screen et le redimensionnement est l'ecran est un peu lourd.
Le Soldat Inconnu
Messages : 4312
Inscription : mer. 28/janv./2004 20:58
Localisation : Clermont ferrand OU Olsztyn
Contact :

Re: Un photoshop Like !

Message par Le Soldat Inconnu »

après, pour dessiner l'image, c'est comme pour mon sélecteur de couleur, tu dessines directement sur la fenêtre.



une idée comme ça, pourquoi ne pas remplacer le principe de la fenêtre MDI par un système d'onglet comme FireFox
Ca pourrait être super sympa comme idée

Une liste d'onglet (dessiner avec imagegadget) et dessous un openwindowedscreen pour afficher l'image (toujours le même screen quelque soit l'onglet)
Je ne suis pas à moitié Polonais mais ma moitié est polonaise ... Vous avez suivi ?

[Intel quad core Q9400 2.66mhz, ATI 4870, 4Go Ram, XP (x86) / 7 (x64)]
Avatar de l’utilisateur
Thyphoon
Messages : 2706
Inscription : mer. 25/août/2004 6:31
Localisation : Eragny
Contact :

Re: Un photoshop Like !

Message par Thyphoon »

Désolé de repondre si tardivement, mais panne internet a la maison greve dans les transports, greve au boulot, et manque de temps ...

Dessiné sur la fenêtre directement le souci c'est que ça clignotte des que la fenêtre est un peu grande.je pense que c'est du au manque de synchro par rapport a un flipbuffer().

L'idée des onglets est pas bêtes, je sais que lorsque je bosse sur photoshop j'aime bien dans certain cas avoir 2 images l'une a côté de l'autre...

Je vais faire d'autre essais ! des que j'aurais le temps (les vacances approche...) je te tient au courant !
Répondre