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

Rave Discussion :

Sauvegarde d'un etat sous form d' image dans un fichier


Sujet :

Rave

  1. #1
    Membre régulier
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mars 2010
    Messages
    945
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Mars 2010
    Messages : 945
    Points : 123
    Points
    123
    Par défaut Sauvegarde d'un etat sous form d' image dans un fichier
    Bonjour à tous,

    Je me trouve confronté à un probléme que je n'arrive pas à résoudre malgré toutes les recherches que j'ai fait. En effet, pour les besoins des mes clients, je voudrais convertir un état de sortie en une image dans un fichier bmp par exple et ainsi l'image peut être traitée (miniaturisation) . Avec Rave on peut faire des sauvegarde en pdf,rtf,html mais pas en (bmp, jpg..).
    merci à tous.

  2. #2
    Rédacteur/Modérateur

    Avatar de SergioMaster
    Homme Profil pro
    Développeur informatique retraité
    Inscrit en
    Janvier 2007
    Messages
    15 031
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 67
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur informatique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2007
    Messages : 15 031
    Points : 40 930
    Points
    40 930
    Billets dans le blog
    62
    Par défaut
    Bonjour,

    non , avec rave il n'est pas possible de sauvegarder l'état en JPG ou BMP , cependant puisque une page a un canvas on doit pouvoir y arriver .

    Dans le principe : à la fin de page récupérer le canvas puis sauvegarder l'image
    le problème reste alors de détecter la fin de page .le OnPrint d'un TrvNDRWriter devrait faire l'affaire je pense

    [EDIT]
    code à la volée , je laisse plein de choses sans réponse et n'ai pas le temps de faire de test
    une inconnue Canvas a t'il la proprièté ClipRect ?



    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
    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
     
    unit Unit1;
     
    interface
     
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, RpBase, RpFiler, RpDefine, RpRave, StdCtrls, ExtCtrls;
     
    type
      TForm1 = class(TForm)
        RvNDRWriter1: TRvNDRWriter;
        Button1: TButton;
        RvProject1: TRvProject;
      ...
        procedure RvNDRWriter1Print(Sender: TObject);
        procedure Button1Click(Sender: TObject);
      private
        { Déclarations privées }
      public
        { Déclarations publiques }
      end;
     
    var
      Form1: TForm1;
     
    implementation
     
    {$R *.dfm}
     
    procedure TForm1.RvNDRWriter1Print(Sender: TObject);
    var WBitmap,RBitmap : TBitmap;
        Arect : TRect;
    begin
    with (sender as TBaseReport) do
     begin
      WBitmap:=TBitmap.Create;
      Wbitmap.height:=Image1.height;
      Wbitmap.width:= Image1.width;
      RBitmap:=TBitmap.create;   // image de la taille du canvas Rave
      try
       ARect:=Canvas.ClipRect;
       Rbitmap.Canvas.CopyRect(arect,Canvas,arect);
        // taille prédéfinie du bitmap à indiquer avant
       WBitmap.Canvas.StretchDraw(Wbitmap.Canvas.ClipRect,RBitmap);
       Wbitmap.SaveToFile('page'+inttostr(CurrentPage)+'.bmp');   // récupére le numéro de page  à vérifier
      finally
        Wbitmap.Free;
        RBitmap.Free;
      end;
     end;
    end;
     
    procedure TForm1.Button1Click(Sender: TObject);
    begin
    rvproject1.open;
    rvNDRWriter1.Execute;
    RvProject1.Close;
    end;
     
    end.
    reste un problème mais de taille , le code compile mais l'image est vide à ma déchage , ce n'est pas non plus un état très valide pour tester , juste deux formes posées sur une page
    , j'attends donc un retour

    sinon il existe un outil (gratuit) qui te permet de le faire à partir d'un fichier NDR (format natif Rave) esbraveviewer c'est d'ailleurs en l'utilisant que j'ai vu que mon état était vide , ce qui tendrait à dire que c'est plus un problème d'état Rave que de code , pourtant la previsualisation est bonne
    MVP Embarcadero
    Delphi installés : D3,D7,D2010,XE4,XE7,D10 (Rio, Sidney), D11 (Alexandria), D12 (Athènes)
    SGBD : Firebird 2.5, 3, SQLite
    générateurs États : FastReport, Rave, QuickReport
    OS : Window Vista, Windows 10, Windows 11, Ubuntu, Androïd

  3. #3
    Rédacteur/Modérateur

    Avatar de SergioMaster
    Homme Profil pro
    Développeur informatique retraité
    Inscrit en
    Janvier 2007
    Messages
    15 031
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 67
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur informatique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2007
    Messages : 15 031
    Points : 40 930
    Points
    40 930
    Billets dans le blog
    62
    Par défaut Après résolution
    Finalement , il manquait un render pour pouvoir avoir un résultat

    voici donc un nouveau code (ajout d'un ScrollBox et d'un RVRenderPreview) , la beauté de la solution , la 'miniaturisation' est faite via le zoomFactor du render
    inconvénient : le scrollbox doit être visible , il y a peut être une piste a suivre dans le rpRenderCanvas

    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
    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
     
    unit Unit1;
     
    interface
     
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, RpBase, RpFiler, RpDefine, RpRave, StdCtrls, ExtCtrls, RpSystem,
      RpRender, RpRenderCanvas, RpRenderPreview;
     
    type
      TForm1 = class(TForm)
        Button1: TButton;
        RvProject1: TRvProject;
        Image1: TImage;
        RvRenderPreview1: TRvRenderPreview;
        ScrollBox1: TScrollBox;
        RvNDRWriter1: TRvNDRWriter;
        procedure Button1Click(Sender: TObject);
      private
        { Déclarations privées }
        procedure savepage(npage : integer);
      public
        { Déclarations publiques }
      end;
     
    var
      Form1: TForm1;
     
    implementation
     
    {$R *.dfm}
     
        procedure TForm1.savepage(npage : integer);
       var
           WBitmap,FBitmap : TBitmap;
           Arect : TRect;
      begin
        rvRenderPreview1.RenderPage(npage);
        FBitmap:=TBitmap.Create;
        FBitmap.Height := rvRenderPreview1.Canvas.ClipRect.Bottom;
        FBitmap.Width := rvRenderPreview1.Canvas.ClipRect.Right;
        FBitmap.Canvas.CopyRect(rvRenderPreview1.Canvas.ClipRect,rvRenderPreview1.Canvas,rvRenderPreview1.Canvas.ClipRect);
     
        WBitmap:=TBitmap.Create;
        WBitmap.Height := 100;
        WBitmap.Width := 50;
        try
         WBitmap.Canvas.StretchDraw(WBitmap.Canvas.ClipRect,FBitmap);
         Wbitmap.SaveToFile('Page'+inttostr(npage)+'.bmp');
         Image1.Picture.LoadFromFile('Page'+inttostr(npage)+'.bmp');
        finally
         Wbitmap.Free;
         FBitMap.Free;
        end;
       end;
     
     
    procedure TForm1.Button1Click(Sender: TObject);
      var Strm : TFileStream;
          i : Integer;
    begin
     strm := TFileStream.Create('test.ndr', fmCreate or fmOpenWrite);
      try
        RvNDRWriter1.StreamMode := smUser;
        RvNDRWriter1.Stream := strm;
        RvNDRWriter1.Start;
        RvProject1.Close;
        RvProject1.ProjectFile := 'C:\Lalet\LaletBDS\Test\Project1.rav';
        RvProject1.Open;
        rvProject1.ExecuteReport('report1');
        RvNDRWriter1.Finish;
      finally
        RvRenderPreview1.Render(strm);
        RvRenderPreview1.Active := True;
        for i:=1 to rvRenderPreview1.Pages do
          SavePage(i);
        RvRenderPreview1.Active := False;
        strm.Free;
      end;
    end;
     
    end;
    Code dfm : 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
    object Form1: TForm1
      Left = 498
      Top = 222
      Width = 638
      Height = 563
      Caption = 'Form1'
      Color = clBtnFace
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = []
      OldCreateOrder = False
      PixelsPerInch = 96
      TextHeight = 13
      object Image1: TImage
        Left = 48
        Top = 136
        Width = 265
        Height = 345
      end
      object Button1: TButton
        Left = 24
        Top = 32
        Width = 75
        Height = 25
        Caption = 'Button1'
        TabOrder = 0
        OnClick = Button1Click
      end
      object ScrollBox1: TScrollBox
        Left = 320
        Top = 136
        Width = 209
        Height = 305
        TabOrder = 1
        Visible = False
      end
      object RvProject1: TRvProject
        Engine = RvNDRWriter1
        ProjectFile = 'Project1.rav'
        Left = 328
        Top = 40
      end
      object RvRenderPreview1: TRvRenderPreview
        DisplayName = 'RPRender'
        ScrollBox = ScrollBox1
        ZoomFactor = 25.000000000000000000   
        MarginMethod = mmScaled
        ShadowDepth = 0
        Left = 520
        Top = 112
      end
      object RvNDRWriter1: TRvNDRWriter
        StatusFormat = 'Printing page %p'
        UnitsFactor = 1.000000000000000000
        Title = 'Rave Report'
        Orientation = poPortrait
        ScaleX = 100.000000000000000000
        ScaleY = 100.000000000000000000
        FileName = 'test.ndr'
        OnPrintPage = RvNDRWriter1PrintPage
        Left = 488
        Top = 48
      end
    end

    [edit] après remaniement le zoomfactor n'a plus vraiment d'importance , reste seulement a trouver la bonne taille de miniature
    MVP Embarcadero
    Delphi installés : D3,D7,D2010,XE4,XE7,D10 (Rio, Sidney), D11 (Alexandria), D12 (Athènes)
    SGBD : Firebird 2.5, 3, SQLite
    générateurs États : FastReport, Rave, QuickReport
    OS : Window Vista, Windows 10, Windows 11, Ubuntu, Androïd

  4. #4
    Membre régulier
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mars 2010
    Messages
    945
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Mars 2010
    Messages : 945
    Points : 123
    Points
    123
    Par défaut
    Bonjour @sergio, je vai voir avec ton code et je te tien au courant.

  5. #5
    Membre régulier
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mars 2010
    Messages
    945
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Mars 2010
    Messages : 945
    Points : 123
    Points
    123
    Par défaut
    bonjour @segio, j'ai essayé les 2 codes même si franchement j'ai pas tout compris, mais malheureusement l'image qui est crée est vide (feuille blanche). j'ai fait plusieurs test mais le résultat est toujours le même.

  6. #6
    Rédacteur/Modérateur

    Avatar de SergioMaster
    Homme Profil pro
    Développeur informatique retraité
    Inscrit en
    Janvier 2007
    Messages
    15 031
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 67
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur informatique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2007
    Messages : 15 031
    Points : 40 930
    Points
    40 930
    Billets dans le blog
    62
    Par défaut
    Bonjour,

    le premier code était fait "à la volée" et ne fonctionnait pas
    le second code à 14h09 fonctionne parfaitement sous D7 raveVersJPG.zip
    MVP Embarcadero
    Delphi installés : D3,D7,D2010,XE4,XE7,D10 (Rio, Sidney), D11 (Alexandria), D12 (Athènes)
    SGBD : Firebird 2.5, 3, SQLite
    générateurs États : FastReport, Rave, QuickReport
    OS : Window Vista, Windows 10, Windows 11, Ubuntu, Androïd

  7. #7
    Membre régulier
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mars 2010
    Messages
    945
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Mars 2010
    Messages : 945
    Points : 123
    Points
    123
    Par défaut
    Bonjour Segio,
    j'ai intégré le code en l'adaptant à mon programme est ça marche , merci beaucoup. Par contre à quoi sert le "Scrollbox"?.

  8. #8
    Rédacteur/Modérateur

    Avatar de SergioMaster
    Homme Profil pro
    Développeur informatique retraité
    Inscrit en
    Janvier 2007
    Messages
    15 031
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 67
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur informatique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2007
    Messages : 15 031
    Points : 40 930
    Points
    40 930
    Billets dans le blog
    62
    Par défaut
    Citation Envoyé par chekkal Voir le message
    j'ai intégré le code en l'adaptant à mon programme est ça marche , merci beaucoup.
    cela aurait donc mérité un
    Par contre à quoi sert le "Scrollbox"?.
    c'est obligatoire (du moins avec Rave 5 et D7 , je n'ai pas essayé avec D2010), si on l'enlève on a l'erreur
    Citation Envoyé par le programme
    ScrollBox must be assigned for RenderPreview component.
    maintenant rien n'empêche de créer le scrollbox à la volée, de l'assigner au rvrenderPreview puis de le libérer à la fin, comme ceci (ajout de SCBox)
    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
     
    procedure TForm1.Button1Click(Sender: TObject);
      var Strm : TFileStream;
          SCBox : TScrollBox;
          i : Integer;
    begin
     strm := TFileStream.Create('test.ndr', fmCreate or fmOpenWrite);
     scBox := TScrollBox.Create(nil);
      try
        ScBox.Parent:=Self;
        scBox.Visible:=False;
        RvRenderPreview1.ScrollBox:=scBox;
        RvNDRWriter1.StreamMode := smUser;
        RvNDRWriter1.Stream := strm;
        RvNDRWriter1.Start;
        RvProject1.Close;
        RvProject1.ProjectFile := ExtractFileDir(ParamStr(0))+'\Project1.rav';
        RvProject1.Open;
        rvProject1.ExecuteReport('report1');
        RvNDRWriter1.Finish;
        RvRenderPreview1.Render(strm);
        RvRenderPreview1.Active := True;
     //   for i:=1 to rvRenderPreview1.Pages do
        SavePage(i);
        RvRenderPreview1.Active := False;
      finally
        scBox.Free;
        strm.Free;
      end;
    end;
    le code n'est peut être pas très optimum , les 2 free devrait être tester (if assigned(variable) then variable.free)
    j'ai revu la partie finally en remontant la "partie" sauvegarde
    On peut bien sur , facilement sauvegarder en JPG plutôt que BMP , cette partie de code se trouve facilement dans la FAQ de Delphi
    à vérifier également , que le fichier stream 'test.ndr' disparaisse après
    MVP Embarcadero
    Delphi installés : D3,D7,D2010,XE4,XE7,D10 (Rio, Sidney), D11 (Alexandria), D12 (Athènes)
    SGBD : Firebird 2.5, 3, SQLite
    générateurs États : FastReport, Rave, QuickReport
    OS : Window Vista, Windows 10, Windows 11, Ubuntu, Androïd

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Sauvegarder une scène GLScene sous forme d'une image
    Par essof_salhi dans le forum Delphi
    Réponses: 4
    Dernier message: 12/06/2014, 01h45
  2. Réponses: 5
    Dernier message: 18/11/2013, 15h20
  3. Trier données sous forme de dictionnaire dans un fichier
    Par pinard dans le forum Général Python
    Réponses: 3
    Dernier message: 17/11/2011, 17h37
  4. etat sous forme de tableau
    Par edzodzinam dans le forum Access
    Réponses: 3
    Dernier message: 16/01/2008, 10h23
  5. Récupérer la valeur d'un submit sous forme d'image
    Par Jim_Nastiq dans le forum Langage
    Réponses: 6
    Dernier message: 28/04/2006, 10h12

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