<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ca">
	<id>http://wiki.joanillo.org/index.php?action=history&amp;feed=atom&amp;title=Llibreria_EasyBMP</id>
	<title>Llibreria EasyBMP - Historial de revisió</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.joanillo.org/index.php?action=history&amp;feed=atom&amp;title=Llibreria_EasyBMP"/>
	<link rel="alternate" type="text/html" href="http://wiki.joanillo.org/index.php?title=Llibreria_EasyBMP&amp;action=history"/>
	<updated>2026-08-30T08:39:38Z</updated>
	<subtitle>Historial de revisió per a aquesta pàgina del wiki</subtitle>
	<generator>MediaWiki 1.34.2</generator>
	<entry>
		<id>http://wiki.joanillo.org/index.php?title=Llibreria_EasyBMP&amp;diff=4010&amp;oldid=prev</id>
		<title>Joan: /* lilypond2musicbox v1.0 */</title>
		<link rel="alternate" type="text/html" href="http://wiki.joanillo.org/index.php?title=Llibreria_EasyBMP&amp;diff=4010&amp;oldid=prev"/>
		<updated>2009-11-12T23:44:02Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;lilypond2musicbox v1.0&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Pàgina nova&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Llibreria EasyBMP per manipular imatges BMP&lt;br /&gt;
=Introducció=&lt;br /&gt;
M'interessa aquesta llibreria perquè tinc la idea d'automatitzar la creació de targetes perforades que serveixin per al DIT Music Box de ThinkGeek. La idea és partir d'un fitxer de lilypond i generar un bitmap amb els punts que he de punxar...&lt;br /&gt;
&lt;br /&gt;
=Instal.lació=&lt;br /&gt;
*http://easybmp.sourceforge.net/&lt;br /&gt;
*Té llicència GPL&lt;br /&gt;
&lt;br /&gt;
Es descarrega el projecte de la pàgina de SourceForge, i també es descarrega la documentació&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sudo make&lt;br /&gt;
cp ../EasyBMP*.h .&lt;br /&gt;
cp ../EasyBMP.cpp .&lt;br /&gt;
g++ -O3 -pipe -fomit-frame-pointer -funroll-all-loops -s -c EasyBMP.cpp&lt;br /&gt;
g++ -c EasyBMPsample.cpp&lt;br /&gt;
g++ -O3 -pipe -fomit-frame-pointer -funroll-all-loops -s EasyBMP.o EasyBMPsample.o -o EasyBMPtest&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Primeres proves=&lt;br /&gt;
Mirant la documentació, faig el primer exemple, que és un conversor de imatges en color a imatges en gris:&lt;br /&gt;
&lt;br /&gt;
ColorBMPtoGrayscale.cpp:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;quot;EasyBMP.h&amp;quot;&lt;br /&gt;
using namespace std;&lt;br /&gt;
int main( int argc, char* argv[] )&lt;br /&gt;
{&lt;br /&gt;
 if( argc != 3 )&lt;br /&gt;
 {&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;Usage: ColorBMPtoGrayscale &amp;lt;input_filename&amp;gt; &amp;lt;output_filename&amp;gt;&amp;quot;&lt;br /&gt;
        &amp;lt;&amp;lt; endl &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return 1;&lt;br /&gt;
 }&lt;br /&gt;
 // declare and read the bitmap&lt;br /&gt;
 BMP Input;&lt;br /&gt;
 Input.ReadFromFile( argv[1] );&lt;br /&gt;
&lt;br /&gt;
 // convert each pixel to grayscale using RGB-&amp;gt;YUV&lt;br /&gt;
 for( int j=0 ; j &amp;lt; Input.TellHeight() ; j++)&lt;br /&gt;
 {&lt;br /&gt;
 	for( int i=0 ; i &amp;lt; Input.TellWidth() ; i++)&lt;br /&gt;
 	{&lt;br /&gt;
 		int Temp = (int) floor( 0.299*Input(i,j)-&amp;gt;Red + 0.587*Input(i,j)-&amp;gt;Green + 0.114*Input(i,j)-&amp;gt;Blue );&lt;br /&gt;
		ebmpBYTE TempBYTE = (ebmpBYTE) Temp;&lt;br /&gt;
		Input(i,j)-&amp;gt;Red   = TempBYTE;&lt;br /&gt;
		Input(i,j)-&amp;gt;Green = TempBYTE;&lt;br /&gt;
		Input(i,j)-&amp;gt;Blue = TempBYTE;&lt;br /&gt;
	}&lt;br /&gt;
 }&lt;br /&gt;
 // Create a grayscale color table if necessary&lt;br /&gt;
 if( Input.TellBitDepth() &amp;lt; 16 )&lt;br /&gt;
 { CreateGrayscaleColorTable( Input ); }&lt;br /&gt;
 // write the output file&lt;br /&gt;
 Input.WriteToFile( argv[2] );&lt;br /&gt;
 return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Compile your source code as you normally would along with the single EasyBMP.cpp file; you don’t have to link to anything. For instance, to compile the code example above with g++, use&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
g++ -o ColorBMPtoGrayscale ColorBMPtoGrayscale.cpp EasyBMP.cpp&lt;br /&gt;
./ColorBMPtoGrayscale blackbuck.bmp blackbuck_grayscale.bmp&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
i funciona perfecte&lt;br /&gt;
&lt;br /&gt;
=lilypond format to ThinkGeek Music Box: lili2musicbox=&lt;br /&gt;
Començo a treballar el codi. La idea és que tinc una plantilla amb una imatge en blanc i que té les dimensions de l'amplada que necessito. Començo a escriure en la imatge.&lt;br /&gt;
&lt;br /&gt;
lili2musicbox.cpp:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;quot;EasyBMP.h&amp;quot;&lt;br /&gt;
using namespace std;&lt;br /&gt;
int main( int argc, char* argv[] )&lt;br /&gt;
{&lt;br /&gt;
 if( argc != 3 )&lt;br /&gt;
 {&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;Usage: prova1 &amp;lt;template_filename&amp;gt; &amp;lt;output_filename&amp;gt;&amp;quot;&lt;br /&gt;
        &amp;lt;&amp;lt; endl &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return 1;&lt;br /&gt;
 }&lt;br /&gt;
 // declare and read the bitmap&lt;br /&gt;
 BMP Input;&lt;br /&gt;
 Input.ReadFromFile( argv[1] );&lt;br /&gt;
&lt;br /&gt;
Input(1,1)-&amp;gt;Red=50;&lt;br /&gt;
Input(1,1)-&amp;gt;Green=50;&lt;br /&gt;
Input(1,1)-&amp;gt;Blue=50;&lt;br /&gt;
&lt;br /&gt;
Input.WriteToFile( argv[2] );&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=lilypond2musicbox v1.0=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Autor}}, octubre 2009&lt;br /&gt;
[[Categoria: programació en C/C++]]&lt;/div&gt;</summary>
		<author><name>Joan</name></author>
		
	</entry>
</feed>