Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <math.h>
  3. #include "IHM.h"
  4.  
  5. // position de l'histogramme dans l'interface
  6. #define HISTO_L 525
  7. #define HISTO_B 580
  8.  
  9. void Set_Pixel ( int c, int L, int coul, unsigned char*Im);
  10. //void Get_Pixel ( int c, int L, unsigned char *Im[512*512] );
  11.  
  12. int main ( int argc, char** argv )
  13. {
  14. // mes variables
  15. char c;
  16. int i,coul;
  17.  
  18.  
  19. // tableau contenant l'image
  20. unsigned char mimage[HAUTEUR_IMAGE * LARGEUR_IMAGE];
  21.  
  22. // ma position
  23. int x;
  24. int y;
  25.  
  26. // initialisation de la fenêtre
  27. IHM_init();
  28.  
  29. // initialisation du tableau à partir du fichier image
  30. IHM_charge_BMP(mimage, "lena_gray.bmp");
  31. // copie du tableau dans l'affichage IHM_set_image(mimage);
  32. IHM_set_image(mimage);
  33.  
  34. // boucle principale de l'IHM
  35. while (!IHM_quitter())
  36. {
  37. // on commence par effacer
  38. IHM_efface();
  39.  
  40. x = IHM_souris_x();
  41. y = IHM_souris_y();
  42. c = IHM_getChar();
  43.  
  44. // les traitements en fonction des caractères tapés
  45. switch(c)
  46. {
  47.  
  48. case 'b':
  49. // faire la binarisation
  50. break;
  51.  
  52. case 'l':
  53. IHM_charge_BMP(mimage, "lena_gray.bmp");
  54. IHM_set_image(mimage);
  55. break;
  56.  
  57. case 'a':
  58. IHM_charge_BMP(mimage, "archives.bmp");
  59. IHM_set_image(mimage);
  60. break;
  61.  
  62. case 'h':
  63. // re-calculer l'histogramme
  64. break;
  65. }
  66.  
  67. // ajouter l'image :
  68. IHM_affiche_image(10,10);
  69.  
  70. // position du zoom
  71. IHM_rectangle(550,10,8*11,8*11,IHM_couleur(255,255,255));
  72.  
  73. // position de l'histogramme
  74. IHM_rectangle(HISTO_L,(HISTO_B - 110),110,256+10,IHM_couleur(255,255,255));
  75.  
  76. // on met à jour l'affichage
  77. IHM_affiche();
  78. for (i = 0; i < 512; i++)
  79. {
  80. Set_Pixel(i, 255, 255, mimage);
  81. Set_Pixel(255, i, 255, mimage);
  82. Set_Pixel(511 - i, i, 0, mimage);
  83. Set_Pixel(i + 1, i, 0, mimage);
  84. }
  85.  
  86. IHM_set_image(mimage);
  87. }
  88.  
  89. // fin de la boucle principale
  90. return 0;
  91. }
  92. void Set_Pixel ( int c, int L, int coul, unsigned char * im)
  93. {
  94. int i ;
  95. i= L*512+c;
  96. im[i]=coul;
  97. }
  98.  
  99. int Get_Pixel(int c, int L, unsigned char * im[512*512])
  100. {
  101.  
  102. int i;
  103. L[i]
  104.  
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement