Une loupe qui suit la souris

Programmation d'applications complexes
Le Soldat Inconnu
Messages : 4312
Inscription : mer. 28/janv./2004 20:58
Localisation : Clermont ferrand OU Olsztyn
Contact :

Une loupe qui suit la souris

Message par Le Soldat Inconnu »

Salut,

Une petite loupe ronde qui suis la souris

Vous avez besoin des librairie "Effect", "IconEx" et "SkinWindow" (que j'avais zappé) que vous trouverez sur mon site
La version sans lib est plus bas, pour ceux qui veulent pas s'embêter a utiliser mes MAGNIFIQUES lib :roll: :lol: quoi ? elles sont pas belles ? *boude* :mrgreen:

Code : Tout sélectionner

; Auteur : Le Soldat Inconnu
; Version de PB : 4.0
;
; Explication du programme :
; Fait un effet de loupe sur votre écran (comme ci une sphèse se déplace au dessus en déformant l'image)

Global Zoom.f, x.l, y.l, x.l, y.l, Rayon.l, Taille.l, Lissage.l
Global Souris_x, Souris_y, Souris_x_mem, Souris_y_mem
Global Ecran_Largeur, Ecran_Hauteur

Global Dim Image(0, 0)
Global Dim Image2(0, 0)

#Decalage_Fenetre = 0.45
#Rafraichissement = 25
#Limite_Lissage = 10

Procedure LoadPackIcon(Mem)
  Taille = PeekL(Mem)
  Mem2 = AllocateMemory(Taille)
  If Mem2
    UnpackMemory(Mem + 4, Mem2)
    IconEx_LoadIconData(Mem2)
    FreeMemory(Mem2)
  EndIf
EndProcedure

Procedure Dimension()
  Taille = 2 * Rayon + 1
  ResizeWindow(0, #PB_Ignore, #PB_Ignore, Taille, Taille)
  ResizeImage(0, Taille, Taille)
  StartDrawing(ImageOutput(0))
    Box(0, 0, Taille, Taille, $FF00FF)
    
    For n = -Rayon To Rayon
      For nn = -Rayon To Rayon
        y = Rayon + nn : x = Rayon + n
        
        Longueur.f = Sqr(n * n + nn * nn) ; On calcul la distance d'un point de la sphère à partir du centre
        If Longueur < Rayon ; And Longueur > 1
          Plot(x, y, 0)
        EndIf
          
      Next
    Next
    
    
  StopDrawing()
  ResizeImage(1, Taille, Taille)
  SkinWindow(WindowID(0), ImageID(0))
  Dim Image(Taille - 1, Taille - 1)
  Dim Image2(Taille - 1, Taille - 1)
  Lissage = 1
EndProcedure

Procedure Sauver()
  If CreatePreferences("Loupe.ini")
    WritePreferenceLong("Taille", Rayon)
    WritePreferenceFloat("Zoom", Zoom)
    ClosePreferences()
  EndIf
EndProcedure
Procedure Charger()
  OpenPreferences("Loupe.ini")
  Rayon = ReadPreferenceLong("Taille", 100)
  Zoom = ReadPreferenceFloat("Zoom", 2)
  ClosePreferences()
EndProcedure

Procedure DeplaceLoupe()
  
  Souris_x = DesktopMouseX()
  Souris_y = DesktopMouseY()
  ; If Souris_x <> Souris_x_mem Or Souris_y <> Souris_y_mem Or Lissage = 1 ; Si la souris a bougé ou si on réactive le lissage
    ; Souris_x_mem = Souris_x
    ; Souris_y_mem = Souris_y
    
    ; Position de la fenêtre
    Fenetre_x = Souris_x + Rayon * #Decalage_Fenetre
    Fenetre_y = Souris_y + Rayon * #Decalage_Fenetre
    If Fenetre_x + Taille >= Ecran_Largeur
      Fenetre_x = Souris_x - Rayon * #Decalage_Fenetre - Taille
    EndIf
    If Fenetre_y + Taille >= Ecran_Hauteur
      Fenetre_y = Souris_y - Rayon * #Decalage_Fenetre - Taille
    EndIf
    ; Fenetre_x = Souris_x - Rayon
    ; Fenetre_y = Souris_y - Rayon
    ResizeWindow(0, Fenetre_x, Fenetre_y, #PB_Ignore, #PB_Ignore)
    
    Temps = ElapsedMilliseconds()
    
    ; On copie l'écran
    DC = GetDC_(0)
    Dessin = StartDrawing(ImageOutput(0))
      Box(0, 0, Taille, Taille, 0)
      BitBlt_(Dessin, 0, 0, Taille, Taille, DC, Souris_x - Rayon, Souris_y - Rayon, #SRCPAINT)
    StopDrawing()
    ReleaseDC_(0, DC)
    ; SaveImage(0, "temp.bmp")
    GetImageBits(ImageID(0), @Image())
    
    ; Dessin du zoom
     
      For n = -Rayon To Rayon
        For nn = -Rayon To Rayon
          y = Rayon + nn : x = Rayon + n
          
          Longueur.f = Sqr(n * n + nn * nn) ; On calcul la distance d'un point de la sphère à partir du centre
          If Longueur < Rayon - 1 ; Si le pixel est situé dans le rayon du cercle moins une bordure
            ; on calcul la distance du point de l'image correspondant à celui de la sphère
            Longueur2.f = 1 / (1 + Zoom * Cos(Longueur / Rayon * (#PI / 4)))
            
            If Lissage > 0
              ; Si le FPS est élevé, on travaille avec du lissage
              PosX.f = Rayon + n * Longueur2
              PosY.f = Rayon + nn * Longueur2
              PosX_Int.l = PosX
              PosY_Int.l = PosY
              PosX_Ecart.f = Abs(PosX - PosX_Int)
              PosY_Ecart.f = Abs(PosY - PosY_Int)
              PosX_EcartInv.f = 1 - PosX_Ecart
              PosY_EcartInv.f = 1 - PosY_Ecart
              If PosX >= PosX_Int
                If PosY >= PosY_Int ; bas, droite
                  Rouge = Red(Image(PosX_Int, PosY_Int)) * PosX_EcartInv * PosY_EcartInv + Red(Image(PosX_Int + 1, PosY_Int)) * PosX_Ecart * PosY_EcartInv + Red(Image(PosX_Int, PosY_Int + 1)) * PosX_EcartInv * PosY_Ecart + Red(Image(PosX_Int + 1, PosY_Int + 1)) * PosX_Ecart * PosY_Ecart
                  Vert = Green(Image(PosX_Int, PosY_Int)) * PosX_EcartInv * PosY_EcartInv + Green(Image(PosX_Int + 1, PosY_Int)) * PosX_Ecart * PosY_EcartInv + Green(Image(PosX_Int, PosY_Int + 1)) * PosX_EcartInv * PosY_Ecart + Green(Image(PosX_Int + 1, PosY_Int + 1)) * PosX_Ecart * PosY_Ecart
                  Bleu = Blue(Image(PosX_Int, PosY_Int)) * PosX_EcartInv * PosY_EcartInv + Blue(Image(PosX_Int + 1, PosY_Int)) * PosX_Ecart * PosY_EcartInv + Blue(Image(PosX_Int, PosY_Int + 1)) * PosX_EcartInv * PosY_Ecart + Blue(Image(PosX_Int + 1, PosY_Int + 1)) * PosX_Ecart * PosY_Ecart
                Else ; haut, droite
                  Rouge = Red(Image(PosX_Int, PosY_Int)) * PosX_EcartInv * PosY_EcartInv + Red(Image(PosX_Int + 1, PosY_Int)) * PosX_Ecart * PosY_EcartInv + Red(Image(PosX_Int, PosY_Int - 1)) * PosX_EcartInv * PosY_Ecart + Red(Image(PosX_Int + 1, PosY_Int - 1)) * PosX_Ecart * PosY_Ecart
                  Vert = Green(Image(PosX_Int, PosY_Int)) * PosX_EcartInv * PosY_EcartInv + Green(Image(PosX_Int + 1, PosY_Int)) * PosX_Ecart * PosY_EcartInv + Green(Image(PosX_Int, PosY_Int - 1)) * PosX_EcartInv * PosY_Ecart + Green(Image(PosX_Int + 1, PosY_Int - 1)) * PosX_Ecart * PosY_Ecart
                  Bleu = Blue(Image(PosX_Int, PosY_Int)) * PosX_EcartInv * PosY_EcartInv + Blue(Image(PosX_Int + 1, PosY_Int)) * PosX_Ecart * PosY_EcartInv + Blue(Image(PosX_Int, PosY_Int - 1)) * PosX_EcartInv * PosY_Ecart + Blue(Image(PosX_Int + 1, PosY_Int - 1)) * PosX_Ecart * PosY_Ecart
                EndIf
              Else
                If PosY >= PosY_Int ; bas, gauche
                  Rouge = Red(Image(PosX_Int, PosY_Int)) * PosX_EcartInv * PosY_EcartInv + Red(Image(PosX_Int - 1, PosY_Int)) * PosX_Ecart * PosY_EcartInv + Red(Image(PosX_Int, PosY_Int + 1)) * PosX_EcartInv * PosY_Ecart + Red(Image(PosX_Int - 1, PosY_Int + 1)) * PosX_Ecart * PosY_Ecart
                  Vert = Green(Image(PosX_Int, PosY_Int)) * PosX_EcartInv * PosY_EcartInv + Green(Image(PosX_Int - 1, PosY_Int)) * PosX_Ecart * PosY_EcartInv + Green(Image(PosX_Int, PosY_Int + 1)) * PosX_EcartInv * PosY_Ecart + Green(Image(PosX_Int - 1, PosY_Int + 1)) * PosX_Ecart * PosY_Ecart
                  Bleu = Blue(Image(PosX_Int, PosY_Int)) * PosX_EcartInv * PosY_EcartInv + Blue(Image(PosX_Int - 1, PosY_Int)) * PosX_Ecart * PosY_EcartInv + Blue(Image(PosX_Int, PosY_Int + 1)) * PosX_EcartInv * PosY_Ecart + Blue(Image(PosX_Int - 1, PosY_Int + 1)) * PosX_Ecart * PosY_Ecart
                Else ; haut, gauche
                  Rouge = Red(Image(PosX_Int, PosY_Int)) * PosX_EcartInv * PosY_EcartInv + Red(Image(PosX_Int - 1, PosY_Int)) * PosX_Ecart * PosY_EcartInv + Red(Image(PosX_Int, PosY_Int - 1)) * PosX_EcartInv * PosY_Ecart + Red(Image(PosX_Int - 1, PosY_Int - 1)) * PosX_Ecart * PosY_Ecart
                  Vert = Green(Image(PosX_Int, PosY_Int)) * PosX_EcartInv * PosY_EcartInv + Green(Image(PosX_Int - 1, PosY_Int)) * PosX_Ecart * PosY_EcartInv + Green(Image(PosX_Int, PosY_Int - 1)) * PosX_EcartInv * PosY_Ecart + Green(Image(PosX_Int - 1, PosY_Int - 1)) * PosX_Ecart * PosY_Ecart
                  Bleu = Blue(Image(PosX_Int, PosY_Int)) * PosX_EcartInv * PosY_EcartInv + Blue(Image(PosX_Int - 1, PosY_Int)) * PosX_Ecart * PosY_EcartInv + Blue(Image(PosX_Int, PosY_Int - 1)) * PosX_EcartInv * PosY_Ecart + Blue(Image(PosX_Int - 1, PosY_Int - 1)) * PosX_Ecart * PosY_Ecart
                EndIf
              EndIf
              Couleur = RGB(Rouge, Vert, Bleu)
            Else
              ; Si le FPS passe en dessous de 10, on utilise la version sans lissage
              Couleur = Image(Int(Rayon + n * Longueur2), Int(Rayon + nn * Longueur2))
            EndIf
            
            ; On affiche le pixel
            Image2(x, y) = Couleur
            
          EndIf
          
        Next nn
      Next n
      
      SetImageBits(ImageID(1), @Image2())
      
    ; FPS analyse
    Temps = ElapsedMilliseconds() - Temps
    If Temps > #Rafraichissement ; Si le temps de calcul est trop long, on désactive le lissage pour 250 ms
      If Lissage < 0
        StartDrawing(WindowOutput(0))
          DrawImage(ImageID(1), 0, 0)
        StopDrawing()
      EndIf
      Lissage = - 250 / #Rafraichissement
    Else
      StartDrawing(WindowOutput(0))
        DrawImage(ImageID(1), 0, 0)
      StopDrawing()
    EndIf

  ; EndIf
  If Lissage < 2 ; On décompte avant de réactiver le lissage si il a été désactivé
    Lissage + 1
  EndIf
EndProcedure

Procedure SetWinTransparency(WinHandle.l, Transparency_Level.l)
  If OpenLibrary(0, "user32.dll")
    CallFunction(0, "SetLayeredWindowAttributes", WinHandle, 0, Transparency_Level, 2)
    CloseLibrary(0)
  EndIf
EndProcedure

Charger()

; On récupère la taille de l'écran
If ExamineDesktops()
  Ecran_Largeur = DesktopWidth(0)
  Ecran_Hauteur = DesktopHeight(0)
Else
  End
EndIf

; Création de la fenêtre et de la GadgetList
If OpenWindow(0, 0, 0, 100, 100, "Loupe", #PB_Window_BorderLess | #PB_Window_Invisible) = 0 Or CreateGadgetList(WindowID(0)) = 0
  End
EndIf
SetWindowLong_(WindowID(0), #GWL_EXSTYLE, GetWindowLong_(WindowID(0), #GWL_EXSTYLE) | #WS_EX_TOOLWINDOW | $00080000) ; choix de la barre d'outil réduite
StickyWindow(0, 1)

SetWinTransparency(WindowID(0), 255)

CreateImage(0, 100, 100)
CreateImage(1, 100, 100)

LoadPackIcon(?IconeLoupe)
IconeLoupe = IconEx_ExtractIcon(16)

If AddSysTrayIcon(0, WindowID(0), IconeLoupe) = 0
  End
EndIf

SysTrayIconToolTip(0, "Loupe")

If CreatePopupMenu(0)
  OpenSubMenu("Taille")
    For n = 60 To 150 Step 10
      MenuItem(1000 + n, Str(n * 2) + " pixels")
      If n = Rayon
        SetMenuItemState(0, 1000 + n, 1)
      EndIf
    Next
  CloseSubMenu()
  OpenSubMenu("Zoom")
    For n = 150 To 400 Step 25
      MenuItem(2000 + n, "x" + StrF(n / 100, 2))
      If Zoom = n / 100
        SetMenuItemState(0, 2000 + n, 1)
      EndIf
    Next
  CloseSubMenu()
  MenuBar()
  MenuItem(0, "Quitter")
Else
  End
EndIf

Dimension()
DeplaceLoupe()
HideWindow(0, 0)

SetTimer_(WindowID(0), 1, #Rafraichissement, 0)

Repeat
  Event = WaitWindowEvent()
  
  Select Event
    Case #PB_Event_Menu
      Select EventMenu() ; Menus
        Case 0
          Event = #PB_Event_CloseWindow
        Default
          If EventMenu() > 2000
            SetMenuItemState(0, 2000 + Zoom * 100, 0)
            Zoom = (EventMenu() - 2000) / 100
            SetMenuItemState(0, 2000 + Zoom * 100, 1)
            Dimension()
          ElseIf EventMenu() > 1000
            SetMenuItemState(0, 1000 + Rayon, 0)
            Rayon = EventMenu() - 1000
            SetMenuItemState(0, 1000 + Rayon, 1)
            Dimension()
          EndIf
      EndSelect
    Case #PB_Event_SysTray
      Select EventType() ; Si clic sur icone systray
        Case #PB_EventType_LeftClick
          DisplayPopupMenu(0, WindowID(0))
        Case #PB_EventType_RightClick
          DisplayPopupMenu(0, WindowID(0))
      EndSelect
    Case #WM_TIMER ; on rafraichit l'affichage
      Timer = EventwParam()
      Select Timer
        Case 1
          ; Affichage
          DeplaceLoupe()
      EndSelect
  EndSelect
  
Until Event = #PB_Event_CloseWindow

KillTimer_(WindowID(0), 1)

Sauver()

End

DataSection
  IconeLoupe : 
  Data.l $000009F6,$09F6434A,$FABC0000,$2301AA42,$23102091,$50822302,$2A122404,$610A3688,$110C600C,$CA114084,$40457028,$06A00046
  Data.l $8EDD8A00,$223D1A22,$788FCE29,$8E232D8E,$01073B51,$A023E0DC,$423D7367,$E88F8C00,$DD238DE6,$FA00C7CB,$CD43FFFD,$43E743F1
  Data.l $F5E7DDBC,$EE72C623,$3EFEE908,$100078A2,$3EFED708,$9BF41004,$C43CA43D,$3E1B3BFA,$3E967B04,$42ECD23F,$381BA08E,$FB074850
  Data.l $AE0E6040,$3E218FCB,$0E1F3B94,$2E2043F5,$06DFCF1D,$23E5388A,$81872981,$9824DFE9,$42489287,$244B7DE3,$3D843449,$123CB602
  Data.l $4C8D3F9D,$02C3CD66,$43BBB001,$1EB07BA3,$4BD8AA06,$2EC8089F,$B324979D,$083C486C,$98D86AE0,$93621BDD,$8C0E8D0F,$11FB87E7
  Data.l $1C0C3FB0,$1E2EA5DA,$C039F36E,$F2E07126,$A00423A3,$687B028F,$F7617F0D,$578B41C2,$C1CF2447,$85C5C437,$D107D4B4,$7A1E43FB
  Data.l $1CFE1EE3,$0C5DFF01,$1DE615AA,$A161D491,$21C76B0C,$706DB0CB,$A174D728,$D0803480,$1204B911,$7CA9211B,$A4AA51FD,$0F6A4B26
  Data.l $9D4F7066,$66B06536,$2D1AA854,$945264EA,$B6118F48,$FA046954,$41A1A7D3,$74497E53,$CDA64428,$CCA26021,$9DCFF389,$5469633A
  Data.l $5D1D27B3,$26336C8E,$D13297CC,$9249299C,$79444523,$2B6364D2,$198DA655,$91D80231,$412146E3,$030FF47E,$62516502,$562D8844
  Data.l $0A0F38A4,$C2A11767,$6C390884,$80C070C8,$482CA416,$9767A070,$046F19B2,$0FC4AFC6,$840DE43D,$3A031D0F,$47D80F02,$1A369049
  Data.l $0453D315,$65612E99,$948C25DD,$E4A52A56,$51508B65,$B1E62922,$8D2B1182,$44B2F421,$12C2C258,$4A4AC965,$8F17A55B,$4AED941D
  Data.l $5B5DA0C9,$FBF5F4A2,$3FE9BE4A,$0CFF544C,$53A71502,$C744EED9,$A644F701,$F45F0236,$B87588A2,$0D37537C,$9028FE3D,$3B60F552
  Data.l $03CF9144,$AE3A23DC,$F5047F80,$046BE56C,$C4538E84,$EEEF4D99,$F3F44D25,$F0DEC9FA,$DF886179,$C25E8087,$0900812E,$405684BF
  Data.l $25DB22B0,$1008B53D,$034E0ADC,$21C9C9D9,$0A244673,$7CBD565C,$FB4B5126,$80368023,$3415EE90,$C4749983,$0233B926,$8AD856C0
  Data.l $8909EA21,$08F98010,$F3A52EB0,$AD905912,$0A50D926,$FD321564,$72878ADB,$9735679B,$4477BF78,$E7442EBB,$9932610F,$D2644035
  Data.l $69B3AD81,$C94054E7,$12283C35,$67E7A245,$867D9344,$D9E38EA0,$35329B50,$C81AAF5F,$24AC3A38,$87FC6F71,$FEA64B9F,$07BF01FE
  Data.l $C7B0B784,$973FAC43,$CA415151,$879D02B6,$05D32DBA,$C5E80D53,$0FFA798E,$28915797,$24574512,$B775448A,$83A5517A,$05FB98F2
  Data.l $2572035A,$F1BE5576,$83FEE3E8,$AEAB15EB,$D2DE915E,$25B02DF2,$01DDAEB9,$39E617C6,$2C08678C,$2AC50D20,$0081F9F0,$00008069
  Data.b $20,$12
EndDataSection
je me sauve amusez vous bien
Dernière modification par Le Soldat Inconnu le mar. 28/avr./2009 21:44, modifié 2 fois.
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)]
PAPIPP
Messages : 534
Inscription : sam. 23/févr./2008 17:58

Message par PAPIPP »

Vous avez besoin des librairie "Effect" et "IconEx" que vous trouverez sur mon site
Mais aussi de skinwindow
:D
A+
Le Soldat Inconnu
Messages : 4312
Inscription : mer. 28/janv./2004 20:58
Localisation : Clermont ferrand OU Olsztyn
Contact :

Message par Le Soldat Inconnu »

rhaaaa

Bon, je fais une version sans lib :)
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 :

Message par Le Soldat Inconnu »

Bon, voila la version sans lib

Du coup, ca rajoute quelque procedure bien tordu et pas très commenté mais bon :roll: vous allez y survivre

Code : Tout sélectionner

; Auteur : Le Soldat Inconnu
; Version de PB : 4.0
;
; Explication du programme :
; Fait un effet de loupe sur votre écran (comme ci une sphèse se déplace au dessus en déformant l'image)

Global Zoom.f, x.l, y.l, x.l, y.l, Rayon.l, Taille.l, Lissage.l
Global Souris_x, Souris_y, Souris_x_mem, Souris_y_mem
Global Ecran_Largeur, Ecran_Hauteur

Global Dim Image(0, 0)
Global Dim Image2(0, 0)

#Decalage_Fenetre = 0.45
#Rafraichissement = 25
#Limite_Lissage = 10

Procedure.l IconEx_LoadIconData(Icone.l) ; Charger l'icône à partir d'un IncludeBinary
  Protected NbIcone.l
  
  If MemIcon
    FreeMemory(MemIcon)
    ClearList(ListeIcon())
  EndIf
  
  ClearList(ListeIcon())
  
  NbIcone = PeekB(Icone + 4) & $FF
  
  For n = 0 To NbIcone - 1
    
    AddElement(ListeIcon())
    
    Pos = 6 + 16 * n
    ListeIcon()\TX = PeekB(Icone + Pos) & $FF
    ListeIcon()\TY = PeekB(Icone + Pos + 1) & $FF
    ListeIcon()\Autre = PeekL(Icone + Pos + 2)
    ListeIcon()\Format = PeekB(Icone + Pos + 6) & $FF
    ListeIcon()\Longueur = PeekL(Icone + Pos + 8)
    ListeIcon()\Position = PeekL(Icone + Pos + 12)
    
    If n = NbIcone - 1
      MemIcon = AllocateMemory(ListeIcon()\Position + ListeIcon()\Longueur)
      CopyMemory(Icone, MemIcon, ListeIcon()\Position + ListeIcon()\Longueur)
    EndIf
    
  Next
EndProcedure

Procedure.l IconEx_ExtractIcon(TailleX) ; Extraire une icone ou la plus proche
  ; Retourne le handle de l'icone si le format spécifié existe
  ; Retourne 0 sinon
  
  Protected id, Format
  
  If MemIcon And (TailleX = 16 Or TailleX = 24 Or TailleX = 32 Or TailleX = 48)
    
    If OSVersion() < #PB_OS_Windows_XP
      Format = 24
    Else
      Format = 32
    EndIf
    
    Repeat
      
      ; MessageRequester("", Str(TailleX) + "    " + Str(Format), 0)
      
      ForEach ListeIcon()
        If ListeIcon()\TX = TailleX And ListeIcon()\TY = TailleX And ListeIcon()\Format = Format
          
          ; On crée l'icone en mémoire
          Mem = AllocateMemory(ListeIcon()\Longueur + 4 + 2 + 2 + 4 + 2 + 4 + 4)
          If Mem
            
            PokeL(Mem, 65536)
            PokeB(Mem + 4, 1)
            PokeB(Mem + 6, ListeIcon()\TX)
            PokeB(Mem + 7, ListeIcon()\TY)
            PokeL(Mem + 8, ListeIcon()\Autre)
            PokeB(Mem + 12, ListeIcon()\Format)
            PokeL(Mem + 14, ListeIcon()\Longueur)
            PokeL(Mem + 18, 22)
            
            CopyMemory(MemIcon + ListeIcon()\Position, Mem + 22, ListeIcon()\Longueur)
            
            id = CatchImage(#PB_Any, Mem)
            
            FreeMemory(Mem)
            
            ProcedureReturn ImageID(id)
            
          EndIf
        EndIf
      Next
      
      Select Format
        Case 32
          Format = 24
        Case 24
          Format = 8
        Case 8
          Select TailleX
            Case 48
              TailleX = 32
            Case 32
              TailleX = 24
            Case 24
              TailleX = 16
            Case 16
              TailleX = 0
          EndSelect
          If OSVersion() < #PB_OS_Windows_XP
            Format = 24
          Else
            Format = 32
          EndIf
      EndSelect
      
    Until TailleX < 16
    
  EndIf
  ProcedureReturn 0
EndProcedure

Procedure SkinWindow(WindowID, ImageID) ; Mettre une forme sur une fenêtre a partir d'une image
  Protected bmi.BITMAPINFO, Region_Temp, Region_Totale, Largeur, Hauteur
  
  GetObject_(ImageID, SizeOf(BITMAP), @bm.BITMAP)
  
  bmi\bmiHeader\biSize = SizeOf(BITMAPINFOHEADER)
  bmi\bmiHeader\biWidth = bm\bmWidth
  bmi\bmiHeader\biHeight = bm\bmHeight
  bmi\bmiHeader\biPlanes = 1
  bmi\bmiHeader\biBitCount = 32
  bmi\bmiHeader\biCompression = #BI_RGB
  
  Region_Totale = CreateRectRgn_(0, 0, bm\bmWidth, bm\bmHeight)
  
  Mem = AllocateMemory(bm\bmWidth * bm\bmHeight * 4)
  If Mem
    
    hdc = CreateCompatibleDC_(GetDC_(ImageID))
    If hdc
      GetDIBits_(hdc, ImageID, 0, bm\bmHeight, Mem, @bmi, #DIB_RGB_COLORS) ; on envoie la liste dans l'image
      DeleteDC_(hdc)
    EndIf
    
    ; On convertit la liste dans le bon format
    Largeur = bm\bmWidth - 1
    Hauteur = bm\bmHeight - 1
    Point = Mem
    For Y1 = 0 To Hauteur
      For X1 = 0 To Largeur
        If PeekL(Point) = $FF00FF
          X2 = X1
          While X2 < Largeur And PeekL(Point + 4) = $FF00FF
            X2 + 1
            Point + 4
          Wend
          Region_Temp = CreateRectRgn_(X1, Hauteur - Y1, X2 + 1, Hauteur - Y1 + 1) ; On retire le point de la region
          CombineRgn_(Region_Totale, Region_Totale, Region_Temp, #RGN_DIFF)
          DeleteObject_(Region_Temp)
          X1 = X2
        EndIf
        Point + 4
      Next
    Next
    
    FreeMemory(Mem)
  EndIf
  
  SetWindowRgn_(WindowID, Region_Totale, 1) ; On applique la region
  DeleteObject_(Region_Totale) ; On efface la region
  
EndProcedure

Procedure.l SetImageBits(ImageID, HList) ; Transfert d'un tableau vers une image
  Protected bmi.BITMAPINFO, hdc.l, Resultat, Mem, n, nn, bm.BITMAP, Temp1, Temp2, Temp3, Temp4
  
  Resultat = 0
  
  GetObject_(ImageID, SizeOf(BITMAP), @bm.BITMAP)
  
  bmi\bmiHeader\biSize = SizeOf(BITMAPINFOHEADER)
  bmi\bmiHeader\biWidth = bm\bmWidth
  bmi\bmiHeader\biHeight = bm\bmHeight
  bmi\bmiHeader\biPlanes = 1
  bmi\bmiHeader\biBitCount = 32
  bmi\bmiHeader\biCompression = #BI_RGB
  
  Mem = AllocateMemory(bm\bmWidth * bm\bmHeight * 4)
  If Mem
    
    ; On convertit la liste dans le bon format
    Temp1 = bm\bmHeight - 1
    Temp2 = bm\bmWidth - 1
    For nn = 0 To Temp2
      For n = 0 To Temp1
        Temp3 = Mem + (nn + (Temp1 - n) * bm\bmWidth) * 4
        PokeB(Temp3 + 2, PeekB(HList))
        PokeB(Temp3 + 1, PeekB(HList + 1))
        PokeB(Temp3, PeekB(HList + 2))
        HList + 4
      Next
    Next
    
    hdc = CreateCompatibleDC_(GetDC_(ImageID))
    If hdc
      SetDIBits_(hdc, ImageID, 0, bm\bmHeight, Mem, @bmi, #DIB_RGB_COLORS) ; on envoie la liste dans l'image
      DeleteDC_(hdc)
      Resultat = ImageID
    EndIf
    
    FreeMemory(Mem)
  EndIf
  
  ProcedureReturn Resultat
EndProcedure

Procedure.l GetImageBits(ImageID, HList) ; Transfert d'une image vers un tableau
  Protected bmi.BITMAPINFO, hdc.l, Resultat, Mem, n, nn, bm.BITMAP, Temp1, Temp2, Temp3, Temp4
  
  Resultat = 0
  
  GetObject_(ImageID, SizeOf(BITMAP), @bm.BITMAP)
  
  bmi\bmiHeader\biSize = SizeOf(BITMAPINFOHEADER)
  bmi\bmiHeader\biWidth = bm\bmWidth
  bmi\bmiHeader\biHeight = bm\bmHeight
  bmi\bmiHeader\biPlanes = 1
  bmi\bmiHeader\biBitCount = 32
  bmi\bmiHeader\biCompression = #BI_RGB
  
  Mem = AllocateMemory(bm\bmWidth * bm\bmHeight * 4)
  If Mem
    
    hdc = CreateCompatibleDC_(GetDC_(ImageID))
    If hdc
      GetDIBits_(hdc, ImageID, 0, bm\bmHeight, Mem, @bmi, #DIB_RGB_COLORS) ; on envoie la liste dans l'image
      DeleteDC_(hdc)
      Resultat = ImageID
    EndIf
    
    ; On convertit la liste dans le bon format
    Temp1 = bm\bmHeight - 1
    Temp2 = bm\bmWidth - 1
    For nn = 0 To Temp2
      For n = 0 To Temp1
        Temp3 = Mem + (nn + (Temp1 - n) * bm\bmWidth) * 4
        PokeB(HList + 2, PeekB(Temp3))
        PokeB(HList + 1, PeekB(Temp3 + 1))
        PokeB(HList, PeekB(Temp3 + 2))
        HList + 4
      Next
    Next
    
    FreeMemory(Mem)
  EndIf
  
  ProcedureReturn Resultat
EndProcedure

Procedure LoadPackIcon(Mem)
  Taille = PeekL(Mem)
  Mem2 = AllocateMemory(Taille)
  If Mem2
    UnpackMemory(Mem + 4, Mem2)
    IconEx_LoadIconData(Mem2)
    FreeMemory(Mem2)
  EndIf
EndProcedure

Procedure Dimension()
  Taille = 2 * Rayon + 1
  ResizeWindow(0, #PB_Ignore, #PB_Ignore, Taille, Taille)
  ResizeImage(0, Taille, Taille)
  StartDrawing(ImageOutput(0))
    Box(0, 0, Taille, Taille, $FF00FF)
    
    For n = -Rayon To Rayon
      For nn = -Rayon To Rayon
        y = Rayon + nn : x = Rayon + n
        
        Longueur.f = Sqr(n * n + nn * nn) ; On calcul la distance d'un point de la sphère à partir du centre
        If Longueur < Rayon ; And Longueur > 1
          Plot(x, y, 0)
        EndIf
          
      Next
    Next
    
    
  StopDrawing()
  ResizeImage(1, Taille, Taille)
  SkinWindow(WindowID(0), ImageID(0))
  Dim Image(Taille - 1, Taille - 1)
  Dim Image2(Taille - 1, Taille - 1)
  Lissage = 1
EndProcedure

Procedure Sauver()
  If CreatePreferences("Loupe.ini")
    WritePreferenceLong("Taille", Rayon)
    WritePreferenceFloat("Zoom", Zoom)
    ClosePreferences()
  EndIf
EndProcedure
Procedure Charger()
  OpenPreferences("Loupe.ini")
  Rayon = ReadPreferenceLong("Taille", 100)
  Zoom = ReadPreferenceFloat("Zoom", 2)
  ClosePreferences()
EndProcedure

Procedure DeplaceLoupe()
  
  Souris_x = DesktopMouseX()
  Souris_y = DesktopMouseY()
  ; If Souris_x <> Souris_x_mem Or Souris_y <> Souris_y_mem Or Lissage = 1 ; Si la souris a bougé ou si on réactive le lissage
    ; Souris_x_mem = Souris_x
    ; Souris_y_mem = Souris_y
    
    ; Position de la fenêtre
    Fenetre_x = Souris_x + Rayon * #Decalage_Fenetre
    Fenetre_y = Souris_y + Rayon * #Decalage_Fenetre
    If Fenetre_x + Taille >= Ecran_Largeur
      Fenetre_x = Souris_x - Rayon * #Decalage_Fenetre - Taille
    EndIf
    If Fenetre_y + Taille >= Ecran_Hauteur
      Fenetre_y = Souris_y - Rayon * #Decalage_Fenetre - Taille
    EndIf
    ; Fenetre_x = Souris_x - Rayon
    ; Fenetre_y = Souris_y - Rayon
    ResizeWindow(0, Fenetre_x, Fenetre_y, #PB_Ignore, #PB_Ignore)
    
    Temps = ElapsedMilliseconds()
    
    ; On copie l'écran
    DC = GetDC_(0)
    Dessin = StartDrawing(ImageOutput(0))
      Box(0, 0, Taille, Taille, 0)
      BitBlt_(Dessin, 0, 0, Taille, Taille, DC, Souris_x - Rayon, Souris_y - Rayon, #SRCPAINT)
    StopDrawing()
    ReleaseDC_(0, DC)
    ; SaveImage(0, "temp.bmp")
    GetImageBits(ImageID(0), @Image())
    
    ; Dessin du zoom
     
      For n = -Rayon To Rayon
        For nn = -Rayon To Rayon
          y = Rayon + nn : x = Rayon + n
          
          Longueur.f = Sqr(n * n + nn * nn) ; On calcul la distance d'un point de la sphère à partir du centre
          If Longueur < Rayon - 1 ; Si le pixel est situé dans le rayon du cercle moins une bordure
            ; on calcul la distance du point de l'image correspondant à celui de la sphère
            Longueur2.f = 1 / (1 + Zoom * Cos(Longueur / Rayon * (#PI / 4)))
            
            If Lissage > 0
              ; Si le FPS est élevé, on travaille avec du lissage
              PosX.f = Rayon + n * Longueur2
              PosY.f = Rayon + nn * Longueur2
              PosX_Int.l = PosX
              PosY_Int.l = PosY
              PosX_Ecart.f = Abs(PosX - PosX_Int)
              PosY_Ecart.f = Abs(PosY - PosY_Int)
              PosX_EcartInv.f = 1 - PosX_Ecart
              PosY_EcartInv.f = 1 - PosY_Ecart
              If PosX >= PosX_Int
                If PosY >= PosY_Int ; bas, droite
                  Rouge = Red(Image(PosX_Int, PosY_Int)) * PosX_EcartInv * PosY_EcartInv + Red(Image(PosX_Int + 1, PosY_Int)) * PosX_Ecart * PosY_EcartInv + Red(Image(PosX_Int, PosY_Int + 1)) * PosX_EcartInv * PosY_Ecart + Red(Image(PosX_Int + 1, PosY_Int + 1)) * PosX_Ecart * PosY_Ecart
                  Vert = Green(Image(PosX_Int, PosY_Int)) * PosX_EcartInv * PosY_EcartInv + Green(Image(PosX_Int + 1, PosY_Int)) * PosX_Ecart * PosY_EcartInv + Green(Image(PosX_Int, PosY_Int + 1)) * PosX_EcartInv * PosY_Ecart + Green(Image(PosX_Int + 1, PosY_Int + 1)) * PosX_Ecart * PosY_Ecart
                  Bleu = Blue(Image(PosX_Int, PosY_Int)) * PosX_EcartInv * PosY_EcartInv + Blue(Image(PosX_Int + 1, PosY_Int)) * PosX_Ecart * PosY_EcartInv + Blue(Image(PosX_Int, PosY_Int + 1)) * PosX_EcartInv * PosY_Ecart + Blue(Image(PosX_Int + 1, PosY_Int + 1)) * PosX_Ecart * PosY_Ecart
                Else ; haut, droite
                  Rouge = Red(Image(PosX_Int, PosY_Int)) * PosX_EcartInv * PosY_EcartInv + Red(Image(PosX_Int + 1, PosY_Int)) * PosX_Ecart * PosY_EcartInv + Red(Image(PosX_Int, PosY_Int - 1)) * PosX_EcartInv * PosY_Ecart + Red(Image(PosX_Int + 1, PosY_Int - 1)) * PosX_Ecart * PosY_Ecart
                  Vert = Green(Image(PosX_Int, PosY_Int)) * PosX_EcartInv * PosY_EcartInv + Green(Image(PosX_Int + 1, PosY_Int)) * PosX_Ecart * PosY_EcartInv + Green(Image(PosX_Int, PosY_Int - 1)) * PosX_EcartInv * PosY_Ecart + Green(Image(PosX_Int + 1, PosY_Int - 1)) * PosX_Ecart * PosY_Ecart
                  Bleu = Blue(Image(PosX_Int, PosY_Int)) * PosX_EcartInv * PosY_EcartInv + Blue(Image(PosX_Int + 1, PosY_Int)) * PosX_Ecart * PosY_EcartInv + Blue(Image(PosX_Int, PosY_Int - 1)) * PosX_EcartInv * PosY_Ecart + Blue(Image(PosX_Int + 1, PosY_Int - 1)) * PosX_Ecart * PosY_Ecart
                EndIf
              Else
                If PosY >= PosY_Int ; bas, gauche
                  Rouge = Red(Image(PosX_Int, PosY_Int)) * PosX_EcartInv * PosY_EcartInv + Red(Image(PosX_Int - 1, PosY_Int)) * PosX_Ecart * PosY_EcartInv + Red(Image(PosX_Int, PosY_Int + 1)) * PosX_EcartInv * PosY_Ecart + Red(Image(PosX_Int - 1, PosY_Int + 1)) * PosX_Ecart * PosY_Ecart
                  Vert = Green(Image(PosX_Int, PosY_Int)) * PosX_EcartInv * PosY_EcartInv + Green(Image(PosX_Int - 1, PosY_Int)) * PosX_Ecart * PosY_EcartInv + Green(Image(PosX_Int, PosY_Int + 1)) * PosX_EcartInv * PosY_Ecart + Green(Image(PosX_Int - 1, PosY_Int + 1)) * PosX_Ecart * PosY_Ecart
                  Bleu = Blue(Image(PosX_Int, PosY_Int)) * PosX_EcartInv * PosY_EcartInv + Blue(Image(PosX_Int - 1, PosY_Int)) * PosX_Ecart * PosY_EcartInv + Blue(Image(PosX_Int, PosY_Int + 1)) * PosX_EcartInv * PosY_Ecart + Blue(Image(PosX_Int - 1, PosY_Int + 1)) * PosX_Ecart * PosY_Ecart
                Else ; haut, gauche
                  Rouge = Red(Image(PosX_Int, PosY_Int)) * PosX_EcartInv * PosY_EcartInv + Red(Image(PosX_Int - 1, PosY_Int)) * PosX_Ecart * PosY_EcartInv + Red(Image(PosX_Int, PosY_Int - 1)) * PosX_EcartInv * PosY_Ecart + Red(Image(PosX_Int - 1, PosY_Int - 1)) * PosX_Ecart * PosY_Ecart
                  Vert = Green(Image(PosX_Int, PosY_Int)) * PosX_EcartInv * PosY_EcartInv + Green(Image(PosX_Int - 1, PosY_Int)) * PosX_Ecart * PosY_EcartInv + Green(Image(PosX_Int, PosY_Int - 1)) * PosX_EcartInv * PosY_Ecart + Green(Image(PosX_Int - 1, PosY_Int - 1)) * PosX_Ecart * PosY_Ecart
                  Bleu = Blue(Image(PosX_Int, PosY_Int)) * PosX_EcartInv * PosY_EcartInv + Blue(Image(PosX_Int - 1, PosY_Int)) * PosX_Ecart * PosY_EcartInv + Blue(Image(PosX_Int, PosY_Int - 1)) * PosX_EcartInv * PosY_Ecart + Blue(Image(PosX_Int - 1, PosY_Int - 1)) * PosX_Ecart * PosY_Ecart
                EndIf
              EndIf
              Couleur = RGB(Rouge, Vert, Bleu)
            Else
              ; Si le FPS passe en dessous de 10, on utilise la version sans lissage
              Couleur = Image(Int(Rayon + n * Longueur2), Int(Rayon + nn * Longueur2))
            EndIf
            
            ; On affiche le pixel
            Image2(x, y) = Couleur
            
          EndIf
          
        Next nn
      Next n
      
      SetImageBits(ImageID(1), @Image2())
      
    ; FPS analyse
    Temps = ElapsedMilliseconds() - Temps
    If Temps > #Rafraichissement ; Si le temps de calcul est trop long, on désactive le lissage pour 250 ms
      If Lissage < 0
        StartDrawing(WindowOutput(0))
          DrawImage(ImageID(1), 0, 0)
        StopDrawing()
      EndIf
      Lissage = - 250 / #Rafraichissement
    Else
      StartDrawing(WindowOutput(0))
        DrawImage(ImageID(1), 0, 0)
      StopDrawing()
    EndIf

  ; EndIf
  If Lissage < 2 ; On décompte avant de réactiver le lissage si il a été désactivé
    Lissage + 1
  EndIf
EndProcedure

Procedure SetWinTransparency(WinHandle.l, Transparency_Level.l)
  If OpenLibrary(0, "user32.dll")
    CallFunction(0, "SetLayeredWindowAttributes", WinHandle, 0, Transparency_Level, 2)
    CloseLibrary(0)
  EndIf
EndProcedure

Charger()

; On récupère la taille de l'écran
If ExamineDesktops()
  Ecran_Largeur = DesktopWidth(0)
  Ecran_Hauteur = DesktopHeight(0)
Else
  End
EndIf

; Création de la fenêtre et de la GadgetList
If OpenWindow(0, 0, 0, 100, 100, "Loupe", #PB_Window_BorderLess | #PB_Window_Invisible) = 0 Or CreateGadgetList(WindowID(0)) = 0
  End
EndIf
SetWindowLong_(WindowID(0), #GWL_EXSTYLE, GetWindowLong_(WindowID(0), #GWL_EXSTYLE) | #WS_EX_TOOLWINDOW | $00080000) ; choix de la barre d'outil réduite
StickyWindow(0, 1)

SetWinTransparency(WindowID(0), 255)

CreateImage(0, 100, 100)
CreateImage(1, 100, 100)

LoadPackIcon(?IconeLoupe)
IconeLoupe = IconEx_ExtractIcon(16)

If AddSysTrayIcon(0, WindowID(0), IconeLoupe) = 0
  End
EndIf

SysTrayIconToolTip(0, "Loupe")

If CreatePopupMenu(0)
  OpenSubMenu("Taille")
    For n = 60 To 150 Step 10
      MenuItem(1000 + n, Str(n * 2) + " pixels")
      If n = Rayon
        SetMenuItemState(0, 1000 + n, 1)
      EndIf
    Next
  CloseSubMenu()
  OpenSubMenu("Zoom")
    For n = 150 To 400 Step 25
      MenuItem(2000 + n, "x" + StrF(n / 100, 2))
      If Zoom = n / 100
        SetMenuItemState(0, 2000 + n, 1)
      EndIf
    Next
  CloseSubMenu()
  MenuBar()
  MenuItem(0, "Quitter")
Else
  End
EndIf

Dimension()
DeplaceLoupe()
HideWindow(0, 0)

SetTimer_(WindowID(0), 1, #Rafraichissement, 0)

Repeat
  Event = WaitWindowEvent()
  
  Select Event
    Case #PB_Event_Menu
      Select EventMenu() ; Menus
        Case 0
          Event = #PB_Event_CloseWindow
        Default
          If EventMenu() > 2000
            SetMenuItemState(0, 2000 + Zoom * 100, 0)
            Zoom = (EventMenu() - 2000) / 100
            SetMenuItemState(0, 2000 + Zoom * 100, 1)
            Dimension()
          ElseIf EventMenu() > 1000
            SetMenuItemState(0, 1000 + Rayon, 0)
            Rayon = EventMenu() - 1000
            SetMenuItemState(0, 1000 + Rayon, 1)
            Dimension()
          EndIf
      EndSelect
    Case #PB_Event_SysTray
      Select EventType() ; Si clic sur icone systray
        Case #PB_EventType_LeftClick
          DisplayPopupMenu(0, WindowID(0))
        Case #PB_EventType_RightClick
          DisplayPopupMenu(0, WindowID(0))
      EndSelect
    Case #WM_TIMER ; on rafraichit l'affichage
      Timer = EventwParam()
      Select Timer
        Case 1
          ; Affichage
          DeplaceLoupe()
      EndSelect
  EndSelect
  
Until Event = #PB_Event_CloseWindow

KillTimer_(WindowID(0), 1)

Sauver()

End

DataSection
  IconeLoupe : 
  Data.l $000009F6,$09F6434A,$FABC0000,$2301AA42,$23102091,$50822302,$2A122404,$610A3688,$110C600C,$CA114084,$40457028,$06A00046
  Data.l $8EDD8A00,$223D1A22,$788FCE29,$8E232D8E,$01073B51,$A023E0DC,$423D7367,$E88F8C00,$DD238DE6,$FA00C7CB,$CD43FFFD,$43E743F1
  Data.l $F5E7DDBC,$EE72C623,$3EFEE908,$100078A2,$3EFED708,$9BF41004,$C43CA43D,$3E1B3BFA,$3E967B04,$42ECD23F,$381BA08E,$FB074850
  Data.l $AE0E6040,$3E218FCB,$0E1F3B94,$2E2043F5,$06DFCF1D,$23E5388A,$81872981,$9824DFE9,$42489287,$244B7DE3,$3D843449,$123CB602
  Data.l $4C8D3F9D,$02C3CD66,$43BBB001,$1EB07BA3,$4BD8AA06,$2EC8089F,$B324979D,$083C486C,$98D86AE0,$93621BDD,$8C0E8D0F,$11FB87E7
  Data.l $1C0C3FB0,$1E2EA5DA,$C039F36E,$F2E07126,$A00423A3,$687B028F,$F7617F0D,$578B41C2,$C1CF2447,$85C5C437,$D107D4B4,$7A1E43FB
  Data.l $1CFE1EE3,$0C5DFF01,$1DE615AA,$A161D491,$21C76B0C,$706DB0CB,$A174D728,$D0803480,$1204B911,$7CA9211B,$A4AA51FD,$0F6A4B26
  Data.l $9D4F7066,$66B06536,$2D1AA854,$945264EA,$B6118F48,$FA046954,$41A1A7D3,$74497E53,$CDA64428,$CCA26021,$9DCFF389,$5469633A
  Data.l $5D1D27B3,$26336C8E,$D13297CC,$9249299C,$79444523,$2B6364D2,$198DA655,$91D80231,$412146E3,$030FF47E,$62516502,$562D8844
  Data.l $0A0F38A4,$C2A11767,$6C390884,$80C070C8,$482CA416,$9767A070,$046F19B2,$0FC4AFC6,$840DE43D,$3A031D0F,$47D80F02,$1A369049
  Data.l $0453D315,$65612E99,$948C25DD,$E4A52A56,$51508B65,$B1E62922,$8D2B1182,$44B2F421,$12C2C258,$4A4AC965,$8F17A55B,$4AED941D
  Data.l $5B5DA0C9,$FBF5F4A2,$3FE9BE4A,$0CFF544C,$53A71502,$C744EED9,$A644F701,$F45F0236,$B87588A2,$0D37537C,$9028FE3D,$3B60F552
  Data.l $03CF9144,$AE3A23DC,$F5047F80,$046BE56C,$C4538E84,$EEEF4D99,$F3F44D25,$F0DEC9FA,$DF886179,$C25E8087,$0900812E,$405684BF
  Data.l $25DB22B0,$1008B53D,$034E0ADC,$21C9C9D9,$0A244673,$7CBD565C,$FB4B5126,$80368023,$3415EE90,$C4749983,$0233B926,$8AD856C0
  Data.l $8909EA21,$08F98010,$F3A52EB0,$AD905912,$0A50D926,$FD321564,$72878ADB,$9735679B,$4477BF78,$E7442EBB,$9932610F,$D2644035
  Data.l $69B3AD81,$C94054E7,$12283C35,$67E7A245,$867D9344,$D9E38EA0,$35329B50,$C81AAF5F,$24AC3A38,$87FC6F71,$FEA64B9F,$07BF01FE
  Data.l $C7B0B784,$973FAC43,$CA415151,$879D02B6,$05D32DBA,$C5E80D53,$0FFA798E,$28915797,$24574512,$B775448A,$83A5517A,$05FB98F2
  Data.l $2572035A,$F1BE5576,$83FEE3E8,$AEAB15EB,$D2DE915E,$25B02DF2,$01DDAEB9,$39E617C6,$2C08678C,$2AC50D20,$0081F9F0,$00008069
  Data.b $20,$12
EndDataSection
Dernière modification par Le Soldat Inconnu le mar. 28/avr./2009 21:48, modifié 1 fois.
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)]
beauregard
Messages : 1307
Inscription : dim. 08/juil./2007 18:32
Localisation : Toulouse

y a du potentiel

Message par beauregard »

Le Soldat Inconnu a écrit :Bon, voila la version sans lib
merci bien :)
Et en travaillant un peu plus ce code, tu peux offrir une application intéressante pour ceux qui utilise une machine munis d'un petit écran, comme le EeePC par exemple...
Avatar de l’utilisateur
Huitbit
Messages : 940
Inscription : jeu. 08/déc./2005 5:19
Localisation : Guadeloupe

Gratulacje !

Message par Huitbit »

Impressionnant , en plus ce n'est pas gourmand en temps CPU !
Bravo!

Ca peut le faire dans un jeu (quitte à supprimer l'effet sphérique pour gagner un peu de fps)!
Exemple :dans un jeu de stratégie, zoom localisé sur une partie de la carte pour voir un combat ou pour y participer :P
Un peu comme dans les films d'héroïc fantasy où le méchant(qui est vraiment très méchant) regarde tout ce qui se passe dans sa boule de cristal(ben oui, un méchant ça triche tout le temps!) !
Hasta la vista !
beauregard
Messages : 1307
Inscription : dim. 08/juil./2007 18:32
Localisation : Toulouse

stylet

Message par beauregard »

pour la dernière gameboy, un système de zoom salvateur* existe, ce dernier s'applicant sur l'écran du haut pour un logiciel commercial permettant de surfer avec sa gameboy et son stylet...

*écran de très faible résolution.
Anonyme

Message par Anonyme »

Dommage que c'est pas portable :D

@Huitbit , pour un jeu tu peut faire aussi rapide sans passé par les apis.

Qu'est ce qu'une loupe dans un programme informatique ?
C'est une série de pixel qui est copié en mémoire
puis re-dessiné en boite plus grosse donnant l'illusion d'une loupe.
Pour les mini-map dans les STR ( jeu de stratégie ( warcraft2&co)) , C'est le même principe , mais inversé :D
Avatar de l’utilisateur
Kwai chang caine
Messages : 6989
Inscription : sam. 23/sept./2006 18:32
Localisation : Isere

Message par Kwai chang caine »

Je manque de mots pour le dire
Et de mains pour applaudir 8)



C'est plus du code mais de l'orfevrerie.
Comment as tu fait pour nous priver de tes talents si longtemps :cry:

En tout cas soldat, meme pendant ton absence apparement tu n'a céssé de "combatre", tu es surentrainé, ton nouvel avatar ne devrait pas etre "ROBOCOP" mais "ROBOCODE" :D
La version sans lib est plus bas, pour ceux qui veulent pas s'embêter a utiliser mes MAGNIFIQUES lib quoi ? elles sont pas belles ? *boude*
Elles doivent surement etre belles tes libs, vu comment sont tes codes, mais sur ce point je suis de l'avis de DOBRO, c'est vrai que sans, c'est beaucoup mieux, quand vous le pouvez bien sur, messieurs les maitres des codes.:wink:

Encore merci de ton splendide cadeau 8)
Avatar de l’utilisateur
Ar-S
Messages : 9540
Inscription : dim. 09/oct./2005 16:51
Contact :

Message par Ar-S »

Superbe ce petit prog, l'effet est vraiment bien rendu.

Pour le rendre encore plus meilleur que bon, ce serait bien que le programme gère l'affichage zoom lorsque l'on fait scroller une page avec la molette de la souris.

Actuellement, si on se trouve sur une page web par exemple, et que l'on scroll vers le bas, l'image zoomée se freeze sur sa dernière position jusqu'a ce que le scroll stop.
~~~~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
Le Soldat Inconnu
Messages : 4312
Inscription : mer. 28/janv./2004 20:58
Localisation : Clermont ferrand OU Olsztyn
Contact :

Message par Le Soldat Inconnu »

arf :)

En fait, je ne rafraichis que si la souris bouge pour économiser le cpu. donc effectivement, ca marche pas avec les srolls

il suffit de supprimer le test

Code : Tout sélectionner

If Souris_x <> Souris_x_mem Or Souris_y <> Souris_y_mem Or Lissage = 1 ; Si la souris a bougé ou si on réactive le lissage 
    Souris_x_mem = Souris_x 
    Souris_y_mem = Souris_y
Dans la procedure DeplaceLoupe()
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)]
beauregard
Messages : 1307
Inscription : dim. 08/juil./2007 18:32
Localisation : Toulouse

clap clap, bravo!, clap clap

Message par beauregard »

Le Soldat Inconnu a écrit :arf :)
il suffit de supprimer le test
ou simplement la désactiver :)

Code : Tout sélectionner

  If zut=0;(Souris_x <> Souris_x_mem Or Souris_y <> Souris_y_mem Or Lissage = 1)
là, un bon exemple de l'utilité de cette loupe:
pour des scènes en pixel art surchargés:
http://www.armyoftrolls.co.uk/website/h ... d_work.htm
ici, la loupe nous permet de découvrir de petites scènes amusantes( par exemple, le type sur la plage à gauche de l'image)
http://www.armyoftrolls.co.uk/website/h ... rt/gta.htm

je ne comprend pas grand chose à ce génial code, alors quand j'arrive à obtenir un truc en trifouillant longuement, ben chuis content:
une loupe plus grande( à la ligne 321):

Code : Tout sélectionner

  ;-taille
  Rayon = ReadPreferenceLong("Taille", 150)
et ligne 366

Code : Tout sélectionner

;- moins de distorsion          
          Longueur2.f = 1 / (1 + Zoom + Longueur / Rayon* (#PI / 16) )
beauregard
Messages : 1307
Inscription : dim. 08/juil./2007 18:32
Localisation : Toulouse

idea

Message par beauregard »

J'ai une idée voyez: traduction automatique du texte qui se trouve dans, heu, sous la loupe.
Le Soldat Inconnu
Messages : 4312
Inscription : mer. 28/janv./2004 20:58
Localisation : Clermont ferrand OU Olsztyn
Contact :

Message par Le Soldat Inconnu »

J'ai mis à jour mon code, pas grand chose mais la loupe se rafraichit tout le temps et plus seulement quand on bouge la souris.
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
Ar-S
Messages : 9540
Inscription : dim. 09/oct./2005 16:51
Contact :

Message par Ar-S »

L'effet est toujours aussi splendide, par contre, serait-il possible (et tu vas m'insulter :roll: ) de supprimer non pas le zoom mais l'effet de déformation de la loupe. Je pense qu'une personne mal voyante (ma mère par exemple) risque d'être perturbé par cette déformation.

Je n'ai pas trouver ou supprimer l'effet de deformation.

Ce serait judicieux d'ajouter un menu avec déformation oui/non
ainsi l'utilisateur choisira à sa convenance.

En tout cas encore bravo
~~~~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
Répondre