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

Android Discussion :

composant stylet signature


Sujet :

Android

  1. #1
    Membre régulier
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    501
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 501
    Points : 102
    Points
    102
    Par défaut composant stylet signature
    Bonjour, je voudrai savoir quel composant faut t'il utilisé pour faire une sorte de EditText mais avec écriture avec un stylet pour une signature manuscrite

    merci les amis

  2. #2
    Membre habitué Avatar de Willy55
    Homme Profil pro
    Étudiant
    Inscrit en
    Janvier 2012
    Messages
    188
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 32
    Localisation : France, Hérault (Languedoc Roussillon)

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

    Informations forums :
    Inscription : Janvier 2012
    Messages : 188
    Points : 131
    Points
    131
    Par défaut
    Personnellement pour réaliser ça lors d'un projet, j'avais utiliser un LinearLayout dans mon layout dans lequel j'appliquais un composant "view" depuis ma classe. Je te met le code :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    private MyView myView;
    LinearLayout conteneurSignature;
    protected void onCreate(Bundle savedInstanceState) {
    	// TODO Auto-generated method stub
    	super.onCreate(savedInstanceState);
    	setContentView(R.layout.xx);
     
            conteneurSignature = (LinearLayout)findViewById(R.id.conteneurSignature);
            myView = new MyView(this);
            conteneurSignature.addView(myView);
     
    }
    Et après pour la récupération, une fois la signature dessinée :

    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
    Bitmap bmMyView = myView.getCanvasBitmap();
    //Save in file
    File folder = new File(Environment.getExternalStorageDirectory () + "/NomDuDossierPourStocker");
    if(!folder.exists())
    { 
    	folder.mkdir(); 
    }
    String extStorageDirectory = Environment.getExternalStorageDirectory().toString()+ "/NomDuDossierPourStocker";
    OutputStream outStream = null;
    File file = new File(extStorageDirectory, id+".jpg");
     
    try {
    	outStream = new FileOutputStream(file);
    	bmMyView.compress(Bitmap.CompressFormat.JPEG, 100, outStream);
    	outStream.flush();
    	outStream.close();
    } catch (FileNotFoundException e) {
    // TODO Auto-generated catch block
    	e.printStackTrace();
    } catch (IOException e) {
    // TODO Auto-generated catch block
    	e.printStackTrace();
    }
    Voila j'espère t'avoir aidé.

  3. #3
    Membre régulier
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    501
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 501
    Points : 102
    Points
    102
    Par défaut
    Salut, peut tu expliquer un peut ton code?

    j'ai créé mon layout et ma view mes comment dessiner dans le composant vew


    merci

  4. #4
    Membre habitué Avatar de Willy55
    Homme Profil pro
    Étudiant
    Inscrit en
    Janvier 2012
    Messages
    188
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 32
    Localisation : France, Hérault (Languedoc Roussillon)

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

    Informations forums :
    Inscription : Janvier 2012
    Messages : 188
    Points : 131
    Points
    131
    Par défaut
    Oups il y'en manque un bout, la prévisualisation a du buguer un peu, tu peux difficilement créer le composant MyView si je te le donne pas

    MyView.java

    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
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    import android.content.Context;
    import android.graphics.Bitmap;
    import android.graphics.Canvas;
    import android.graphics.Color;
    import android.graphics.Matrix;
    import android.graphics.Paint;
    import android.graphics.Path;
    import android.util.AttributeSet;
    import android.view.MotionEvent;
    import android.view.View;
     
    public class MyView extends View {
     
    	boolean freeTouched = false;
    	Path freePath;
     
    	Bitmap myCanvasBitmap = null;
    	Canvas myCanvas = null;
     
    	Matrix identityMatrix;
     
    	public MyView(Context context) {
    		super(context);
    	}
     
    	public MyView(Context context, AttributeSet attrs) {
    		super(context, attrs);
    	}
     
    	public MyView(Context context, AttributeSet attrs, int defStyle) {
    		super(context, attrs, defStyle);
    	}
     
    	@Override
    	protected void onDraw(Canvas canvas) {
    		canvas.drawColor(Color.WHITE);
    		if(freeTouched){
    			Paint paint = new Paint();
    			paint.setStyle(Paint.Style.STROKE);
    			paint.setColor(Color.MAGENTA);
    			paint.setStrokeWidth(5);
    //			canvas.drawColor(Color.BLACK);
     
    			myCanvas.drawPath(freePath, paint);
     
    			canvas.drawBitmap(myCanvasBitmap, identityMatrix, null);
     
    		}
    	}
     
    	@Override
    	public boolean onTouchEvent(MotionEvent event) {
    		switch(event.getAction()){
    //			case MotionEvent.ACTION_UP:
    //				freeTouched = false;
    //				break;
    			case MotionEvent.ACTION_DOWN:
    				freeTouched = true;
    				freePath = new Path();
    				freePath.moveTo(event.getX(), event.getY());
    				break;
    			case MotionEvent.ACTION_MOVE:
    				freePath.lineTo(event.getX(), event.getY());
    				invalidate();
    				break;
    		}
    		return true;
    	}
     
    	@Override
    	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    		int w = MeasureSpec.getSize(widthMeasureSpec);
    		int h = MeasureSpec.getSize(heightMeasureSpec);
     
    		myCanvasBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
    		myCanvas = new Canvas();
    		myCanvas.setBitmap(myCanvasBitmap);
     
    		identityMatrix = new Matrix();
     
    		setMeasuredDimension(w, h);
    	}
     
    	public void cleanBoard() {
    		freePath.reset();
    		myCanvasBitmap.eraseColor(Color.WHITE);
    //		mPaths.clear();
    		invalidate();
    	}
     
    	public Bitmap getCanvasBitmap(){
    //	 	myCanvasBitmap.eraseColor(Color.WHITE);
    		return myCanvasBitmap;
    	}
    }
    J'ai retrouvé le tuto dont je m'étais servi : http://android-coding.blogspot.fr/20...stom-view.html

  5. #5
    Membre régulier
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    501
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 501
    Points : 102
    Points
    102
    Par défaut
    Merci l ami je te tien au courant

  6. #6
    Membre régulier
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    501
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 501
    Points : 102
    Points
    102
    Par défaut
    Salut, bon j'ai réussi finalement à créer quelque chose, pas toute a fait au point car il faut tout de même une view assez grande pour pouvoir signer

    Ta une idée l'ami

    Merci

  7. #7
    Membre habitué Avatar de Willy55
    Homme Profil pro
    Étudiant
    Inscrit en
    Janvier 2012
    Messages
    188
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 32
    Localisation : France, Hérault (Languedoc Roussillon)

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

    Informations forums :
    Inscription : Janvier 2012
    Messages : 188
    Points : 131
    Points
    131
    Par défaut
    Oui, tout dépend de la qualité du stylet et des conditions pour signer. Une idée pour ?

  8. #8
    Membre régulier
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    501
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 501
    Points : 102
    Points
    102
    Par défaut
    Salut, donc tout fonctionne à merveille, merci beaucoup cher amis

  9. #9
    Membre régulier
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    501
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 501
    Points : 102
    Points
    102
    Par défaut
    Salut, peut tu me donner ton avis sur la discussion que j'ai posté a ce post:

    http://www.developpez.net/forums/d14...l/#post7747291

    comment mettre l'image d'une signature dans un mail

    Merci

Discussions similaires

  1. [WD16] Signature avec un stylet sur tablette
    Par EriCstoFF dans le forum WinDev
    Réponses: 4
    Dernier message: 07/04/2014, 18h48
  2. Réponses: 1
    Dernier message: 23/06/2002, 00h15
  3. Redéfinir l'événement OnExit de mon composant TEditFloat
    Par Seb des Monts dans le forum C++Builder
    Réponses: 5
    Dernier message: 18/06/2002, 16h10
  4. Installer ses composants
    Par Geronimo dans le forum C++Builder
    Réponses: 14
    Dernier message: 18/06/2002, 14h51
  5. Re-dimensionnement automatique de composants
    Par ludo_7 dans le forum C++Builder
    Réponses: 10
    Dernier message: 16/05/2002, 16h35

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