Código:
import "mod_map";
import "mod_file";
import "mod_mem";
function int split_map( int file, int graph )
private
int fileout, g;
int w, h, depth, pitch;
int i;
char * gbuff, * gbuffo;
begin
w = map_info( file, graph, G_WIDTH );
h = map_info( file, graph, G_HEIGHT );
depth = map_info( file, graph, G_DEPTH );
pitch = map_info( file, graph, G_PITCH );
gbuff = map_buffer( file, graph );
fileout = fpg_new();
g = map_new( w, 1, depth );
gbuffo = map_buffer( 0, g );
for( i = 0; i < h; i++ )
memmove( gbuffo, gbuff, pitch );
fpg_add( fileout, i + 1, 0, g );
gbuff += pitch;
end
map_del( 0, g );
return fileout;
end
process main()
private
nfpg;
g;
begin
g=load_png(argv[1]);
nfpg=split_map(0,g);
fpg_save(nfpg, argv[2]);
end
---------- Post añadido a las 18:30 ---------- Post anterior a las 18:28 ----------
la funcion te retorna el id del fpg, si queres que lo salve directo, modificala...
en este ejemplo, le pasas el nombre del png y el nombre del archivo.fpg, y hace el trabajo.
saludos.
---------- Post añadido a las 18:32 ---------- Post anterior a las 18:30 ----------
ahi subi una modificacion... es que la hice muy rapido y no pense en la optimizacion, ahora va mas rapido.
---------- Post añadido a las 18:33 ---------- Post anterior a las 18:32 ----------
queda fuera de esto, puntos de control...
Marcadores