IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

 Delphi Discussion :

Que pensez-vous de mon scrolling iPhone like ? :)


Sujet :

Delphi

  1. #41
    Modérateur

    Homme Profil pro
    Ingénieur retraité
    Inscrit en
    Octobre 2005
    Messages
    2 396
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Ingénieur retraité

    Informations forums :
    Inscription : Octobre 2005
    Messages : 2 396
    Points : 3 263
    Points
    3 263
    Par défaut
    Re-salut,

    Une question, à l'ouverture de l'application on charge un bitmap desktop. Est t'il supprimé quand on charge après un bmp ou jpg ou est t'il supperposé à celui d'origine ?
    ... attention un bitmap c'est comme une ardoise effacable virtuelle sur laquelle une image prend la place de la précédente.

    FDesktop est du type TBitMap et comme c'est une variable :
    - à l'ouverture de l'application il lui est affecté automatiquement le bitmap de la copie de l'écran,
    - et quand par la suite on charge un fichier au format *.bmp le bitmap correspondant vient remplacer le bitmap de la copie d'écran ... et si on charge un fichier *.jpg ou *.gif celui-ci est d'abord converti en BitMap par les fonctions du genre BMPdeJPEG( ): TBitmap; BMPdeGIF( ) ): TBitmap.

    On ne peut pas superposer deux bitmap ... par contre on peut créer à partir d'eux un troisième bitmap qui est une combinaison numérique des deux : Si tu prends X% de l'intensité R,G,B de chaque pixel du 1er bmp et (100-X)% du 2ième et que tu les ajoutes en créant le 3ième bmp, ce troisième aura l'aspect d'une photo d'un fondu-enchaîné.

    A+
    N'oubliez pas de consulter les FAQ Delphi et les cours et tutoriels Delphi

  2. #42
    Membre expérimenté
    Profil pro
    Inscrit en
    Janvier 2006
    Messages
    2 426
    Détails du profil
    Informations personnelles :
    Âge : 71
    Localisation : Belgique

    Informations forums :
    Inscription : Janvier 2006
    Messages : 2 426
    Points : 1 326
    Points
    1 326
    Par défaut
    @ Gilbert Geyer, merci pour ton code permettant de modifier le background de l'iphone et de tes explications.

    @+,

    Cincap

  3. #43
    Expert éminent sénior
    Avatar de Paul TOTH
    Homme Profil pro
    Freelance
    Inscrit en
    Novembre 2002
    Messages
    8 964
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Freelance
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2002
    Messages : 8 964
    Points : 28 445
    Points
    28 445
    Par défaut
    pour la petite histoire, je me suis amusé à faire le même effet en C#...bizarrement l'image est plus grise et j'ai des pixels blancs dans mon image...

    Code C# : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
     
    private void TransformImage(Bitmap ABitmap)
        {
          GraphicsUnit unit = GraphicsUnit.Pixel;
          RectangleF BoundsF = ABitmap.GetBounds(ref unit);
          Rectangle Bounds = new Rectangle((int)BoundsF.X, (int)BoundsF.Y, (int)BoundsF.Width, (int)BoundsF.Height);
          BitmapData Data = ABitmap.LockBits(Bounds, ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
          IntPtr ScanLine = Data.Scan0;
          int Size = ABitmap.Width * ABitmap.Height;
          int[] Pixels = new int[Size];
          System.Runtime.InteropServices.Marshal.Copy(ScanLine, Pixels, 0, Size);
          for (int i = 0; i < Size; i++  )
          {
            Pixels[i] = (int)(((uint)Pixels[i] & (uint)0xFEFEFEFE) >> 1);
          }
          System.Runtime.InteropServices.Marshal.Copy(Pixels, 0, ScanLine, Size);
          ABitmap.UnlockBits(Data);
          FHook.X = 0;
          FHook.Y = 0;
          FHook = PointToScreen(FHook);
          FHook.X = -FHook.X;
          FHook.Y = -FHook.Y;
        }
     
        private void MainForm_Load(object sender, EventArgs e)
        {
          FBitmap = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb);
          Graphics cGraphic = Graphics.FromImage(FBitmap);
          cGraphic.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
          TransformImage(FBitmap);
        }

    Nom : bug.jpg
Affichages : 73
Taille : 55,8 Ko
    Developpez.com: Mes articles, forum FlashPascal
    Entreprise: Execute SARL
    Le Store Excute Store

  4. #44
    Modérateur

    Homme Profil pro
    Ingénieur retraité
    Inscrit en
    Octobre 2005
    Messages
    2 396
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Ingénieur retraité

    Informations forums :
    Inscription : Octobre 2005
    Messages : 2 396
    Points : 3 263
    Points
    3 263
    Par défaut
    Bonjour,

    "... bizarrement l'image est plus grise et j'ai des pixels blancs dans mon image..."
    ... ben, sans connaître les mystères du C, on peut s'attendre à ce que le C ne réalise pas exactement de la même façon, par exemple, ce qui est codé sous Delphi dans la procedure TransformColor : vive Delphi !.

    A+.
    N'oubliez pas de consulter les FAQ Delphi et les cours et tutoriels Delphi

  5. #45
    Membre éclairé Avatar de Kaféine
    Homme Profil pro
    Inscrit en
    Avril 2007
    Messages
    569
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Avril 2007
    Messages : 569
    Points : 736
    Points
    736
    Par défaut
    En l'occurence c'est du C#...

    j'ai testé ce code et j'ai rien du tout ?!

    wtf?

    EDIT: haha quel naze je suis il faut coller le bmp dans le OnPaint
    Akim Merabet

  6. #46
    Membre éclairé Avatar de Kaféine
    Homme Profil pro
    Inscrit en
    Avril 2007
    Messages
    569
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Avril 2007
    Messages : 569
    Points : 736
    Points
    736
    Par défaut
    ca marche chez moi... enfin je crois

    EDIT: non ca marché pas
    Images attachées Images attachées  
    Akim Merabet

  7. #47
    Membre chevronné Avatar de chaplin
    Profil pro
    Inscrit en
    Août 2006
    Messages
    1 215
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 1 215
    Points : 1 819
    Points
    1 819
    Par défaut
    Citation Envoyé par Paul TOTH Voir le message
    pour la petite histoire, je me suis amusé à faire le même effet en C#...bizarrement l'image est plus grise et j'ai des pixels blancs dans mon image...

    Code C# : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
     
    private void TransformImage(Bitmap ABitmap)
        {
          GraphicsUnit unit = GraphicsUnit.Pixel;
          RectangleF BoundsF = ABitmap.GetBounds(ref unit);
          Rectangle Bounds = new Rectangle((int)BoundsF.X, (int)BoundsF.Y, (int)BoundsF.Width, (int)BoundsF.Height);
          BitmapData Data = ABitmap.LockBits(Bounds, ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
          IntPtr ScanLine = Data.Scan0;
          int Size = ABitmap.Width * ABitmap.Height;
          int[] Pixels = new int[Size];
          System.Runtime.InteropServices.Marshal.Copy(ScanLine, Pixels, 0, Size);
          for (int i = 0; i < Size; i++  )
          {
            Pixels[i] = (int)(((uint)Pixels[i] & (uint)0xFEFEFEFE) >> 1);
          }
          System.Runtime.InteropServices.Marshal.Copy(Pixels, 0, ScanLine, Size);
          ABitmap.UnlockBits(Data);
          FHook.X = 0;
          FHook.Y = 0;
          FHook = PointToScreen(FHook);
          FHook.X = -FHook.X;
          FHook.Y = -FHook.Y;
        }
     
        private void MainForm_Load(object sender, EventArgs e)
        {
          FBitmap = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb);
          Graphics cGraphic = Graphics.FromImage(FBitmap);
          cGraphic.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
          TransformImage(FBitmap);
        }
    Même si la présentation du code pourrait être améliorée, je sais pas pourquoi je préfère la syntaxe Delphi(pascal/procédurale&objet) et que le la programmation purement objet devient parfois indigeste. Je préfère avoir les variables déclarées à l'exterieur du bloc de la procédure .. contrairement à certaines opinions.

    C'est vrai que les couleurs dans l'EDI apportent énormément à la lisibilité.

  8. #48
    Rédacteur/Modérateur
    Avatar de Andnotor
    Inscrit en
    Septembre 2008
    Messages
    5 694
    Détails du profil
    Informations personnelles :
    Localisation : Autre

    Informations forums :
    Inscription : Septembre 2008
    Messages : 5 694
    Points : 13 130
    Points
    13 130
    Par défaut
    @ Paul Toth

    En Delphi, la couleur est codée $AABBGGRR alors qu'en C, $RRGGBBAA.
    En C#, tu devrais essayer un shl à la place d'un shr.

  9. #49
    Expert éminent sénior
    Avatar de Paul TOTH
    Homme Profil pro
    Freelance
    Inscrit en
    Novembre 2002
    Messages
    8 964
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Freelance
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2002
    Messages : 8 964
    Points : 28 445
    Points
    28 445
    Par défaut
    Citation Envoyé par Andnotor Voir le message
    @ Paul Toth

    En Delphi, la couleur est codée $AABBGGRR alors qu'en C, $RRGGBBAA.
    En C#, tu devrais essayer un shl à la place d'un shr.
    peu importe je masque le bit de poids faible de chaque composante ( & 0xFEFEFEFE) et je décale à droite ( >> 1 )pour diviser les valeurs par 2

    à moins que C# ne tienne compte du canal Alpha ?...GAGNE

    Code C# : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    Pixels[i] = (int)((((uint)Pixels[i] & (uint)0x00FEFEFE) >> 1) | 0xFF000000);
    Developpez.com: Mes articles, forum FlashPascal
    Entreprise: Execute SARL
    Le Store Excute Store

  10. #50
    Membre éclairé Avatar de Kaféine
    Homme Profil pro
    Inscrit en
    Avril 2007
    Messages
    569
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Avril 2007
    Messages : 569
    Points : 736
    Points
    736
    Par défaut
    je pense que j'ai compris:

    Paul doit faire ça dans le OnPaint

    Code C# : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
      Graphics g = CreateGraphics();
      g.DrawImage(FBitmap, new Point(0, 0));


    alors que j'ai fait ca

    Code C# : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
      Graphics g = e.Graphics;
      g.DrawImage(FBitmap, new Point(0, 0));
    Akim Merabet

  11. #51
    Expert éminent sénior
    Avatar de Paul TOTH
    Homme Profil pro
    Freelance
    Inscrit en
    Novembre 2002
    Messages
    8 964
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Freelance
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2002
    Messages : 8 964
    Points : 28 445
    Points
    28 445
    Par défaut
    Citation Envoyé par Kaféine Voir le message
    je pense que j'ai compris:

    Paul doit faire ça dans le OnPaint

    Code C# : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
      Graphics g = CreateGraphics();
      g.DrawImage(FBitmap, new Point(0, 0));


    alors que j'ai fait ca

    Code C# : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
      Graphics g = e.Graphics;
      g.DrawImage(FBitmap, new Point(0, 0));
    j'en fait un tout petit peu plus ^^ mais j'utilise bien e.Graphics

    Code c# : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
     
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Drawing.Imaging;
    using System.Text;
    using System.Windows.Forms;
     
    namespace Test.Net
    {
      public partial class MainForm : Form
      {
        private static Bitmap FBitmap;
        private static Point FHook;
        private static long FSpeed;
        private static Point FVector;
        private static long FDownTime;
        private static Point FDownPos;
        private static Point FDownState;
        private static long FMoveTime;
        private static long FTicks;
     
        public MainForm()
        {
          InitializeComponent();
        }
     
        private void TransformImage(Bitmap ABitmap)
        {
          GraphicsUnit unit = GraphicsUnit.Pixel;
          RectangleF BoundsF = ABitmap.GetBounds(ref unit);
          Rectangle Bounds = new Rectangle((int)BoundsF.X, (int)BoundsF.Y, (int)BoundsF.Width, (int)BoundsF.Height);
          BitmapData Data = ABitmap.LockBits(Bounds, ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
          IntPtr ScanLine = Data.Scan0;
          int Size = ABitmap.Width * ABitmap.Height;
          int[] Pixels = new int[Size];
          System.Runtime.InteropServices.Marshal.Copy(ScanLine, Pixels, 0, Size);
          for (int i = 0; i < Size; i++  )
          {
            Pixels[i] = (int)((((uint)Pixels[i] & (uint)0x00FEFEFE) >> 1) | 0xFF000000);
          }
          System.Runtime.InteropServices.Marshal.Copy(Pixels, 0, ScanLine, Size);
          ABitmap.UnlockBits(Data);
          FHook.X = 0;
          FHook.Y = 0;
          FHook = PointToScreen(FHook);
          FHook.X = -FHook.X;
          FHook.Y = -FHook.Y;
        }
     
        private void MainForm_Load(object sender, EventArgs e)
        {
          FBitmap = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb);
          Graphics cGraphic = Graphics.FromImage(FBitmap);
          cGraphic.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
          TransformImage(FBitmap);
        }
     
        private void MainForm_Paint(object sender, PaintEventArgs e)
        {
          if (FSpeed > 0)
          {
            long cTicks = DateTime.Now.Ticks;
            long cDelta = (cTicks - FTicks) / 10000; // 10.000 ticks in 1 ms
            FTicks = cTicks;
     
            if (cDelta > 0) 
            {
              long cDx = FVector.X * cDelta / FSpeed;
              long cDy = FVector.Y * cDelta / FSpeed;
              if ((cDx == 0) && (cDy == 0))
              {
                FVector.X = 0;
                FVector.Y = 0;
                FSpeed = 0;
              }
              else 
              {
                FHook.X += (int)cDx;
                FHook.Y += (int)cDy;
                FSpeed += (long)((float)(FSpeed * cDelta) / 1000);
                if ((FVector.X == 0) && (FVector.Y == 0))
                  FSpeed = 0;
              }
     
            }
          }
          if (FHook.X > 0)
          {
            FHook.X = 0;
            FVector.X = 0;
          }
          if (FHook.Y > 0)
          {
            FHook.Y = 0;
            FVector.Y = 0;
          }
          if (FHook.X < ClientSize.Width - FBitmap.Width)
          {
            FHook.X = ClientSize.Width - FBitmap.Width; 
            FVector.X = 0;
          }
          if (FHook.Y < ClientSize.Height - FBitmap.Height)
          {
            FHook.Y = ClientSize.Height - FBitmap.Height;
            FVector.Y = 0;
          }
          e.Graphics.DrawImage(FBitmap, FHook);
          if (FSpeed > 0) 
            Invalidate();
     
        }
     
        private void MainForm_MouseDown(object sender, MouseEventArgs e)
        {
          FSpeed = 0;
          FVector.X = 0;
          FVector.Y = 0;
          FDownTime = DateTime.Now.Ticks;
          FDownPos.X = e.X;
          FDownPos.Y = e.Y;
          FDownState = FDownPos;
        }
     
        private void MainForm_MouseMove(object sender, MouseEventArgs e)
        {
          if (e.Button != MouseButtons.None)
          { 
            FHook.X += e.X - FDownState.X;
            FHook.Y += e.Y - FDownState.Y;
            FDownState.X = e.X;
            FDownState.Y = e.Y;
            FMoveTime = DateTime.Now.Ticks;
            if (FMoveTime - FDownTime > 1500000)
            {
              FDownPos = FDownState;
              FDownTime = FMoveTime;
            }
            Invalidate();
          }
        }
     
        private void MainForm_MouseUp(object sender, MouseEventArgs e)
        {
          if (FDownTime > 0)
          {
            FVector.X += e.X - FDownPos.X;
            FVector.Y += e.Y - FDownPos.Y;
            FTicks = DateTime.Now.Ticks;
            FSpeed = (FTicks - FDownTime) / 10000;
            FDownTime = 0;
            Invalidate();
          }
        }
      }
    }
    Developpez.com: Mes articles, forum FlashPascal
    Entreprise: Execute SARL
    Le Store Excute Store

  12. #52
    Membre éclairé Avatar de Kaféine
    Homme Profil pro
    Inscrit en
    Avril 2007
    Messages
    569
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Avril 2007
    Messages : 569
    Points : 736
    Points
    736
    Par défaut
    Ceci a l'air de fonctionner, enfin j'ai l'impression d'avoir le même résultat

    à la place de l'existant:
    Code C# : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
        Pixels[i] = (int)((Pixels[i] & 0xFEFEFEFE)) >> 1;

    En outre il existe déjà une méthode appellé SetPixel dans Bitmap qui s'occupe de locker le bmp...

    Code C# : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
     
      for (int x = 0; x < ABitmap.Width; x++)
      {
            for (int y = 0; y < ABitmap.Height; y++)
            {
                 Color oldColor = ABitmap.GetPixel(x, y);
                 int tmp = (int)(oldColor.ToArgb() & 0xFEFEFEFE) >> 1;
                 Color newColor = Color.FromArgb((int)tmp);
                 ABitmap.SetPixel(x, y, newColor); 
            }
      }
    Akim Merabet

  13. #53
    Rédacteur/Modérateur
    Avatar de Andnotor
    Inscrit en
    Septembre 2008
    Messages
    5 694
    Détails du profil
    Informations personnelles :
    Localisation : Autre

    Informations forums :
    Inscription : Septembre 2008
    Messages : 5 694
    Points : 13 130
    Points
    13 130
    Par défaut
    Citation Envoyé par Paul TOTH Voir le message
    à moins que C# ne tienne compte du canal Alpha ?...GAGNE

    Code C# : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    Pixels[i] = (int)((((uint)Pixels[i] & (uint)0x00FEFEFE) >> 1) | 0xFF000000);
    Alors plutôt que de modifier les 3 composantes, tu pourrais mettre le fond de ta fiche en noir et ne jouer que sur la composante alpha .
    Ca pourrait être intéressant de conserver la couleur d'origine pour une évolution future (IPhone 3 ).

  14. #54
    Expert éminent sénior
    Avatar de Paul TOTH
    Homme Profil pro
    Freelance
    Inscrit en
    Novembre 2002
    Messages
    8 964
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Freelance
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2002
    Messages : 8 964
    Points : 28 445
    Points
    28 445
    Par défaut
    Citation Envoyé par Andnotor Voir le message
    Alors plutôt que de modifier les 3 composantes, tu pourrais mettre le fond de ta fiche en noir et ne jouer que sur la composante alpha .
    Ca pourrait être intéressant de conserver la couleur d'origine pour une évolution future (IPhone 3 ).
    hey mais c'est vachement pas bête ça

    il doit même être possible de passer par un ImageAttributes...mais bon l'idée au départ était d'avoir une fonction TransformPixel() et je n'ai fais cet effet que par manque d'inspiration

    Code c# : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
          for (int i = 0; i < Size; i++  )
          {
            //Pixels[i] = (int)((((uint)Pixels[i] & (uint)0x00FEFEFE) >> 1) | 0xFF000000);
            Pixels[i] = (int)(((uint)Pixels[i] & (uint)0x00FFFFFF) | 0x7F000000);
          }
    Developpez.com: Mes articles, forum FlashPascal
    Entreprise: Execute SARL
    Le Store Excute Store

  15. #55
    Rédacteur/Modérateur
    Avatar de Andnotor
    Inscrit en
    Septembre 2008
    Messages
    5 694
    Détails du profil
    Informations personnelles :
    Localisation : Autre

    Informations forums :
    Inscription : Septembre 2008
    Messages : 5 694
    Points : 13 130
    Points
    13 130
    Par défaut
    Et je dirais même que le canal alpha est à $FF (opaque) par défaut.
    Une petite simplification

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Pixels[i] = (int)((uint)Pixels[i] & (uint)0x7FFFFFFF);

  16. #56
    Membre éprouvé
    Avatar de Montor
    Homme Profil pro
    Autre
    Inscrit en
    Avril 2008
    Messages
    879
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Autre

    Informations professionnelles :
    Activité : Autre

    Informations forums :
    Inscription : Avril 2008
    Messages : 879
    Points : 963
    Points
    963
    Par défaut
    Moi aussi je ose pour modifier ce code pour le rendre facile a comprendre
    fonctions modifiées
    Fonction TransformBitmap
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    procedure TransformBitmap(aBitmap : TBitmap;ARect:TRect;AMs:TColor=clBlack);
    var
      x, y : Integer;
      Pixel: PCardinal;
    begin
    // effectuer une transformation sur chaque pixel de l'image
     
     // if IsRectEmpty(ARect) then Exit;
      with aBitmap.Canvas,ARect do
         if not PtInRect(ClipRect,TopLeft) or
            not PtInRect(ClipRect,BottomRight) then Exit;
     
      aBitmap.PixelFormat := pf32Bit;
      for y := ARect.Top to ARect.Bottom do
      begin
        Pixel := aBitmap.ScanLine[y];
        inc(Pixel,ARect.Left);
        for x := ARect.Left to ARect.Right do
        begin
           Pixel^ :=((Pixel^ and $00FEFEFE) shr 1)xor AMs;
           Inc(Pixel);
        end;
      end;
    end;
    Une partie de la fonction FormPaint
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
      if FDownTime = 0 then
      with  FBounds do
        begin
          if IsRectEmpty(Rect(FLeft,Left,Right,FLeft)) then
          begin
            FLeft     := Min(FLeft,Right);
            FLeft     := Max(FLeft,Left );
            FVector.X := 0;
            cRedraw   := True;
          end;
          if IsRectEmpty(Rect(FTop,Top,Bottom,FTop)) then
          begin
            FTop      := Min(FTop,Bottom);
            FTop      := Max(FTop,Top );
            FVector.Y := 0;
            cRedraw   := True;
          end;
       end;
     
      with FBitmap.Canvas do
      begin
      // dessiner l'image
        Brush.Color := $606060;
        FillRect(Rect(0, 0, FBitmap.Width, FBitmap.Height));
        Draw(FLeft, FTop, FDesktop);
        DrawScrollBars;
      end;
      Canvas.Draw(0, 0, FBitmap);
      if cRedraw then
        Invalidate;
    end;
    fonction DrawScrollBars
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    function _ScrollBars(var AStart,ALen:integer;TL,AOP1,AOP2,DES:integer):boolean;
    begin
       result:=false;
      if (AOP1> 10) then
      begin
        result :=true;
        ALen   := MulDiv((AOP2 - 17), AOP2, DES);
        AStart := MulDiv(5 - (AOP2 - 17), TL, DES);
        if AStart < 5 then
        begin
          inc(ALen, AStart - 5);
          AStart := 5;
        end;
        if AStart + ALen > AOP2 - 17 then
          ALen := AOP2 - 17 - AStart;
      end;
     
    end;
     
    procedure TMainForm.DrawScrollBars;
    var
      start: Integer;
      len  : Integer;
    begin
      with FBitmap do
      begin
       if _ScrollBars(start, len, FLeft, Height, Width, FDesktop.Width) then
         TransformBitmap(FBitmap, Bounds(start, Height - 10, len, 5),clCream);
     
       if _ScrollBars(start, len, Ftop, Width, Height, FDesktop.Height) then
         TransformBitmap(FBitmap, Bounds(Width - 10, start, 5, len),clCream);
      end;
     
    end;

  17. #57
    Membre éprouvé
    Avatar de Montor
    Homme Profil pro
    Autre
    Inscrit en
    Avril 2008
    Messages
    879
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Autre

    Informations professionnelles :
    Activité : Autre

    Informations forums :
    Inscription : Avril 2008
    Messages : 879
    Points : 963
    Points
    963
    Par défaut
    bonjour j'ai oublié de publier la ligne de code pour chargemnt de l'image avec la nouvelle fonction TransformBitmap
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
      TransformBitmap(FDesktop,rect(0,0,FDesktop.Width-1,FDesktop.Height-1));
    j'ajoute aussi qu'il faut ajouter Invalidate() a la procedure FormResize
    Il vaut mieux supprimer ces ligne sur la nouvelle fonction TransformBitmap elles ne font pas grande chose mais ralentissent l'exécution
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
      with aBitmap.Canvas,ARect do
         if not PtInRect(ClipRect,TopLeft) or
            not PtInRect(ClipRect,BottomRight) then Exit;

  18. #58
    Membre éprouvé
    Avatar de Montor
    Homme Profil pro
    Autre
    Inscrit en
    Avril 2008
    Messages
    879
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Autre

    Informations professionnelles :
    Activité : Autre

    Informations forums :
    Inscription : Avril 2008
    Messages : 879
    Points : 963
    Points
    963
    Par défaut
    je vous signale une remarque si on a des controls sur la fiche ils seront désactivés durant le scroll probleme résolu mais je pense que un TForm n'est le bon control pour faire ce genre d'applis un TPaintBox c'est mieux placé Invalidate avec un Twincontrol va faire des autres Invalidats pour tout ses controls

  19. #59
    Expert éminent sénior
    Avatar de Paul TOTH
    Homme Profil pro
    Freelance
    Inscrit en
    Novembre 2002
    Messages
    8 964
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Freelance
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2002
    Messages : 8 964
    Points : 28 445
    Points
    28 445
    Par défaut
    Citation Envoyé par Montor Voir le message
    je vous signale une remarque si on a des controls sur la fiche ils seront désactivés durant le scroll probleme résolu mais je pense que un TForm n'est le bon control pour faire ce genre d'applis un TPaintBox c'est mieux placé Invalidate avec un Twincontrol va faire des autres Invalidats pour tout ses controls
    alors replaçons les choses dans leur contexte

    j'ai juste voulu reproduire l'effet de scrolling d'un iPhone, pour cela j'ai pris le desktop qui présente l'avantage de ne pas avoir a choisir un bitmap et j'ai codé directement le comportement dans la fiche car je n'avais pas d'autre besoin.

    pour faire scroller des contrôles c'est plutôt le déplacement d'un TWinControl conteneur qu'il faudrait gérer.
    Developpez.com: Mes articles, forum FlashPascal
    Entreprise: Execute SARL
    Le Store Excute Store

  20. #60
    Rédacteur/Modérateur
    Avatar de Andnotor
    Inscrit en
    Septembre 2008
    Messages
    5 694
    Détails du profil
    Informations personnelles :
    Localisation : Autre

    Informations forums :
    Inscription : Septembre 2008
    Messages : 5 694
    Points : 13 130
    Points
    13 130
    Par défaut
    Citation Envoyé par Montor Voir le message
    je vous signale une remarque si on a des controls sur la fiche ils seront désactivés durant le scroll probleme résolu mais je pense que un TForm n'est le bon control pour faire ce genre d'applis un TPaintBox c'est mieux placé Invalidate avec un Twincontrol va faire des autres Invalidats pour tout ses controls
    Dans le cas présent, il serait judicieux de briser la linéarité de ton texte en rajoutant quelques ponctuations et retours à la ligne

Discussions similaires

  1. que pensez vous de mon site http://www.tout57.fr
    Par alain57 dans le forum Mon site
    Réponses: 4
    Dernier message: 21/01/2007, 12h47
  2. [Avis] Que pensez-vous de mon C.V.
    Par skynet dans le forum CV
    Réponses: 22
    Dernier message: 30/09/2006, 18h49
  3. Réponses: 11
    Dernier message: 09/09/2006, 15h54
  4. [SGBD/MLD]Que pensez vous de mon MLD?
    Par Bils dans le forum Décisions SGBD
    Réponses: 8
    Dernier message: 29/03/2006, 16h50
  5. que pensez vous de mon code source ecrit en c++(je debute)
    Par superspike23 dans le forum Débuter
    Réponses: 6
    Dernier message: 06/10/2005, 18h26

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo