Browse Source

corrections mineurs

Jackbot 2 years ago
parent
commit
3f743c59b8
1 changed files with 14 additions and 2 deletions
  1. 14 2
      bmp2gcode.cc

+ 14 - 2
bmp2gcode.cc

@@ -46,7 +46,11 @@ void BMP2Gcode::traitement(std::string nom_fichier)
 	{
 		if(donnees() == 0)
 		{sortie();}
+		else
+		{std::cout << "une erreur s'est produite" << std::endl;}
 	}
+	else
+	{std::cout << "une erreur s'est produite" << std::endl;}
 }
 
 int BMP2Gcode::entete()
@@ -144,7 +148,6 @@ int BMP2Gcode::donnees()
 	*/
 
 	int reste = (BMP_largeur * BMP_profondeur/8) % 4, longueur_ligne = BMP_largeur * BMP_profondeur/8;
-	int limite = BMP_largeur * BMP_hauteur * BMP_profondeur/8 + BMP_offset;
 	
 	if(reste != 0)
 	{
@@ -153,6 +156,9 @@ int BMP2Gcode::donnees()
 		longueur_ligne += (4 - reste);
 	}
 
+	//Maintenant qu'on connait la taille réelle d'une ligne on peut calculer la limite
+	int limite = longueur_ligne * BMP_hauteur + BMP_offset;
+
 	char *donnees = new char [ limite ];
 	fichier.read(donnees, limite);
 
@@ -184,6 +190,12 @@ int BMP2Gcode::sortie()
 	std::ofstream fichier_sortie;
 	fichier_sortie.open (nom_fichier_gcode);
 
+	if(!fichier_sortie)
+	{
+		std::cerr << "impossible d'ouvrir le fichier de sortie" << std::endl;
+		return -1;
+	}
+
 	/****************************CONDITIONS INITIALES****************************/
 	int sens = 1, nbr_passage = 1, ligne = 0, colonne = 0;
 
@@ -322,7 +334,7 @@ int BMP2Gcode::fichier_configuration(std::string conf)
 	{
 		//alors on le crée
 		std::ofstream fichier_conf;
-		fichier_conf.open("laser.conf");
+		fichier_conf.open(conf);
 		fichier_conf << "taille_laser(mm) 0.2" << std::endl;
 		fichier_conf << "puissance_min 0" << std::endl;
 		fichier_conf << "puissance_max 255" << std::endl;