Escolar Documentos
Profissional Documentos
Cultura Documentos
1
Manual de usuario: Indice
1. INTRODUCCIÓN........................................................................................................................................4
1.1. OBJETIVOS DE LA APLICACIÓN:.......................................................................................................................4
1.2. REQUERIMIENTOS HARDWARE Y SOFTWARE......................................................................................................6
1.3. INSTALACIÓN...............................................................................................................................................8
2. MENÚS..........................................................................................................................................................9
2.1. MENÚ ABRIR............................................................................................................................................11
2.1.1. Abrir...............................................................................................................................................11
2.2. GUARDAR IMAGEN......................................................................................................................................12
2.2.1. Impresión:......................................................................................................................................13
2.2.2. Salir................................................................................................................................................13
2.3. MENÚ PARÁMETROS:..................................................................................................................................14
2.3.1. Tamaño de Borrar..........................................................................................................................14
2.3.2. Tamaño das liñas sin unir..............................................................................................................15
2.3.3. Máxima Lonxitude de Unión:........................................................................................................15
2.3.4. Realizar Interpolación...................................................................................................................16
2.4. MENÚ CORES............................................................................................................................................17
2.4.1. Cores..............................................................................................................................................18
2.5. MENÚ DISTANCIA......................................................................................................................................21
2.5.1. Ver Ferramentas.............................................................................................................................21
2.6. MENÚ COMPOSICIÓN..................................................................................................................................27
2.6.1. Crear..............................................................................................................................................28
2.7. MENÚ FIESTRAS........................................................................................................................................33
2.7.1. Cascada..........................................................................................................................................33
2.7.2. Mosaico..........................................................................................................................................33
2.7.3. Organizar iconos............................................................................................................................34
2.8. MENÚ CRÉDITOS.......................................................................................................................................35
3. MENÚS EMERGENTES..........................................................................................................................36
4. PANELES ...................................................................................................................................................37
4.1. PANEL SUPERIOR.......................................................................................................................................37
4.2. PANEL EXTRAER COLOR.............................................................................................................................39
4.2.1. Botón extraer por color.................................................................................................................40
4.2.2. Botón Extracción por colores. .....................................................................................................41
4.2.3. Botón Adelgazar.............................................................................................................................43
4.3. PANEL UNIR.............................................................................................................................................44
4.3.1. Botón unir.......................................................................................................................................44
4.3.2. Botón Trazar Línea........................................................................................................................45
4.3.3. Botón quitar ruido..........................................................................................................................46
4.3.4. Botón Ver Extremos........................................................................................................................46
4.4. PANEL GRÁFICO........................................................................................................................................47
4.4.1. Botón Perfil....................................................................................................................................47
4.4.2. Botón Región..................................................................................................................................48
4.4.3. Botón de Tres dimensiones.............................................................................................................49
4.4.4. Botón estadística............................................................................................................................53
4.4.5. Botón etiquetado............................................................................................................................54
5. CÓDIGO FUENTE....................................................................................................................................57
5.1. RELIEVES.DPR...................................................................................................................................57
5.2. CUATRO.PAS..............................................................................................................................................58
5.3. FILLA2.PAS................................................................................................................................................74
5.4. COMPOSICION.PAS....................................................................................................................................105
2
Manual de usuario: Indice
5.5. DESCONTINUIDADESAUX.PAS.....................................................................................................................107
5.6. DESCONTINUIDADES.PAS............................................................................................................................110
5.7. ZHANGSUES.PAS......................................................................................................................................113
5.8. DIBUJO.PAS.............................................................................................................................................116
5.9. UNIDADFPREGUNTA.PAS............................................................................................................................117
5.10. ZOOM.PAS.............................................................................................................................................118
5.11. TIPOS.PAS..............................................................................................................................................119
6. TABLA DE ILUSTRACIONES..............................................................................................................125
3
Manual de usuario: Introducción
1.INTRODUCCIÓN
1.1.OBJETIVOS DE LA APLICACIÓN:
La introducción de la informática en el proceso de Cartografía mediante programas
expectativas ya conocidas por aquellas que trabajan con esta clase de información
elaboración de mapas y planos con los procesos de análisis, reduciendo así los costes y
Como una demostración práctica del tema de este proyecto, he desarrollado una
aplicación (denominada RELIEVES) que extrae, o lo que es lo mismo, detecta, las curvas
están representadas en el mismo con un color que las distingue de otro tipo de
información, y con las cuales (tras su etiquetado manual o automático) el programa puede
generar una imagen tridimensional el terreno realista y que puede ser manipulada y
analizada en todo su conjunto, también se podrá extraer de las imágenes otro tipo de
información como ríos, carreteras, que normalmente están representada con un color
distintivo.
4
Manual de usuario: Introducción
Este tomo del proyecto no pretende ser una explicación de los procesos que se
realizan en el programa, sino una ayuda que les sirva a los usuarios que lo utilicen a la
hora de manejarlo. Tampoco están incluidos aquí los algoritmos utilizados, para
5
Manual de usuario:
unidad de CD-ROM, siendo recomendable como mínimo un Pentium con 200 Mhz, y 32
Mg de memoria RAM.
incumplan estas características, pero cabe reseñar que en sistemas con procesadores
complejidad de los algoritmos que se emplean (para una mayor información de estos
Professional para correr bajo Windows 95. La paleta de colores de Windows debe estar en
6
Manual de usuario:
También es recomendable, para una buena ejecución del programa y para mayor
facilidad de manejo, que la barra de tareas de Windows 95 esté oculta mientras se ejecute
el programa.
7
Manual de usuario:
1.3.INSTALACIÓN
Para que la representación 3D se realice correctamente previamente a la instalación
Impression”.
documentación
Ilustración 2: Icono de
RELIEVES
8
Manual de usuario: Menús
2.MENÚS
Tras pulsar el botón “ACEPTAR” nos encontramos ante la pantalla principal del
programa:
9
Manual de usuario: Menús
Para abrir una imagen hay que pulsar el menú abrir. Una vez abierta la imagen
podremos aparecerán unos paneles en el lado derecho y superior que nos permitirán
10
Manual de usuario:
2.1.MENÚ ABRIR
Bajo este menú se encuentran todas las opciones relacionadas con el
2.1.1.ABRIR
2.1.1.ABRIR
Sólo se podrán cargar imágenes en formato Windows BMP de 256 colores o tonos
de grises, sin comprimir. Para utilizar una imagen en cualquier otro formato esta deberá
recomendable que, en la medida de lo posible, se trabaje con los menos posibles, pues
cuanto mayor sea el número de imágenes que se tengan abiertas mayor será el numero de
11
Manual de usuario:
2.2.GUARDAR IMAGEN
Se guarda la imagen activa. Para ello se abre un diálogo igual al anterior de “Abrir
Imagen”. La imagen se guarda en 256 colores. Este es un dato importante cuando tenemos
12
Manual de usuario:
2.2.1.IMPRESIÓN:
2.2.1.IMPRESIÓN:
2.2.2.SALIR
2.2.2.SALIR
13
Manual de usuario:
2.3.MENÚ PARÁMETROS:
Este menú nos permitirá variar algunos parámetros que se utilizan en el programa,
interpolación.
2.3.1.TAMAÑO
2.3.1.TAMAÑO DE BORRAR
Esta opción especifica el tamaño de la goma que se puede utilizar para borrar
Este número indica el numero de pixeles que se borran cada vez que se pulsa el
botón derecho del botón (mayor tamaño de borrar, mayor será el número de pixeles que se
borren.
14
Manual de usuario:
En la figura pueden verse (en color blanco) borrados con gomas de tamaño 3, 6 y
2.3.2.TAMAÑO
2.3.2.TAMAÑO DAS LIÑAS SIN UNIR
Cambia el valor que valor tienen los tramos de las curvas de nivel extraídas donde
se va intentar eliminar una discontinuidad (el programa intentará unir líneas de esa
pixeles), el programa unirá líneas que pueden no corresponderse con curvas de nivel
(ruido). Si es demasiado grande dejará sin unir líneas que son en realidad curvas de nivel.
Tamaño de las líneas sin unir Tamaño de las líneas sin unir
igual a 5 igual a 15
Ilustración 8: Ejemplo de tamaño de las líneas sin unir
El valor por defecto de esta variable es 15. El valor máximo que puede tomar es
1000.
2.3.3.MÁXIMA
2.3.3.MÁXIMA LONXITUDE DE UNIÓN:
15
Manual de usuario:
El valor por defecto es 15. El valor máximo que puede tomar esta variable es 1000.
Imagen Original Imagen con valor máximo Imagen con valor máximo
de unión 1 de unión 15
Ilustración 9: Ejemplo de valor máximo de unión.
2.3.4.REALIZAR
2.3.4.REALIZAR INTERPOLACIÓN
documentos abiertos a la vez, en algunos está opción puede estar activa y en otro no. Si la
aquel que se haya dado a la región donde se encuentre el punto. Si por el contrario la
forma tridimensional.
16
Manual de usuario:
2.4.MENÚ CORES
Este menú está inicialmente inactivo, para activarlo habrá que tener alguna imagen
abierta.
17
Manual de usuario:
2.4.1.CORES
2.4.1.CORES
Este es el único apartado del “menú Cores” cuando se pulsa, se muestra por
pantalla una leyenda con los colores con los que se ha etiquetado el mapa. Si aún no se ha
leyenda:
18
Manual de usuario:
En esta nueva pantalla , los números de la izquierda indican las alturas con las que
se ha etiquetado cada región y los colores de la derecha como han sido representadas estas
alturas en el mapa.
Es posible cambiar los colores de la leyenda. Basta con pulsar sobre el cuadro que
indica cada color y se abrirá un diálogo que nos permitirá elegir un nuevo color, que
reemplace al viejo.
19
Manual de usuario:
Para volver a la pantalla principal es necesario cerrar esta nueva pantalla pulsando
20
Manual de usuario:
2.5.MENÚ DISTANCIA
Ese menú solo contiene la opción de “ver Ferramentas” y es el que nos permite
2.5.1.VER
2.5.1.VER FERRAMENTAS
21
Manual de usuario:
Este botón es de confirmación, sirve para ocultar el panel una vez que hayamos
Este botón se pulsa cuando queremos establecer una referencia en el mapa que se
mapa 1:25000 como el de la imagen) es relativamente fácil porque el mapa aparece divido
22
Manual de usuario:
Una vez pulsado este botón, se hace clic con el botón izquierdo del ratón en la
ratón hasta la posición final (aparece un segmento de referencia) y se vuelve a hacer clic
con el botón izquierdo del ratón. Realizada la operación tendremos que indicar la longitud
Este botón sirve para medir distancias entre dos puntos de la imagen.
Una vez pulsado este botón, se hace clic con el botón izquierdo del ratón en la
ratón hasta la posición final (aparece un segmento de referencia sobre la distancia a medir)
de la distancia medida (primeramente tiene que haber sido establecida una referencia).
23
Manual de usuario:
El botón “Rexión” es el que se utiliza para establecer una región dentro del mapa.
Una vez pulsado se hace clic con el botón derecho del ratón en la imagen de la izquierda
(imagen original) sobre los vértices de la región que queremos situar, cerrándola
finalmente pulsando a la vez la tecla control (Ctrl) y el botón derecho del ratón.
La finalidad de este botón es dar una cota a una región que hayamos establecido
con anterioridad.
Para ello pulsamos el botón y a continuación hacemos clic con el botón izquierdo
24
Manual de usuario:
Imagen tridimensional después de haber añadido una nueva región al mapa y haberla etiquetado.
25
Manual de usuario:
Imagen tridimensional del mapa original Imagen tridimensional después de haber añadido varias
26
Manual de usuario:
2.6.MENÚ COMPOSICIÓN
En este menú sólo se encuentra la opción de crear que es la que se utiliza cuando se
quiere componer una imagen grande (que abarque mayor territorio) a partir de otras mas
pequeñas (que abarquen menos territorio). Esta opción es muy útil cuando tenemos un
mapa excesivamente grande como para ser escaneado en una sola imagen, y se hace
imprescindible dividir el mapa en secciones con el fin de tratar cada imagen por separado,
de menor tamaño. Una vez extraídas las curvas de nivel y eliminadas las discontinuidades
se graba la imagen en disco duro de cada imagen (sin realizar el etiquetado que se hará
posteriormente). Cuando tengamos todas los partes en el disco duro estas se unirán en una
27
Manual de usuario:
2.6.1.CREAR
2.6.1.CREAR
Al elegir esta opción se nos presentará una ventana donde podremos realizar todas
las maniobras que consideremos oportunas para crear la composición. Esta ventana es la
siguiente:
modificar a su antojo y que indican las coordenadas globales, que son las coordenadas de
la nueva imagen, y las coordenadas de inserción, que son las coordenadas entre las cuales
pulsar este botón con la finalidad de cargar una imagen desde archivo. A continuación se
nos muestra un dialogo para cargar la imagen, que es igual al dialogo que aparece tras
pulsar la opción “Abrir Imagen” en el menú “Abrir” La imagen cargada deberá estar en
formato Windows BMP de 256 colores o tonos de grises y aunque admite cualquier
imagen es recomendable que la elegida tenga ya extraídas las curvas de nivel y eliminadas
las discontinuidades.
imagen en el lugar indicado, pero siempre teniendo en cuenta que en las coordenadas
superior izquierda ‘X’ e ‘Y’ tienen que tomar valores mas pequeños que los de inferior
derecha.
Ejemplo:
29
Manual de usuario:
30
Manual de usuario:
Si una imagen se solapa con otra, la imagen que queda por encima es siempre la
última en insertarse.
Si hacemos clic con el botón derecho del ratón sobre la imagen obtendremos el
32
Manual de usuario:
2.7.MENÚ FIESTRAS
tiempo. A medida que se vayan abriendo ventanas éstas irán tomando una posición dada
Sin embargo, cuando se tienen abiertas múltiples ventanas, este trabajo puede ser
laborioso y por ello disponemos de este menú que puede ayudar en esta tarea. El menú
abiertos.
2.7.1.CASCADA
2.7.1.CASCADA
2.7.2.MOSAICO
2.7.2.MOSAICO
ajustan los tamaños para que todas las ventanas sean visibles simultáneamente.
33
Manual de usuario:
2.7.3.ORGANIZAR
2.7.3.ORGANIZAR ICONOS
principal, no se verán afectadas por ninguno de los dos métodos anteriores, podemos
utilizar, no obstante, la opción organizar iconos para ordenar los iconos que representan a
estas ventanas, de tal forma que se alineen todos en la parte inferior de la ventana.
Las opciones se completan con una lista de todas las ventanas existentes en ese
34
Manual de usuario:
2.8.MENÚ CRÉDITOS
Esta opción del menú principal no tiene opciones, si la pulsamos se mostrará por
35
Manual de usuario: Menús emergentes
3.MENÚS EMERGENTES
otros dos menús emergentes, uno en la imagen original (imagen de la izquierda) y otro en
la imagen de la derecha (imagen de trabajo) que se accionan al hacer clic con en botón
la imagen de trabajo);
36
Manual de usuario: Paneles
4.PANELES
Cuando la aplicación se ejecuta va apareciendo, en el margen derecho de la
ventana principal, una serie de paneles con sus correspondientes botones que nos permiten
4.1.PANEL SUPERIOR
En este panel se muestran diferentes informaciones sobre la imagen:
“Cor” muestra el color del punto de la imagen sobre el que está situado el cursor
“Altura” muestra la altura del punto de la imagen sobre el que está situado el
cursor. Si la opción “Interpolación” del menú “Parámetros” está activada la altura indicada
Botón goma:
Borra una porción de la imagen de trabajo (el número de pixeles borrados está en
“Parámetros”.
37
Manual de usuario: Paneles
Se utiliza para regresar a la imagen tal y como estaba antes del proceso de
eliminación de discontinuidades.
38
Manual de usuario:
Est panel es el que se muestra cuando cargamos desde disco duro cualquier
imagen, es el que facilita las tareas de extracción de las curvas de nivel (o cualquier otra
información que se pueda extraer por el color) a partir de un mapa en color que contenga
más información.
39
Manual de usuario:
Hay dos formas de extraer las curvas de nivel de una imagen, la primera
denominada extracción por color consiste en elegir hasta un máximo de 5 colores y luego
calibrar, mediante una barra, el margen que queremos dar para coger más o menos colores.
Cuando pulsamos esta opción nos sale un segundo panel que es el siguiente:
indican los colores de la imagen elegidos, son los cinco recuadros de selección de color.
En el centro del panel los cinco editores, uno por cada recuadro de color, que
contienen el valor del umbral asociado a cada color. Cuanto menor sea ese número, menor
Para elegir un color, hay que hacer clic con el ratón en cualquiera recuadro de
selección de color (el recuadro aparece ahora de color rojo) y luego con el botón izquierdo
del ratón se hace clic en la imagen de trabajo o bien en la imagen original. Hecho esto, se
40
Manual de usuario:
escoge un umbral para ese color, bien manualmente (tecleamos un número en el editor
asociado), bien mediante una barra que reflejará de forma automática los cambios tanto en
Este botón nos da la posibilidad de extraer las curvas de nivel de una forma
diferente que consiste en elegir los colores que pertenecen a la curva de nivel uno a uno.
El panel que se nos presenta es el siguiente (una vez se haya pulsado el botón y
cualquiera de las dos imágenes, original o de trabajo, para seleccionar algún color):
41
Manual de usuario:
imagen de trabajo. Añadimos colores a esta tabla pulsando en cualquiera de las dos
imágenes (los colores que se añaden son siempre de la imagen original, por tanto podemos
pulsar en cualquier parte de la imagen de trabajo y el color añadido será el que está en esa
misma posición pero en la imagen original, lo cual es muy útil cuando vemos
Para borrar un color de la lista basta con pulsar sobre el recuadro que lo contiene.
Para elegir un método u otro, hay que decir que el primero es más automático (con
las ventaja de que puede ser más rápido pero también más inexacto) y debe ser utilizado
42
Manual de usuario:
cuando queremos extraer curvas de nivel que estén bastante separadas las unas de las otras
y que sean gruesas (por ejemplo las equidistantes en 50 metros en los mapas 1:25000). El
segundo método puede ser más lento pero también se alcanzan mejores resultados y es
muy útil en líneas bastante que tengan un color muy parecido al del fondo (por ejemplo las
4.2.3.BOTÓN
4.2.3.BOTÓN ADELGAZAR
Este botón sirve para adelgazar las líneas extraídas mediante cualquiera de los
En el siguiente cuadro pueden verse los resultados de aplicar todos los métodos del
43
Manual de usuario:
4.3.PANEL UNIR
El panel unir contiene una serie de herramientas para eliminar las discontinuidades
Este panel aparece una vez se hayan adelgazado las curvas de nivel.
4.3.1.BOTÓN
4.3.1.BOTÓN UNIR
Cuando se una hay que tener en cuenta dos variables, el tamaño de las líneas sin
unir, y el de la máxima longitud de unión, cuyos valores iniciales son cincuenta, y que se
44
Manual de usuario:
4.3.2.BOTÓN
4.3.2.BOTÓN TRAZAR LÍNEA
Una vez pulsado este botón, se hace clic con el botón izquierdo del ratón en la
ratón hasta la posición final (aparece un segmento) y se vuelve a hacer clic con el botón
45
Manual de usuario:
4.3.3.BOTÓN
4.3.3.BOTÓN QUITAR RUIDO
El botón “quitar ruido” sirve para eliminar en la imagen de trabajo, los tramos o
segmentos que tengan una longitud igual o inferior a un umbral. Este umbral lo elige el
tecleamos el valor 0 entonces simplemente borraremos los pixeles sueltos (que no estén
4.3.4.BOTÓN
4.3.4.BOTÓN VER EXTREMOS
Este botón es simplemente de información y sirve para ver los extremos que hay en
46
Manual de usuario:
4.4.PANEL GRÁFICO
Ese panel sirve para calcular perfiles, imágenes tridimensionales, etiquetar, y
realizar estadísticas.
continuación, el botón de confirmación sólo está visible cuando se hace clic en el botón
4.4.1.BOTÓN
4.4.1.BOTÓN PERFIL
Una vez pulsado este botón, se hace clic con el botón izquierdo del ratón en la
ratón hasta la posición final (aparece un segmento) y se vuelve a hacer clic con el botón
izquierdo del ratón. Entonces se generará una pantalla con el perfil de ese segmento, como
esta:
4.4.2.BOTÓN
4.4.2.BOTÓN REGIÓN
Este botón se pulsa cuando quiere cambiarse el valor de la cota de una determinada
región ya etiquetada.
48
Manual de usuario:
4.4.3.BOTÓN
4.4.3.BOTÓN DE TRES DIMENSIONES
La “altura base” es un valor introducido por el usuario, y hace que las alturas
tridimensional la altura base es siempre etiquetada con valor 0. Esto se ve con el siguiente
ejemplo:
Imagen obtenida con “altura base” con valor 0 (las alturas van de 0 a 80)
49
Manual de usuario:
Imagen obtenida con “altura base” con valor 50 (las alturas van de 0 a
80)
Ilustración 36: Altura base.
para hacer la representación tridimensional. Cuanto mayor sea el número, mayor será el
50
Manual de usuario:
51
Manual de usuario:
52
Manual de usuario:
La imagen se puede rotar, para hacerlo basta con pulsar la tecla control (Ctrl) situar
el cursor del ratón sobre la imagen tridimensional y desplazar el cursor con el botón
izquierdo del ratón pulsado. En el siguiente ejemplo aparecen tres puntos de vista
También podemos hacer un zoom de la imagen pulsando los botones que aparecen
Sobre la imagen podemos hacer otro tipo de variaciones (leyendas, luces, colores,
ect.) para ello hay que pulsar con en botón derecho del ratón sobre la imagen y modificar
4.4.4.BOTÓN
4.4.4.BOTÓN ESTADÍSTICA
Al pulsar este botón aparece por pantalla una ventana estadística sobre las regiones
53
Manual de usuario:
gráfico.
4.4.5.BOTÓN
4.4.5.BOTÓN ETIQUETADO
Aunque se podría etiquetar todo el mapa con la ayuda del botón “región” (cuya
principal finalidad es modificar la altura de una zona) se dispone de una forma mucho mas
Si elegimos “Selecionado” entonces se nos irá preguntando el color cada vez que se
etiquete una región. Si elegimos “Gradual” se hará visible el subpanel 2. En el, elegiremos
el primer color con el que se etiquetará la primera región, haciendo clic con el botón
izquierdo del ratón sobre el recuadro etiquetado como “Inicial”. En “Separación” se teclea
elegimos “Selecionada” se nos preguntará la altura cada vez que se etiquete una región. Si
55
Manual de usuario:
vez elegidas las opciones, y antes de pulsar el botón “Aceptar” se pulsa con el botón
izquierdo del ratón sobre la imagen de trabajo que va a ser la posición inicial, se mueve el
ratón hasta la posición final (aparece un segmento) y se vuelve a hacer clic con el botón
izquierdo del ratón, las regiones se irán etiquetando de forma ascendente. Con la
etiquetar una sola región, basta con ha cer dos veces clic en dos puntos de la misma
región.
56
Manual de usuario: Código Fuente
5.CÓDIGO FUENTE
5.1. RELIEVES.DPR
program Relieves;
{ó compilar no menú de Delphi Tools-Environment Options-Preferences-Debugging
Break on Exception: Desactivar)}
uses
Forms,
cuatro {VPrincipal},
ZhangSuen in 'ZhangSuen.pas',
zoom in 'zoom.pas',
descontinuidades in 'descontinuidades.pas',
ruido in 'ruido.pas',
filla2 in 'filla2.pas' {filla},
dibujo in 'dibujo.pas',
FichaDialo in 'FichaDialo.pas' {FichaDialogo},
unidadChar in 'unidadChar.pas' {VChar},
UnidadVChar2 in 'UnidadVChar2.pas' {VChar2},
composicion in 'composicion.pas',
UnidadPInicio in 'UnidadPInicio.pas' {PantallaInicio},
UnidadCreditos in 'UnidadCreditos.pas' {VCreditos},
UnidadFPregunta in 'UnidadFPregunta.pas' {FPregunta},
UnidadTabla in 'UnidadTabla.pas' {FTabla}
;{Vcomposicion}
//graf3d in 'graf3d.pas' {ven3d},
// tresDim in 'tresDim.pas' {ventana3d};
{$R *.RES}
begin
Application.Initialize;
Application.Title := 'RELIEVES';
Application.CreateForm(TVPrincipal, VPrincipal);
Application.Run;
end.
57
Manual de usuario:
5.2. CUATRO.PAS
begin
DialogoAbrir.InitialDir:='c:\relieves';
if DialogoAbrir.Execute then
begin
try
assignFile(fichero,DialogoAbrir.FileName);
reset(fichero);
seek(fichero,28);
read(fichero,byteNumeroColores);
closeFile(fichero);
if byteNumeroColores=8 then
begin
filla1:=tfilla.create(self);
Panel1.Visible:=true;
Panel2.Visible:=true;
//Facemos visibles a opción de grabar no menu:
GardarImaxen1.Enabled:=true;
Impresion1.Enabled:=true;
Distancia1.Enabled:=true;
Colores1.Enabled:=true;
grupoLineas.visible:=false;
Unir.Visible:=true;
ruido.visible:=true;
Bruido.visible:=true;
(ActiveMDIChild as Tfilla).cargarClick(DialogoAbrir.FileName);
end
else
showmessage('A imaxen non é de 256 cores');
except
showmessage('Imposible abrir ese ficheiro');
end;
end;
end;
BNoCo.visible:=false;
restaurar.Down:=false;
Bet.down:=false;
BArea.visible:=true;
Unir.visible:=true;
Grupo1.visible:=true;
PanelEt.visible:=false;
GrupoLineas.visible:=false;
PanelUnir.visible:=false;
BRestaurar2.Visible:=false;
with (ActiveMDIChild as Tfilla)do
begin
if nomeFichero<>''then
begin
Maltura.Destroy;
Maltura:=TMaltura.Create(0);
EstadoImagen:=-1;
58
Manual de usuario:
assignFile(fichero,nomeFichero);
reset(fichero);
seek(fichero,54);
for auxFor:=0 to 255 do
for auxFor2:=1 to 4 do
write(fichero,paleta[auxFor,auxFor2]);
closeFile(fichero);
cargarClick(nomeFichero);
end;
end;
end;
59
Manual de usuario:
ScrollBox2.HorzScrollBar.Position:=0;
ScrollBox2.VertScrollBar.position:=0;
EstadoImagen:=1;
rectangulo.Left:=0;
rectangulo.Top:=0;
rectangulo.Right:=imagen1.picture.width;
rectangulo.Bottom:=Imagen1.picture.Height;
abajo:=imagen1.Left;
arriba:=imagen1.top;
ancho:=imagen1.width; //ojo
alto:=imagen1.height;
anchoB:=imagen1.picture.width;
altoB:=imagen1.picture.height;
imagen1.Picture.SaveToFile(nomeFichero+'temporal.bmp');
Imagen1.Picture.LoadFromFile(nomeFichero+'temporal.bmp');
bitmap.Canvas.CopyRect(rectangulo,imagen1.Picture.Bitmap.Canvas,rectangulo);
bitmap.Canvas.CopyRect(rectangulo,imagen1.canvas,rectangulo);
imagen1.Destroy;
imagen1:=TImage.create(ActiveMdichild as TFilla);
Imagen1.Left:=abajo;
imagen1.top:=arriba;
imagen1.width:=ancho;
imagen1.height:=alto;
imagen1.visible:=true;
imagen1.enabled:=true;
imagen1.center:=false;
imagen1.stretch:=true;
imagen1.name:='imagen1';
imagen1.parent:=Scrollbox1;
imagen1.PopupMenu:=popupMenu1;
imagen1.onMouseDown:=Imagen1MouseDown;
imagen1.onMouseMove:=Imagen1MouseMove;
imagen1.width:=AnchoB;
imagen1.height:=AltoB;
imagen1.autosize:=false;
60
Manual de usuario:
imagen1.canvas.Draw(0,0,bitmap);
bitmapRoj:=TBitmap.Create;
bitmapRoj.Width:=imagen1.Picture.Width;
bitmapRoj.Height:=Imagen1.Picture.Height;
rectangulo.Left:=0;
rectangulo.Top:=0;
rectangulo.Right:=imagen1.Picture.Width;
rectangulo.Bottom:=Imagen1.Picture.Height;
copiaMatriz(matrizBy,matrizByAux,imagen1.Picture.Width,imagen1.Picture.Height);
bitmapaux.Canvas.CopyRect(rectangulo,bitmap.canvas,rectangulo);
bitmapRoj.Canvas.CopyRect(rectangulo,bitmap.canvas,rectangulo);
copiaMatriz(matrizBy,matrizByRoj,imagen1.Picture.Width,imagen1.Picture.Height);
end;
Bestado.Panels.Clear;
screen.cursor:=CrDefault;
BRestaurar2.visible:=true;
PanelUnir.visible:=true;
Grupo1.visible:=false;
panel4.visible:=false;
end;
procedure TVPrincipal.UnirClick(Sender: TObject);
var
rectangulo:Trect;
begin
unir.visible:=false;
screen.cursor:=CrHourGlass;
Bestado.Panels.Clear;
Application.ProcessMessages;
with BEstado.Panels.add do
Text:='Eliminando Descontinuidades';
with ActiveMdichild as TFilla do
begin
EstadoImagen:=2;
rectangulo.Left:=0;
rectangulo.Top:=0;
rectangulo.Right:=bitmap.Width;
rectangulo.Bottom:=bitmap.Height;
copiaMatriz(matrizByAux,matrizByRoj,bitmap.width,bitmap.Height);
bitmapRoj.Canvas.CopyRect(rectangulo,bitmapaux.canvas,rectangulo);
eliminarDescontinuidades(matrizByAux,bitmapAux,imagen1.Picture.Width-1,imagen1.Picture.height-1,maxUnion);
imagen1.Canvas.Draw(0,0,bitmapAux);
DibujarImagen(contadorZoom,imagen1,imagen1.Picture.Width,imagen1.Picture.Height);
end;
ShowMessage('Fin del Proceso');
Bestado.Panels.Clear;
screen.cursor:=CrDefault;
end;
61
Manual de usuario:
end;
end
else
with ActiveMdichild as TFilla do
begin
BRestaurar2Click(self);
Unir.Visible:=false;
ruido.visible:=false;
Bruido.visible:=false;
rectangulo.Left:=0;
rectangulo.Top:=0;
rectangulo.Right:=bitmap.Width;
rectangulo.Bottom:=bitmap.Height;
copiaMatriz(matrizByAux,matrizByRoj,bitmap.width,bitmap.Height);
bitmapRoj.Canvas.CopyRect(rectangulo,bitmapaux.canvas,rectangulo);
bitmapaUX:=TBitmap.Create;
bitmapAUX.Width:=imagen1.Picture.Width;
bitmapAUX.Height:=Imagen1.Picture.Height;
EliminacionDeTramos(bitmapAux,matrizByAux,BProgreso,StrToInt(Ruido.Text),imagen1.Picture.Width-1,imagen1.Picture.height-1);
eliminarDescontinuidades(matrizByAux,bitmapaUX,imagen1.Picture.Width-1,imagen1.Picture.height-1,maxLinea);
EliminacionDeTramos(bitmapAux,matrizByAux,BProgreso,StrToInt(Ruido.Text),imagen1.Picture.Width-1,imagen1.Picture.height-1);
imagen1.Canvas.Draw(0,0,bitmapAux);
DibujarImagen(contadorZoom,imagen1,imagen1.Picture.Width,imagen1.Picture.Height);
end;
ShowMessage('Fin del Proceso');
VPrincipal.Cursor:=CrDefault;
Bestado.Panels.Clear;
screen.cursor:=CrDefault;
end;
62
Manual de usuario:
procedure TVPrincipal.Cascada1Click(Sender: TObject);
begin
Cascade;
end;
printer.Canvas.PenPos:=punto;
printer.Canvas.Brush.color:=RGB(250,0,0);
printer.Canvas.Brush.style:=bsSolid;
printer.Canvas.pen.color:=RGB(250,0,0);
printer.Canvas.pen.style:=psSolid ;
printer.canvas.StretchDraw(rectangulo,imagen1.picture.bitmap);
printer.EndDoc;
end// do with active
else showmessage('Non hai nada a imprimir');
end;
BBorrar.down:=false;
with(ActiveMdichild as TFilla)do
begin
primero:=true;
BoolDibuja:=false;
end;
end;
end;
63
Manual de usuario:
ruido.visible:=true;
Bruido.visible:=true;
with(ActiveMdichild as TFilla)do
begin
Maltura.Destroy;
Maltura:=TMaltura.Create(0);
rectangulo.Left:=0;
rectangulo.Top:=0;
rectangulo.Right:=bitmapRoj.Width;
rectangulo.Bottom:=bitmapRoj.Height;
bitmapAux.Canvas.CopyRect(rectangulo,bitmapRoj.canvas,rectangulo);
copiaMatriz(matrizByRoj,MatrizByAux,imagen1.picture.width,imagen1.Picture.Height);
bitmap.Canvas.CopyRect(rectangulo,bitmapRoj.canvas,rectangulo);
copiaMatriz(matrizByRoj,MatrizBy,imagen1.picture.width,imagen1.Picture.Height);
imagen1.Canvas.StretchDraw(Rectangulo,bitmap);
end;
end;
end;
64
Manual de usuario:
closeFile(fichero);
assignFile(fichero,nomeFichero);
reset(fichero);
for auxFor:=0 to 255 do
begin
if Vcolor.esta((RGB(paleta[auxFor,3],paleta[auxFor,2],paleta[auxFor,1]))) then
begin
paletaNueva[auxFor,1]:=paleta[auxFor,1];
paletaNueva[auxFor,2]:=paleta[auxFor,2];
paletaNueva[auxFor,3]:=paleta[auxFor,3];
end
else
begin
paletaNueva[auxFor,1]:=255;
paletaNueva[auxFor,2]:=255;
paletaNueva[auxFor,3]:=255;
end;
end;
seek(fichero,54);
for auxFor:=0 to 255 do
for auxFor2:=1 to 4 do
write(fichero,paletaNueva[auxFor,auxFor2]);
closeFile(fichero);
Imagen1.Picture.LoadFromFile(nomeFichero);
rectangulo.Left:=0;
rectangulo.Top:=0;
rectangulo.Right:=imagen1.Width;
rectangulo.Bottom:=imagen1.Height ;
imagen1.AutoSize:=false; //un ano
imagen1.canvas.Draw(0,0,imagen1.Picture.bitmap);
dibujarImagen(contadorZoom,imagen1,imagen1.Picture.Width,imagen1.Picture.Height);
end;
end;
end;
65
Manual de usuario:
VChar2.Show;
end;
66
Manual de usuario:
Respuesta:integer;
begin
Application.CreateForm(TFPregunta,FPregunta);
respuesta:=FPregunta.showModal;
if respuesta=-1 then respuesta:=0;
if respuesta>1000 then respuesta:=1000;
Fpregunta.Free;
if MDIChildCount>0 then
with(ActiveMdichild as TFilla)do
MaxUnion:=Respuesta;
end;
end;
67
Manual de usuario:
ColorS5:=Shape5.brush.color;
iumbral:=Barra.Position;
umbral.Text:=IntToStr(iumbral div 10);
iumbraltxt:=IntToStr(Barra.Position);
if Shape1.Pen.color=clRed then mascara1.text:=iumbraltxt
else if Shape2.Pen.color=clRed then mascara2.text:=iumbraltxt
else if Shape3.Pen.color=clRed then mascara3.text:=iumbraltxt
else if Shape4.Pen.color=clRed then mascara4.text:=iumbraltxt
else if Shape5.Pen.color=clRed then mascara5.text:=iumbraltxt;
with(ActiveMDIChild as Tfilla) do
begin
for auxFor:=0 to 255 do
if RGB(paleta[auxfor,3],paleta[auxfor,2],paleta[auxfor,1])=colorS1 then Elegido1:=auxFor
else if RGB(paleta[auxfor,3],paleta[auxfor,2],paleta[auxfor,1])=colorS2 then Elegido2:=auxFor
else if RGB(paleta[auxfor,3],paleta[auxfor,2],paleta[auxfor,1])=colorS3 then Elegido3:=auxFor
else if RGB(paleta[auxfor,3],paleta[auxfor,2],paleta[auxfor,1])=colorS4 then Elegido4:=auxFor
else if RGB(paleta[auxfor,3],paleta[auxfor,2],paleta[auxfor,1])=colorS5 then Elegido5:=auxFor;
assignFile(fichero,nomeFichero);
reset(fichero);
seek(fichero,54);
for auxFor:=0 to 255 do
for auxFor2:=1 to 4 do
write(fichero,paleta[auxFor,auxFor2]);
closeFile(fichero);
assignFile(fichero,nomeFichero);
reset(fichero);
seek(fichero,54);
for auxFor:=0 to 255 do
for auxFor2:=1 to 4 do
begin
read(fichero,paleta[auxFor,auxFor2]);
end;
for auxFor:=0 to 255 do
begin
if (
(abs(Paleta[auxFor,1]-Paleta[elegido1,1])
+abs(Paleta[auxFor,2]-Paleta[elegido1,2])
+ abs(Paleta[auxFor,3]-Paleta[elegido1,3])<strToInt(mascara1.text)
)
or
(abs(Paleta[auxFor,1]-Paleta[elegido2,1])
+abs(Paleta[auxFor,2]-Paleta[elegido2,2])
+ abs(Paleta[auxFor,3]-Paleta[elegido2,3])<strToInt(mascara2.text)
)
or
(abs(Paleta[auxFor,1]-Paleta[elegido3,1])
+abs(Paleta[auxFor,2]-Paleta[elegido3,2])
+ abs(Paleta[auxFor,3]-Paleta[elegido3,3])<strToInt(mascara3.text)
)
or
(abs(paleta[auxFor,1]-Paleta[elegido4,1])
+abs(Paleta[auxFor,2]-Paleta[elegido4,2])
+ abs(Paleta[auxFor,3]-Paleta[elegido4,3])<strToInt(mascara4.text)
)
or
(abs(Paleta[auxFor,1]-Paleta[elegido5,1])
+abs(paleta[auxFor,2]-Paleta[elegido5,2])
+ abs(paleta[auxFor,3]-Paleta[elegido5,3])<strToInt(mascara5.text)
)
)
then
begin
paletaNueva[auxFor,1]:=paleta[auxFor,1];
paletaNueva[auxFor,2]:=Paleta[auxFor,2];
paletaNueva[auxFor,3]:=Paleta[auxFor,3];
end
68
Manual de usuario:
else
begin
paletaNueva[auxFor,1]:=255;
paletaNueva[auxFor,2]:=255;
paletaNueva[auxFor,3]:=255;
end;
end;
seek(fichero,54);
for auxFor:=0 to 255 do
for auxFor2:=1 to 4 do
write(fichero,paletaNueva[auxFor,auxFor2]);
closeFile(fichero);
Imagen1.Picture.LoadFromFile(NomeFichero);
rectangulo.Left:=0;
rectangulo.Top:=0;
rectangulo.Right:=imagen1.Width;
rectangulo.Bottom:=imagen1.Height ;
imagen1.AutoSize:=false; //un ano
imagen1.canvas.Draw(0,0,imagen1.Picture.bitmap);//?
dibujarImagen(contadorZoom,imagen1,imagen1.Picture.Width,imagen1.Picture.Height);
end;
end;
Elegido1:=1;
Elegido2:=1;
Elegido3:=1;
Elegido4:=1;
Elegido5:=1;
ColorS1:=Shape1.brush.color;
ColorS2:=Shape2.brush.color;
ColorS3:=Shape3.brush.color;
ColorS4:=Shape4.brush.color;
ColorS5:=Shape5.brush.color;
iumbral:=Barra.Position;
umbral.Text:=IntToStr(iumbral div 10);
iumbraltxt:=IntToStr(Barra.Position);
with(ActiveMDIChild as Tfilla) do
begin
for auxFor:=0 to 255 do
if RGB(paleta[auxfor,3],paleta[auxfor,2],paleta[auxfor,1])=colorS1 then Elegido1:=auxFor
else if RGB(paleta[auxfor,3],paleta[auxfor,2],paleta[auxfor,1])=colorS2 then Elegido2:=auxFor
else if RGB(paleta[auxfor,3],paleta[auxfor,2],paleta[auxfor,1])=colorS3 then Elegido3:=auxFor
69
Manual de usuario:
else if RGB(paleta[auxfor,3],paleta[auxfor,2],paleta[auxfor,1])=colorS4 then Elegido4:=auxFor
else if RGB(paleta[auxfor,3],paleta[auxfor,2],paleta[auxfor,1])=colorS5 then Elegido5:=auxFor;
assignFile(fichero,nomeFichero);
reset(fichero);
seek(fichero,54);
for auxFor:=0 to 255 do
for auxFor2:=1 to 4 do
write(fichero,paleta[auxFor,auxFor2]);
closeFile(fichero);
assignFile(fichero,nomeFichero);
reset(fichero);
seek(fichero,54);
for auxFor:=0 to 255 do
for auxFor2:=1 to 4 do
read(fichero,paleta[auxFor,auxFor2]);
begin
paletaNueva[auxFor,1]:=paleta[auxFor,1];
paletaNueva[auxFor,2]:=Paleta[auxFor,2];
paletaNueva[auxFor,3]:=Paleta[auxFor,3];
end
else
begin
paletaNueva[auxFor,1]:=255;
paletaNueva[auxFor,2]:=255;
paletaNueva[auxFor,3]:=255;
end;
end;
seek(fichero,54);
for auxFor:=0 to 255 do
for auxFor2:=1 to 4 do
write(fichero,paletaNueva[auxFor,auxFor2]);
closeFile(fichero);
Imagen1.Picture.LoadFromFile(NomeFichero);
rectangulo.Left:=0;
rectangulo.Top:=0;
70
Manual de usuario:
rectangulo.Right:=imagen1.Width;
rectangulo.Bottom:=imagen1.Height ;
imagen1.AutoSize:=false; //un ano
imagen1.canvas.Draw(0,0,imagen1.Picture.bitmap);
dibujarImagen(contadorZoom,imagen1,imagen1.Picture.Width,imagen1.Picture.Height);
end;
end;
end;
end;
71
Manual de usuario:
procedure TVPrincipal.CorEt1MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if DiaCor.Execute then
corEt1.Brush.color:=DiaCor.Color;
end;
72
Manual de usuario:
Interpolacin1.checked:=false
end;
end;
end;
73
Manual de usuario:
5.3. FILLA2.PAS
procedure Tfilla.tabla;
var
iX1,iy1,auxForX,auxForY:integer;
fila,columna:integer;
altura:string;
begin
Application.CreateForm(TFTabla,FTabla);
Ftabla.show;
while (imagen1.width>30) do
procedimientoZoomMenos(contadorZoom,imagen1,imagen1.picture.width,imagen1.picture.height);;
auxforX:=0;
auxforY:=0;
fila:=0;columna:=0;
for auxforx:=0 to imagen1.Width-1 do
for auxfory:=0 to imagen1.Height-1 do
begin
if ContadorZoom>0 then
begin
iX1:=auxforX div ContadorZoom;
iY1:=auxforY div ContadorZoom;
end
else
begin
iX1:=auxforX*(abs(ContadorZoom));
iy1:=auxforY* (abs(ContadorZoom));
end;
altura:=IntToStr(Maltura.AlturaDeColor
(imagen1.Canvas.pixels[ix1,iY1]));
try
FTabla.{(Owner as TVPrincipal)}F1.entryRC[auxForX+1,auxForY+1]:=altura;
except
showmessage('Error de Gráficos, Falta Instalar First Impression...');
end;
end; //do for
contadorZoom:=contadorZoom2;
dibujarImagen(contadorZoom,imagen1,imagen1.picture.Width,imagen1.picture.height);
ScrollBox1.HorzScrollBar.position:=ScrollBox2.HorzScrollBar.position;
ScrollBox1.VertScrollBar.Position:=ScrollBox2.VertScrollBar.Position;
end;
procedure Tfilla.colorea1Region(x1,y1:integer;ColorCambiado:tcolor);
var
dx,dy,altura,auxFx,auxFy,ancho,alto:integer;
cambio:boolean;
color:tcolor;
begin
screen.cursor:=crHourGlass;
If (Owner as TVPrincipal).DiaCor.execute then
begin
color:=(Owner as TVPrincipal).Diacor.color;
Application.CreateForm(TFPregunta,FPregunta);
altura:=FPregunta.showModal;
if altura=-1 then altura:=0;
Fpregunta.Free;
ancho:=imagen1.picture.Width;
alto:=imagen1.picture.Height;
for dx:=0 to ancho do
for dy:=0 to alto do
if imagen1.picture.bitmap.canvas.pixels[dx,dy]=ColorCambiado
then matrizByAuxC[dx,dy]:=1
else matrizByAuxC[dx,dy]:=0;
MAltura.Anhadir(color,altura);
matrizByAuxC[x1,y1]:=2;
cambio:=true;
74
Manual de usuario:
while cambio do
begin
cambio:=false;
for auxFx:=1 to ancho-2 do
for auxFy:=1 to alto-2 do
if matrizByAuxC[auxFx,auxFy]=2 then
begin
if (matrizByAuxC[auxFx-1,auxFy]=1)then //18->linea de zona
begin
dx:=auxFx-1;
dy:=auxFy;
matrizByAuxC[dx,dy]:=2;
cambio:=true;
dx:=dx-1;
dy:=dy;
while (matrizByAuxC[dx,dy]=1)
and(dx>1)and(dx<ancho-2)and(dy>1)and(dy<alto-2) do
begin
matrizByAuxC[dx,dy]:=2;
dx:=dx-1;
dy:=dy;
end; //do while
end;//do if
if (matrizByAuxC[auxFx+1,auxFy]=1)then //18->linea de zona
begin
dx:=auxFx+1;
dy:=auxFy;
matrizByAuxC[dx,dy]:=2;
cambio:=true;
dx:=dx+1;
dy:=dy;
while (matrizByAuxC[dx,dy]=1)and
(dx>1)and(dx<ancho-2)and(dy>1)and(dy<alto-2) do
begin
matrizByAuxC[dx,dy]:=2;
dx:=dx+1;
dy:=dy;
end; //do while
end; //do if
75
Manual de usuario:
end; //del while
end //del if
end;//do if matriz[auxFx,auxFy]=25
end;//do while cambio
end;
screen.cursor:=crDefault;
for dx:=0 to ancho do
for dy:=0 to alto do
if matrizByAuxC[dx,dy]=2 then
begin
imagen1.picture.bitmap.canvas.pixels[dx,dy]:=Color;
bitmapAux.Canvas.pixels[dx,dy]:=Color;
end;
end;
procedure Tfilla.coloreaN(x1,y1:integer;color:tcolor;ancho,alto:integer);
var
AuxFx,auxFy,dx,dy:integer;
cambio:boolean;
altura:integer;
alturaString:string;
preparado:boolean;
begin
bitmapAUX.Canvas.Pen.Mode:=pmCopy;
Application.CreateForm(TFPregunta,FPregunta);
altura:=FPregunta.showModal;
if altura=-1 then altura:=0;
Fpregunta.Free;
Preparado:=true;
for dx:=0 to ancho do
for dy:=0 to alto do
if matrizByAux[dx,dy]=18 then matrizByAuxC[dx,dy]:=18
else matrizByAuxC[dx,dy]:=0;
preparado:=true;
if preparado then
begin
screen.cursor:=crHourGlass;
bitmapAux.canvas.pixels[x1,y1]:=Color;
matrizByAuxC[x1,y1]:=25;
MAltura.Anhadir(color,altura);
cambio:=true;
while cambio do
begin
cambio:=false;
for auxFx:=1 to ancho-2 do
for auxFy:=1 to alto-2 do
if matrizByAuxC[auxFx,auxFy]=25 then
begin
if (matrizByAuxC[auxFx-1,auxFy]=0)then //18->linea de zona
begin
dx:=auxFx-1;
dy:=auxFy;
matrizByAuxC[dx,dy]:=25;
bitmapAux.canvas.pixels[dx,dy]:=color;
cambio:=true;
dx:=dx-1;
dy:=dy;
while (matrizByAuxC[dx,dy]<>18)and(dx>1)and(dx<ancho-2)and(dy>1)
and(dy<alto-2) do
begin
bitmapAux.canvas.pixels[dx,dy]:=color;
matrizByAuxC[dx,dy]:=25;
dx:=dx-1;
dy:=dy;
end; //do while
end;//do if
76
Manual de usuario:
matrizByAuxC[dx,dy]:=25;
bitmapAux.canvas.pixels[dx,dy]:=color;
cambio:=true;
dx:=dx+1;
dy:=dy;
while (matrizByAuxC[dx,dy]<>18)and(dx>1)and(dx<ancho-2)and(dy>1)
and(dy<alto-2) do
begin
matrizByAuxC[dx,dy]:=25;
bitmapAux.canvas.pixels[dx,dy]:=color;
dx:=dx+1;
dy:=dy;
end; //do while
end; //do if
if (matrizByAuxC[auxFx,auxFy+1]=0) then //18->linea de zona
begin
dx:=auxFx;
dy:=auxFy+1;
matrizByAuxC[dx,dy]:=25;
bitmapAux.canvas.pixels[dx,dy]:=color;
cambio:=true;
dx:=dx;
dy:=dy+1;
while (matrizByAuxC[dx,dy]<>18)and(dx>1)and(dx<ancho-2)and(dy>1)
and(dy<alto-2)do
begin
matrizByAuxC[dx,dy]:=25;
bitmapAux.canvas.pixels[dx,dy]:=color;
dx:=dx;
dy:=dy+1;
end; //do while
end; //do if
if (matrizByAuxC[auxFx,auxFy-1]=0) then //18->linea de zona
begin
dx:=auxFx;
dy:=auxFy-1;
matrizByAuxC[dx,dy]:=25;
bitmapAux.canvas.pixels[dx,dy]:=color;
cambio:=true;
dx:=dx;
dy:=dy-1;
while (matrizByAuxC[dx,dy]<>18)and(dx>1)and(dx<ancho-2)and(dy>1)
and(dy<alto-2)do
begin
matrizByAuxC[dx,dy]:=25;
bitmapAux.canvas.pixels[dx,dy]:=color;
dx:=dx;
dy:=dy-1;
end; //del while
end //del if}
end;//do if matriz[auxFx,auxFy]=25}
end;//do while cambio
screen.cursor:=crDefault;
for dx:=0 to ancho do
for dy:=0 to alto do
if matrizByAuxC[dx,dy]=25 then
begin
if (matrizByAuxC[dx-1,dy]=18) then
begin
matrizByAuxC[dx-1,dy]:=10;
bitmapAux.canvas.pixels[dx-1,dy]:=color;
end;
if (matrizByAuxC[dx+1,dy]=18)then
begin
matrizByAuxC[dx+1,dy]:=10;
bitmapAux.canvas.pixels[dx+1,dy]:=color;
end;
if (matrizByAuxC[dx,dy+1]=18) then
begin
77
Manual de usuario:
matrizByAuxC[dx,dy+1]:=10;
bitmapAux.canvas.pixels[dx,dy+1]:=color;
end;
if (matrizByAuxC[dx,dy-1]=18) then
begin
matrizByAuxC[dx,dy-1]:=10;
bitmapAux.canvas.pixels[dx,dy-1]:=color;
end;
end;
end;
for dx:=0 to ancho do
for dy:=0 to alto do
if matrizByAux[dx,dy]=18 then matrizByAux[dx,dy]:=0;
end;
78
Manual de usuario:
encontradoB1,encontradoB2:boolean;
xprimeroB,yprimeroB,xsegundoB,ysegundoB:integer;
distanciaPixelsB:real;
encontradoC1,encontradoC2:boolean;
xprimeroC,yprimeroC,xsegundoC,ysegundoC:integer;
distanciaPixelsC:real;
encontradoD1,encontradoD2:boolean;
xprimeroD,yprimeroD,xsegundoD,ysegundoD:integer;
distanciaPixelsD:real;
begin
AnchoI:=imagen1.Picture.Bitmap.Width-1;
AltoI:=imagen1.Picture.Bitmap.height-1;
xi:=puntoCentral.x;
yi:=PuntoCentral.y;
encontradoA1:=false;
encontradoA2:=false;
while ((encontradoA1=false)and(xi>0)and(xi<Anchoi)
and(yi>0)and(yi<AltoI))do
begin
if bitmapaux.Canvas.Pixels[xi,yi]<>colorElegido then
begin
encontradoA1:=true;
xprimeroA:=xi;
yprimeroA:=yi;
end;
xi:=xi+1
end;
xi:=puntoCentral.x;
yi:=PuntoCentral.y;
if encontradoA1=true then
begin
while ((encontradoA2=false)and(xi>0)and(xi<Anchoi)
and(yi>0)and(yi<AltoI))do
begin
if bitmapaux.Canvas.Pixels[xi,yi]<>colorElegido then
begin
encontradoA2:=true;
xsegundoA:=xi;
ysegundoA:=yi;
distanciaPixelsA:=distancia(xprimeroA,yprimeroA,xsegundoA,ysegundoA,matrizBy);
end;
xi:=xi-1
end;
end;
if(Maltura.AlturaDeColor(bitmapaux.canvas.Pixels[xprimeroA,yprimeroA])-
Maltura.AlturaDeColor(bitmapaux.canvas.Pixels[xsegundoA,ysegundoA]))=0
then
if
(Maltura.AlturaDeColor(bitmapaux.canvas.Pixels[PuntoCentral.x,PuntoCentral.y]))>
(Maltura.AlturaDeColor(bitmapaux.canvas.Pixels[xsegundoA,ysegundoA]))
then encontradoA2:=false;
if encontradoA2=true then
begin
distanciaPixels:=distanciaPixelsA;
xprimero:=xprimeroA;
xsegundo:=xsegundoA;
yprimero:=yprimeroA;
ysegundo:=ysegundoA;
end;
/// ***************y*************
xi:=puntoCentral.x;
yi:=PuntoCentral.y;
encontradoB1:=false;
encontradoB2:=false;
while ((encontradoB1=false)and(xi>0)and(xi<Anchoi)
and(yi>0)and(yi<AltoI))do
begin
79
Manual de usuario:
if bitmapaux.Canvas.Pixels[xi,yi]<>colorElegido then
begin
encontradoB1:=true;
xprimeroB:=xi;
yprimeroB:=yi;
end;
yi:=yi+1
end;
xi:=puntoCentral.x;
yi:=PuntoCentral.y;
if encontradoB1=true then
begin
while ((encontradoB2=false)and(xi>0)and(xi<Anchoi)
and(yi>0)and(yi<AltoI))do
begin
if bitmapaux.Canvas.Pixels[xi,yi]<>colorElegido then
begin
encontradoB2:=true;
xsegundoB:=xi;
ysegundoB:=yi;
distanciaPixelsB:=distancia(xprimeroB,yprimeroB,xsegundoB,ysegundoB,matrizBy);
end;
yi:=yi-1;
end;
end;
if(Maltura.AlturaDeColor(bitmapaux.canvas.Pixels[xprimeroB,yprimeroB])-
Maltura.AlturaDeColor(bitmapaux.canvas.Pixels[xsegundoB,ysegundoB]))=0
then
if
(Maltura.AlturaDeColor(bitmapaux.canvas.Pixels[PuntoCentral.x,PuntoCentral.y]))>
(Maltura.AlturaDeColor(bitmapaux.canvas.Pixels[xsegundoB,ysegundoB]))
then encontradoB2:=false;
if (encontradoB2=true) then
begin
if((encontradoA2=false)or(distanciaPixelsB<distanciaPixels))then
begin
distanciaPixels:=distanciaPixelsB;
xprimero:=xprimeroB;
xsegundo:=xsegundoB;
yprimero:=yprimeroB;
ysegundo:=ysegundoB;
end;
end;
/// ***************xy*************
xi:=puntoCentral.x;
yi:=PuntoCentral.y;
encontradoC1:=false;
encontradoC2:=false;
while ((encontradoC1=false)and(xi>0)and(xi<Anchoi)
and(yi>0)and(yi<AltoI))do
begin
if bitmapaux.Canvas.Pixels[xi,yi]<>colorElegido then
begin
encontradoC1:=true;
xprimeroC:=xi;
yprimeroC:=yi;
end;
yi:=yi+1;
xi:=xi+1;
end;
xi:=puntoCentral.x;
yi:=PuntoCentral.y;
if encontradoC1=true then
begin
while ((encontradoC2=false)and(xi>0)and(xi<Anchoi)
and(yi>0)and(yi<AltoI))do
begin
if bitmapaux.Canvas.Pixels[xi,yi]<>colorElegido then
80
Manual de usuario:
begin
encontradoC2:=true;
xsegundoC:=xi;
ysegundoC:=yi;
distanciaPixelsC:=distancia(xprimeroC,yprimeroC,xsegundoC,ysegundoC,matrizBy);
end;
yi:=yi-1;
xi:=xi-1;
end;
end;
if(Maltura.AlturaDeColor(bitmapaux.canvas.Pixels[xprimeroC,yprimeroC])-
Maltura.AlturaDeColor(bitmapaux.canvas.Pixels[xsegundoC,ysegundoC]))=0
then
if
(Maltura.AlturaDeColor(bitmapaux.canvas.Pixels[PuntoCentral.x,PuntoCentral.y]))>
(Maltura.AlturaDeColor(bitmapaux.canvas.Pixels[xsegundoC,ysegundoC]))
then encontradoC2:=false;
if (encontradoC2=true) then
begin
if(((encontradoA2=false)and(encontradoB2=false))or(distanciaPixelsC<distanciaPixels))then
begin
distanciaPixels:=distanciaPixelsC;
xprimero:=xprimeroC;
xsegundo:=xsegundoC;
yprimero:=yprimeroC;
ysegundo:=ysegundoC;
end;
end;
/// ***************xy-1*************
xi:=puntoCentral.x;
yi:=PuntoCentral.y;
encontradoD1:=false;
encontradoD2:=false;
while ((encontradoD1=false)and(xi>0)and(xi<Anchoi)
and(yi>0)and(yi<AltoI))do
begin
if bitmapaux.Canvas.Pixels[xi,yi]<>colorElegido then
begin
encontradoD1:=true;
xprimeroD:=xi;
yprimeroD:=yi;
end;
yi:=yi-1;
xi:=xi+1;
end;
xi:=puntoCentral.x;
yi:=PuntoCentral.y;
if encontradoD1=true then
begin
while ((encontradoD2=false)and(xi>0)and(xi<Anchoi)
and(yi>0)and(yi<AltoI))do
begin
if bitmapaux.Canvas.Pixels[xi,yi]<>colorElegido then
begin
encontradoD2:=true;
xsegundoD:=xi;
ysegundoD:=yi;
distanciaPixelsD:=distancia(xprimeroD,yprimeroD,xsegundoD,ysegundoD,matrizBy);
end;
yi:=yi+1;
xi:=xi-1;
end;
end;
if(Maltura.AlturaDeColor(bitmapaux.canvas.Pixels[xprimeroD,yprimeroD])-
Maltura.AlturaDeColor(bitmapaux.canvas.Pixels[xsegundoD,ysegundoD]))=0
then
if
(Maltura.AlturaDeColor(bitmapaux.canvas.Pixels[PuntoCentral.x,PuntoCentral.y]))>
(Maltura.AlturaDeColor(bitmapaux.canvas.Pixels[xsegundoD,ysegundoD]))
then encontradoD2:=false;
81
Manual de usuario:
if (encontradoD2=true) then
begin
if(((encontradoA2=false)and(encontradoB2=false)and(encontradoC2=false))
or(distanciaPixelsD<distanciaPixels))then
begin
distanciaPixels:=distanciaPixelsD;
xprimero:=xprimeroD;
xsegundo:=xsegundoD;
yprimero:=yprimeroD;
ysegundo:=ysegundoD;
end;
end;
///**************OPERACION:***********
if ((encontradoA2=true)or(encontradoB2=true)or(encontradoC2=true)or(encontradoD2=true))then
begin
if ((Maltura.AlturaDeColor(bitmapaux.canvas.Pixels[xprimero,yprimero]))>
(Maltura.AlturaDeColor(bitmapaux.canvas.Pixels[PuntoCentral.x,PuntoCentral.y])))and
((Maltura.AlturaDeColor(bitmapaux.canvas.Pixels[xsegundo,ysegundo]))<
(Maltura.AlturaDeColor(bitmapaux.canvas.Pixels[PuntoCentral.x,PuntoCentral.y])))
then
begin
distanciaMetros:=abs(Maltura.AlturaDeColor(bitmapaux.canvas.Pixels
[xprimero,yprimero])-
Maltura.AlturaDeColor(bitmapaux.canvas.Pixels
[PuntoCentral.x,PuntoCentral.y]));
distanciaPixels:=distancia(xprimero,yprimero,xsegundo,ysegundo,matrizBy);
factorMetrosPixel:=distanciaMetros/distanciaPixels;
distanciaPixelICentro:=distancia(xsegundo,ysegundo,PuntoCentral.x,PuntoCentral.y,matrizBy);
Faltura1:=(Maltura.AlturaDeColor(bitmapaux.canvas.Pixels[PuntoCentral.x,PuntoCentral.y]))+
distanciaPixelICentro*factorMetrosPixel;
end
else
if ((Maltura.AlturaDeColor(bitmapaux.canvas.Pixels[xsegundo,ysegundo]))>
(Maltura.AlturaDeColor(bitmapaux.canvas.Pixels[PuntoCentral.x,PuntoCentral.y])))and
((Maltura.AlturaDeColor(bitmapaux.canvas.Pixels[xprimero,yprimero]))<
(Maltura.AlturaDeColor(bitmapaux.canvas.Pixels[PuntoCentral.x,PuntoCentral.y])))then
begin
distanciaMetros:=abs(Maltura.AlturaDeColor(bitmapaux.canvas.Pixels[xsegundo,ysegundo])-
Maltura.AlturaDeColor(bitmapaux.canvas.Pixels[PuntoCentral.x,PuntoCentral.y]));
distanciaPixels:=distancia(xprimero,yprimero,xsegundo,ysegundo,matrizBy);
factorMetrosPixel:=distanciaMetros/distanciaPixels;
distanciaPixelDCentro:=distancia(xprimero,yprimero,PuntoCentral.x,PuntoCentral.y,matrizBy);
Faltura1:=Maltura.AlturaDeColor(bitmapaux.canvas.Pixels[PuntoCentral.x,PuntoCentral.y])+
distanciaPixelDCentro*factorMetrosPixel;
end
else
if ((Maltura.AlturaDeColor(bitmapaux.canvas.Pixels[xprimero,yprimero]))>
(Maltura.AlturaDeColor(bitmapaux.canvas.Pixels[PuntoCentral.x,PuntoCentral.y])))and
((Maltura.AlturaDeColor(bitmapaux.canvas.Pixels[xsegundo,ysegundo]))>
(Maltura.AlturaDeColor(bitmapaux.canvas.Pixels[PuntoCentral.x,PuntoCentral.y])))then
begin
distanciaPixelDCentro:=distancia(xprimero,yprimero,PuntoCentral.x,PuntoCentral.y,matrizBy);
distanciaPixelICentro:=distancia(xsegundo,ysegundo,PuntoCentral.x,PuntoCentral.y,matrizBy);
if distanciaPixelDcentro<DistanciaPixelIcentro then
begin
distanciaMetros:=abs(Maltura.AlturaDeColor(bitmapaux.canvas.Pixels
[xprimero,yprimero])-
Maltura.AlturaDeColor(bitmapaux.canvas.Pixels
[PuntoCentral.x,PuntoCentral.y]));
distanciaPixels:=distancia(xprimero,yprimero,xsegundo,ysegundo,matrizBy);
factorMetrosPixel:=distanciaMetros/distanciaPixels;
distanciaPixelICentro:=distancia(xsegundo,ysegundo,PuntoCentral.x,PuntoCentral.y,matrizBy);
Faltura1:=(Maltura.AlturaDeColor(bitmapaux.canvas.Pixels[PuntoCentral.x,PuntoCentral.y]))+
distanciaPixelICentro*factorMetrosPixel;
82
Manual de usuario:
else
begin
distanciaMetros:=abs(Maltura.AlturaDeColor(bitmapaux.canvas.Pixels
[xsegundo,ysegundo])-
Maltura.AlturaDeColor(bitmapaux.canvas.Pixels
[PuntoCentral.x,PuntoCentral.y]));
distanciaPixels:=distancia(xprimero,yprimero,xsegundo,ysegundo,matrizBy);
factorMetrosPixel:=distanciaMetros/distanciaPixels;
distanciaPixelDCentro:=distancia(xprimero,yprimero,PuntoCentral.x,PuntoCentral.y,matrizBy);
Faltura1:=(Maltura.AlturaDeColor(bitmapaux.canvas.Pixels[PuntoCentral.x,PuntoCentral.y]))+
distanciaPixelDCentro*factorMetrosPixel;
end; //del else if distanciaS<DistanciaI
end // del > and >
else Faltura1:=Maltura.AlturaDeColor(bitmapaux.canvas.Pixels[PuntoCentral.x,PuntoCentral.y])
end
else Faltura1:=Maltura.AlturaDeColor(bitmapaux.canvas.Pixels[PuntoCentral.x,PuntoCentral.y]);
Faltura:=Faltura1;
end;
procedure Tfilla.dibujarEtiqueta(var bitmap:tbitmap;var matrizby:matrizByte;x2,y2,x1,y1:integer;colorBitmap:Tcolor;colorByte:byte);
var
AlturaInicial:string;
ROJO,verde,azul,DistanciaCR,DistanciaCV,DistanciaCA,DistanciaPrincipio,x,y:integer;
corPintar:Tcolor;
aux:real;
largo:Longint;
auxfx:integer;
//COMEZO PRINCIPAL
begin
if (Owner as TVPrincipal).RadioAltura.ItemIndex=1 then
AlturaInicial:=(Owner as TVPrincipal).Altura1.text;
if (bitmap.canvas.Pixels[y1,x1]=RGB(255,255,255))then
BEGIN
if (Owner as TVPrincipal).RadioColor.ItemIndex=1 then
begin
corPintar:=(Owner as TVPrincipal).corEt1.brush.color;
DistanciaPrincipio:=StrToInt((Owner as TVPrincipal).EDisCor.text);
DistanciaCV:=0;
DistanciaCA:=0;
DistanciaCR:=0;
largo:=ColorToRGB(corPintar);
rojo:=(largo mod 256);
verde:=(largo div 256);
verde:=verde mod 256;
azul:=(largo div (256*256));
azul:=azul mod 256;
CorPintar :=RGB(rojo,verde,azul);
end
END;
//COMEZO
if (abs(y2-y1)>abs(x2-x1)) then
begin
if y2<y1 then
begin
for y:=y1 downto y2 do
begin
aux:=x1+(x2-x1)*(y-y1)/(y2-y1);
x:=round(aux);
if (aux-x)>0.5 then inc(x);
if (bitmap.canvas.Pixels[y,x]=RGB(255,255,255))then
if (Owner as TVPrincipal).RadioColor.ItemIndex=1 then
begin
colorea(y,x,corPintar,imagen1.picture.Width,imagen1.Picture.height);
DEAux(DistanciaPrincipio,DistanciaCr,DistanciaCV,DistanciaCA,rojo,azul,verde,largo,
CorPintar);
end else
83
Manual de usuario:
if(Owner as TVPrincipal).RadioColor.ItemIndex=0 then
begin
if DialogoColor.Execute then
begin
colorea(y,x,DialogoColor.Color,imagen1.picture.Width,imagen1.Picture.height);
DEAux(DistanciaPrincipio,DistanciaCr,DistanciaCV,DistanciaCA,rojo,azul,verde,largo,
CorPintar);
end;
end
else //botón selecionado o 2
colorea(y,x,RGB(random(255),random(255),random(255)),imagen1.picture.Width,imagen1.Picture.height)
end; //do for y
end else
for y:=y1 to y2 do
begin
aux:=x1+(x2-x1)*(y-y1)/(y2-y1);
x:=round(aux);
if (aux-x)>0.5 then inc(x);
if (bitmap.canvas.Pixels[y,x]=RGB(255,255,255))then
if (Owner as TVPrincipal).RadioColor.ItemIndex=1 then
begin
colorea(y,x,corPintar,imagen1.picture.Width,imagen1.Picture.height);
DEAux(DistanciaPrincipio,DistanciaCr,DistanciaCV,DistanciaCA,rojo,azul,verde,largo,
CorPintar);
end else
if(Owner as TVPrincipal).RadioColor.ItemIndex=0 then
begin
if DialogoColor.Execute then
begin
colorea(y,x,DialogoColor.Color,imagen1.picture.Width,imagen1.Picture.height);
DEAux(DistanciaPrincipio,DistanciaCr,DistanciaCV,DistanciaCA,rojo,azul,verde,largo,
CorPintar);
end;
end
else //botón selecionado o 2
colorea(y,x,RGB(random(255),random(255),random(255)),imagen1.picture.Width,imagen1.Picture.height)
84
Manual de usuario:
end; //do for x
end else
for x:=x1 to x2 do
begin
aux:=y1+(y2-y1)*(x-x1)/(x2-x1);
y:=round(aux);
if (aux-y)>0.5 then inc(y);
if (bitmap.canvas.Pixels[y,x]=RGB(255,255,255))then
if (Owner as TVPrincipal).RadioColor.ItemIndex=1 then
begin
colorea(y,x,corPintar,imagen1.picture.Width,imagen1.Picture.height);
DEAux(DistanciaPrincipio,DistanciaCr,DistanciaCV,DistanciaCA,rojo,azul,verde,largo,
CorPintar);
end else
if(Owner as TVPrincipal).RadioColor.ItemIndex=0 then
begin
if DialogoColor.Execute then
begin
colorea(y,x,DialogoColor.Color,imagen1.picture.Width,imagen1.Picture.height);
DEAux(DistanciaPrincipio,DistanciaCr,DistanciaCV,DistanciaCA,rojo,azul,verde,largo,
CorPintar);
end;
end
else //botón selecionado o 2
colorea(y,x,RGB(random(255),random(255),random(255)),imagen1.picture.Width,imagen1.Picture.height)
end;//do for x
// end; //do else begin
//FINAL:
end;
if (Owner as TVPrincipal).RadioAltura.ItemIndex=1 then
(Owner as TVPrincipal).Altura1.text:=AlturaInicial;
end;
procedure Tfilla.tresD;
var
fila,columna,auxFs,auxforx,auxfory:integer;
altura,ancho,alto:string;
letra,retorno,retorno2,espacio:char;
recta1,recta2:trect;
ventana3d:Tventana3d;
//contador,
ix1,iy1:integer;
divisor:real;
malla,base,base0:integer;
puntoCentral:TPoint;
Faltura:real;
begin
if Maltura.NElementos=0 then Base0:=10
else Base0:=0;
if ((Owner as TVPrincipal).EditBase.text)<>'' then
begin
base:=StrToInt((Owner as TVPrincipal).EditBase.text);
end
else base:=0;
if ((Owner as TVPrincipal).EditMalla.text)<>'' then
malla:=StrToInt((Owner as TVPrincipal).EditMalla.text)
else malla:=0;
Application.CreateForm(TVentana3d,ventana3d);
85
Manual de usuario:
ventana3d.Show;
while (imagen1.width>malla) do
procedimientoZoomMenos(contadorZoom,imagen1,imagen1.picture.width,imagen1.picture.height);;
ventana3d.figura.ColumnCount:=imagen1.Width-1;
ventana3d.figura.RowCount:=imagen1.Height-1;
auxforX:=0;
auxforY:=0;
fila:=0;columna:=0;
if interpolacion then
begin
puntoCentral.x:=ix1;
puntoCentral.y:=iy1;
encontrarEtiqueta(puntoCentral,imagen1.Canvas.pixels[ix1,iY1],Faltura);
if (Faltura-base)<0
then Faltura:=0
else Faltura:=Faltura-base+base0;
ventana3d.figura.data:=floatToStr(Faltura);
end
else
begin
if (Maltura.AlturaDeColor(imagen1.Canvas.pixels[ix1,iY1])-base)<0
then altura:='0'
else altura:=IntToStr(Maltura.AlturaDeColor(imagen1.Canvas.pixels[ix1,iY1])-base+Base0);
ventana3d.figura.data:=altura;
end;
end; //do for
contadorZoom:=contadorZoom2;
dibujarImagen(contadorZoom,imagen1,imagen1.picture.Width,imagen1.picture.height);
ScrollBox1.HorzScrollBar.position:=ScrollBox2.HorzScrollBar.position;
ScrollBox1.VertScrollBar.Position:=ScrollBox2.VertScrollBar.Position;
recta1.Left:=0;
recta1.Top:=0;
recta1.Right:=imagen1.Picture.bitmap.Width;
recta1.Bottom:=Imagen1.Picture.bitmap.Height;
recta2.left:=0;
recta2.top:=0;
recta2.right:=ventana3d.imaxep.width;
recta2.bottom:=ventana3d.imaxep.height;
ventana3d.imaxep.Canvas.CopyRect(recta2,imagen1.Picture.bitmap.canvas,recta1);
end;
procedure Tfilla.mostrarFicha;
begin
ficha.Showmodal;
end;
procedure Tfilla.anhadirSerie(origen,destino:Tpoint;var matriz:matrizByte;var bitmap:tbitmap;var fraccion:real;var dis:integer);
var
x1,y1,x2,y2,x,y:integer;
distanciaPixels,distanciaMetros:real;
aux:real;
begin
if fraccion=0 then fraccion:=1;
86
Manual de usuario:
x1:=origen.y;
y1:=origen.x;
x2:=destino.y;
y2:=destino.x;
if (abs(y2-y1)>abs(x2-x1)) then
begin
if y2<y1 then
begin
for y:=y1 downto y2 do
begin
distanciaAcumulada:=distanciaAcumulada+1;
aux:=x1+(x2-x1)*(y-y1)/(y2-y1);
x:=round(aux);
if (aux-x)>0.5 then inc(x);
if ultimoColor<>(bitmap.canvas.pixels[y,x])then
begin
//distanciaPixels:=distancia(origen.x,origen.y,puntoM.x,puntoM.y,matrizBy);
//distanciaMetros:=distanciaPixels*fraccion;
ficha.Series1.AddXY(distanciaAcumulada*fraccion,Maltura.AlturaDeColor(bitmap.canvas.pixels[y,x]),'',RGB(250,0,0));
if Maltura.AlturaDeColor(penultimo)>Maltura.AlturaDeColor(antepenultimo)//ascendente
then
if Maltura.AlturaDeColor(ultimoColor)>Maltura.AlturaDeColor(bitmap.canvas.pixels[y,x])
then
ficha.Series1.AddXY(distanciaAcumulada*fraccion,Maltura.AlturaDeColor(ultimoColor),'',RGB(250,0,0))
else
ficha.Series1.AddXY(distanciaAcumulada*fraccion,Maltura.AlturaDeColor(bitmap.canvas.pixels[y,x]),'',RGB(250,0,0));
if Maltura.AlturaDeColor(penultimo)<Maltura.AlturaDeColor(antepenultimo)//descendente
then
if Maltura.AlturaDeColor(ultimoColor)>Maltura.AlturaDeColor(bitmap.canvas.pixels[y,x])
then
ficha.Series1.AddXY(distanciaAcumulada*fraccion,Maltura.AlturaDeColor(bitmap.canvas.pixels[y,x]),'',RGB(250,0,0))
else
ficha.Series1.AddXY(distanciaAcumulada*fraccion,Maltura.AlturaDeColor(ultimoColor),'',RGB(250,0,0));
ultimoColor:=(bitmap.canvas.Pixels[y,x]);
Antepenultimo:=Penultimo;
Penultimo:=ultimoColor;
end;
end;
end else
for y:=y1 to y2 do
begin
DistanciaAcumulada:=distanciaAcumulada+1;
aux:=x1+(x2-x1)*(y-y1)/(y2-y1);
x:=round(aux);
if (aux-x)>0.5 then inc(x);
if ultimoColor<>(bitmap.canvas.pixels[y,x])then
begin
ficha.Series1.AddXY(distanciaAcumulada*fraccion,Maltura.AlturaDeColor(bitmap.canvas.pixels[y,x]),'',RGB(250,0,0));
if Maltura.AlturaDeColor(penultimo)>Maltura.AlturaDeColor(antepenultimo)//ascendente
then
if Maltura.AlturaDeColor(ultimoColor)>Maltura.AlturaDeColor(bitmap.canvas.pixels[y,x])
then
ficha.Series1.AddXY(distanciaAcumulada*fraccion,Maltura.AlturaDeColor(ultimoColor),'',RGB(250,0,0))
else
87
Manual de usuario:
ficha.Series1.AddXY(distanciaAcumulada*fraccion,Maltura.AlturaDeColor(bitmap.canvas.pixels[y,x]),'',RGB(250,0,0));
if Maltura.AlturaDeColor(penultimo)<Maltura.AlturaDeColor(antepenultimo)//descendente
then
if Maltura.AlturaDeColor(ultimoColor)>Maltura.AlturaDeColor(bitmap.canvas.pixels[y,x])
then
ficha.Series1.AddXY(distanciaAcumulada*fraccion,Maltura.AlturaDeColor(bitmap.canvas.pixels[y,x]),'',RGB(250,0,0))
else
ficha.Series1.AddXY(distanciaAcumulada*fraccion,Maltura.AlturaDeColor(ultimoColor),'',RGB(250,0,0));
ultimoColor:=(bitmap.canvas.Pixels[y,x]);
Antepenultimo:=Penultimo;
Penultimo:=ultimoColor;
end;
end;
end
else
begin
if x2<x1 then
begin
for x:=x1 downto x2 do
begin
aux:=y1+(y2-y1)*(x-x1)/(x2-x1);
y:=round(aux);
if (aux-y)>0.5 then inc(y);
distanciaAcumulada:=distanciaAcumulada+1;
if ultimoColor<>(bitmap.canvas.pixels[y,x])then
begin
if Maltura.AlturaDeColor(penultimo)=Maltura.AlturaDeColor(antepenultimo)//igual (caso raro)
then
ficha.Series1.AddXY(distanciaAcumulada*fraccion,Maltura.AlturaDeColor(bitmap.canvas.pixels[y,x]),'',RGB(250,0,0));
if Maltura.AlturaDeColor(penultimo)>Maltura.AlturaDeColor(antepenultimo)//ascendente
then
if Maltura.AlturaDeColor(ultimoColor)>Maltura.AlturaDeColor(bitmap.canvas.pixels[y,x])
then
ficha.Series1.AddXY(distanciaAcumulada*fraccion,Maltura.AlturaDeColor(ultimoColor),'',RGB(250,0,0))
else
ficha.Series1.AddXY(distanciaAcumulada*fraccion,Maltura.AlturaDeColor(bitmap.canvas.pixels[y,x]),'',RGB(250,0,0));
if Maltura.AlturaDeColor(penultimo)<Maltura.AlturaDeColor(antepenultimo)//descendente
then
if Maltura.AlturaDeColor(ultimoColor)>Maltura.AlturaDeColor(bitmap.canvas.pixels[y,x])
then
ficha.Series1.AddXY(distanciaAcumulada*fraccion,Maltura.AlturaDeColor(bitmap.canvas.pixels[y,x]),'',RGB(250,0,0))
else
ficha.Series1.AddXY(distanciaAcumulada*fraccion,Maltura.AlturaDeColor(ultimoColor),'',RGB(250,0,0));
ultimoColor:=(bitmap.canvas.Pixels[y,x]);
Antepenultimo:=Penultimo;
Penultimo:=ultimoColor;
end;
end;
end else
for x:=x1 to x2 do
begin
aux:=y1+(y2-y1)*(x-x1)/(x2-x1);
y:=round(aux);
if (aux-y)>0.5 then inc(y);
distanciaAcumulada:=distanciaAcumulada+1;
if ultimoColor<>(bitmap.canvas.pixels[y,x])then
begin
88
Manual de usuario:
if Maltura.AlturaDeColor(penultimo)=Maltura.AlturaDeColor(antepenultimo)//igual (caso raro)
then
ficha.Series1.AddXY(distanciaAcumulada*fraccion,Maltura.AlturaDeColor(bitmap.canvas.pixels[y,x]),'',RGB(250,0,0));
if Maltura.AlturaDeColor(penultimo)>Maltura.AlturaDeColor(antepenultimo)//ascendente
then
if Maltura.AlturaDeColor(ultimoColor)>Maltura.AlturaDeColor(bitmap.canvas.pixels[y,x])
then
ficha.Series1.AddXY(distanciaAcumulada*fraccion,Maltura.AlturaDeColor(ultimoColor),'',RGB(250,0,0))
else
ficha.Series1.AddXY(distanciaAcumulada*fraccion,Maltura.AlturaDeColor(bitmap.canvas.pixels[y,x]),'',RGB(250,0,0));
if Maltura.AlturaDeColor(penultimo)<Maltura.AlturaDeColor(antepenultimo)//descendente
then
if Maltura.AlturaDeColor(ultimoColor)>Maltura.AlturaDeColor(bitmap.canvas.pixels[y,x])
then
ficha.Series1.AddXY(distanciaAcumulada*fraccion,Maltura.AlturaDeColor(bitmap.canvas.pixels[y,x]),'',RGB(250,0,0))
else
ficha.Series1.AddXY(distanciaAcumulada*fraccion,Maltura.AlturaDeColor(ultimoColor),'',RGB(250,0,0));
ultimoColor:=(bitmap.canvas.Pixels[y,x]);
Antepenultimo:=Penultimo;
Penultimo:=ultimoColor;
end;
end;
end;
end;
procedure Tfilla.colorea(x1,y1:integer;color:Tcolor;ancho,alto:integer);
var
AuxFx,auxFy,dx,dy:integer;
cambio:boolean;
altura:integer;
alturaString:string;
preparado:boolean;
begin
bitmapAUX.Canvas.Pen.Mode:=pmCopy;
alturaString:='0';
if (Owner as TVPrincipal).RadioAltura.ItemIndex=0 then
begin
Application.CreateForm(TFPregunta,FPregunta);
altura:=FPregunta.showModal;
if altura=-1 then altura:=0;
Fpregunta.Free;
end
else
begin
altura:=StrToInt((Owner as TVPrincipal).altura1.Text);
(Owner as TVPrincipal).altura1.Text:=IntToSTR(altura+STrToInt((Owner as TVPrincipal).EDistancia.text));
end;
preparado:=true;
if preparado then
begin
screen.cursor:=crHourGlass;
MAltura.Anhadir(color,altura);
bitmapAux.canvas.pixels[x1,y1]:=Color;
matrizByAux[x1,y1]:=25;
cambio:=true;
while cambio do
begin
cambio:=false;
for auxFx:=1 to ancho-2 do
for auxFy:=1 to alto-2 do
if matrizByAux[auxFx,auxFy]=25 then
89
Manual de usuario:
begin
if matrizByAux[auxFx-1,auxFy]=0 then
begin
dx:=auxFx-1;
dy:=auxFy;
matrizByAux[dx,dy]:=25;
bitmapAux.canvas.pixels[dx,dy]:=color;
cambio:=true;
dx:=dx-1;
dy:=dy;
while (matrizByAux[dx,dy]=0)and(dx>1)and(dx<ancho-2)and(dy>1)
and(dy<alto-2) do
begin
bitmapAux.canvas.pixels[dx,dy]:=color;
matrizByAux[dx,dy]:=25;
dx:=dx-1;
dy:=dy;
if matrizByAux[auxFx+1,auxFy]=0 then
begin
dx:=auxFx+1;
dy:=auxFy;
matrizByAux[dx,dy]:=25;
bitmapAux.canvas.pixels[dx,dy]:=color;
cambio:=true;
dx:=dx+1;
dy:=dy;
while (matrizByAux[dx,dy]=0)and(dx>1)and(dx<ancho-2)and(dy>1)and
(dy<alto-2) do
begin
matrizByAux[dx,dy]:=25;
bitmapAux.canvas.pixels[dx,dy]:=color;
dx:=dx+1;
dy:=dy;
end; //do while
end; //do if
if matrizByAux[auxFx,auxFy+1]=0 then
begin
dx:=auxFx;
dy:=auxFy+1;
matrizByAux[dx,dy]:=25;
bitmapAux.canvas.pixels[dx,dy]:=color;
cambio:=true;
dx:=dx;
dy:=dy+1;
while (matrizByAux[dx,dy]=0)and(dx>1)and(dx<ancho-2)and(dy>1)and(dy<ancho-2)do
begin
matrizByAux[dx,dy]:=25;
bitmapAux.canvas.pixels[dx,dy]:=color;
dx:=dx;
dy:=dy+1;
end; //do while
end; //do if
if matrizByAux[auxFx,auxFy-1]=0 then
begin
dx:=auxFx;
dy:=auxFy-1;
matrizByAux[dx,dy]:=25;
bitmapAux.canvas.pixels[dx,dy]:=color;
cambio:=true;
dx:=dx;
dy:=dy-1;
while (matrizByAux[dx,dy]=0)and(dx>1)and(dx<ancho-2)and(dy>1)and
(dy<alto-2)do
90
Manual de usuario:
begin
matrizByAux[dx,dy]:=25;
bitmapAux.canvas.pixels[dx,dy]:=color;
dx:=dx;
dy:=dy-1;
end; //del while
end //del if
end;//do if matriz[auxFx,auxFy]=25
end;//do while cambio
screen.cursor:=crDefault;
if (matrizByAux[dx,dy+1]=150)or(matrizByAux[dx,dy+1]=1) then
begin
matrizByAux[dx,dy+1]:=10;
bitmapAux.canvas.pixels[dx,dy+1]:=color;
end;
if (matrizByAux[dx,dy-1]=150)or(matrizByAux[dx,dy-1]=1) then
begin
matrizByAux[dx,dy-1]:=10;
bitmapAux.canvas.pixels[dx,dy-1]:=color;
end;
end;
end;
end;//do procedure
function Tfilla.contarPixels(x1,y1:integer;color:Tcolor;ancho,alto:integer):integer;
var
AuxFx,auxFy,dx,dy:integer;
cambio:boolean;
altura:integer;
alturaString:string;
contaPixels:integer;
begin
contaPixels:=0;
bitmapAUX.Canvas.Pen.Mode:=pmCopy;
for AuxFx:=1 to ancho-1 do
for AuxFy:=1 to alto-1 do
matrizByAuxR[AuxFx,auxFy]:=matrizByAux[AuxFx,AuxFy];
screen.cursor:=crHourGlass;
matrizByAux[x1,y1]:=25;
cambio:=true;
while cambio do
begin
cambio:=false;
for auxFx:=1 to ancho-2 do
for auxFy:=1 to alto-2 do
if matrizByAux[auxFx,auxFy]=25 then
begin
if matrizByAux[auxFx-1,auxFy]=0 then
begin
dx:=auxFx-1;
dy:=auxFy;
matrizByAux[dx,dy]:=25;
91
Manual de usuario:
inc(ContaPixels);
cambio:=true;
dx:=dx-1;
dy:=dy;
while (matrizByAux[dx,dy]<>18)and(dx>1)and(dx<ancho-2)and(dy>1)and(dy<ancho-2) do
begin
inc(ContaPixels);
matrizByAux[dx,dy]:=25;
dx:=dx-1;
dy:=dy;
end; //do while
end;//do if
if matrizByAux[auxFx+1,auxFy]=0 then
begin
dx:=auxFx+1;
dy:=auxFy;
matrizByAux[dx,dy]:=25;
inc(ContaPixels);
cambio:=true;
dx:=dx+1;
dy:=dy;
while (matrizByAux[dx,dy]<>18)and(dx>1)and(dx<ancho-2)and(dy>1)and(dy<ancho-2) do
begin
matrizByAux[dx,dy]:=25;
inc(ContaPixels);
dx:=dx+1;
dy:=dy;
end; //do while
end; //do if
if matrizByAux[auxFx,auxFy+1]=0 then
begin
dx:=auxFx;
dy:=auxFy+1;
matrizByAux[dx,dy]:=25;
inc(ContaPixels);
cambio:=true;
dx:=dx;
dy:=dy+1;
while (matrizByAux[dx,dy]<>18)and(dx>1)and(dx<ancho-2)and(dy>1)and(dy<ancho-2)do
begin
matrizByAux[dx,dy]:=25;
inc(ContaPixels);
dx:=dx;
dy:=dy+1;
end; //do while
end; //do if
if matrizByAux[auxFx,auxFy-1]=0 then
begin
dx:=auxFx;
dy:=auxFy-1;
matrizByAux[dx,dy]:=25;
inc(ContaPixels);
cambio:=true;
dx:=dx;
dy:=dy-1;
while (matrizByAux[dx,dy]<>18)and(dx>1)and(dx<ancho-2)and(dy>1)and(dy<ancho-2)do
begin
matrizByAux[dx,dy]:=25;
inc(ContaPixels);
dx:=dx;
dy:=dy-1;
end; //del while
end //del if
end;//do if matriz[auxFx,auxFy]=25
end;//do while cambio
screen.cursor:=crDefault;
for dx:=1 to ancho-2 do
for dy:=1 to alto-2 do
if matrizByAux[dx,dy]=25 then
92
Manual de usuario:
begin
if (matrizByAux[dx-1,dy]=150)or(matrizByAux[dx-1,dy]=1) then
begin
matrizByAux[dx-1,dy]:=10;
inc(ContaPixels);
end;
if (matrizByAux[dx+1,dy]=150)or(matrizByAux[dx+1,dy]=1) then
begin
matrizByAux[dx+1,dy]:=10;
inc(ContaPixels);
end;
if (matrizByAux[dx,dy+1]=150)or(matrizByAux[dx,dy+1]=1) then
begin
matrizByAux[dx,dy+1]:=10;
inc(ContaPixels);
end;
if (matrizByAux[dx,dy-1]=150)or(matrizByAux[dx,dy-1]=1) then
begin
matrizByAux[dx,dy-1]:=10;
inc(ContaPixels);
end;
end;
contarPixels:=contaPixels;
for AuxFx:=1 to ancho-1 do
for AuxFy:=1 to alto-1 do
matrizByAux[AuxFx,auxFy]:=matrizByAuxR[AuxFx,AuxFy];
end;//do procedure
with bitmapAux.Canvas do
begin
pen.Color:=RGB(255,3,3);
Pen.Mode :=pmNotXor ;
Ellipse(punto.x-2,punto.y-2,punto.x+3,punto.y+3);
end;
imagen1.canvas.StretchDraw(rectangulo,bitmapAux);
end;
93
Manual de usuario:
procedure Tfilla.dibuja(TopLeft,BottomRight:Tpoint;Amode:TPenMode;ancho:integer);
var rectangulo:trect;
begin
rectangulo.Left:=0;
rectangulo.Top:=0;
rectangulo.Right:=bitmapAux.Width;
rectangulo.Bottom:=bitmapAux.Height ;
imagen1.AutoSize:=false; //un ano
with imagen1.Canvas do
begin
pen.Color:=clGreen;
Pen.Mode := AMode;
pen.Width:=ancho;
MoveTo(TopLeft.X, TopLeft.Y);
LineTo(BottomRight.X, BottomRight.Y);
end;
imagen1.Canvas.pen.mode:=pmCopy;
end;
procedure Tfilla.dibuja2(TopLeft,BottomRight:Tpoint;Amode:TPenMode;ancho:integer);
var rectangulo:trect;
begin
rectangulo.Left:=0;
rectangulo.Top:=0;
rectangulo.Right:=bitmapAux.Width;
rectangulo.Bottom:=bitmapAux.Height ;
imagen2.AutoSize:=false; //un ano
with imagen2.Canvas do
begin
pen.Color:=clGreen;
Pen.Mode := AMode;
pen.Width:=ancho;
MoveTo(TopLeft.X, TopLeft.Y);
LineTo(BottomRight.X, BottomRight.Y);
end;
imagen2.Canvas.pen.mode:=pmCopy;
end;
begin
if ContadorZoom>0 then
begin
(Owner as TVPrincipal).EditX.text:=IntToStr(X div ContadorZoom);
(Owner as TVPrincipal).EditY.text:=IntToStr(Y div ContadorZoom);
end
else
begin
(Owner as TVPrincipal).EditX.text:=IntToStr(X* (abs(ContadorZoom)));
(Owner as TVPrincipal).EditY.text:=IntToStr(Y* (abs(ContadorZoom)));
end;
x1:=StrToInt((Owner as TVPrincipal).EditX.text);
y1:=StrToInt((Owner as TVPrincipal).EditY.text);
(Owner as TVPrincipal).CuadradoColor.Brush.Color:=Imagen1.Canvas.Pixels[x1,y1];
if MAltura.NElementos=0 then (Owner as TVPrincipal).EditA.text:=''
else
begin
if interpolacion then
begin
EncontrarEtiqueta(point(x1,y1),(Owner as TVPrincipal).CuadradoColor.Brush.Color,Faltura);
94
Manual de usuario:
(Owner as TVPrincipal).EditA.text:=FloatToStr(FAltura)
end
else
(Owner as
TVPrincipal).EditA.text:=(IntToStr(Maltura.AlturaDeColor(bitmapaux.canvas.Pixels[x1,y1])));
end;
if ((BoolDibuja)and(((Owner as TVPrincipal).BLinea.down=true) or((Owner as TVPrincipal).Bet.down=true))) then
begin
Dibuja(Origen,puntoM,pmNotXor,1);
PuntoM:=Point(x1,y1);;
dibuja(origen,puntoM,pmNotXor,1);
end;
if ((Owner as TVPrincipal).BRuta.down=true)and(primero=false) then
begin
Dibuja(Origen,puntoM,pmNotXor,2);
PuntoM:=Point(x1,y1);;
dibuja(origen,puntoM,pmNotXor,2);
end;
95
Manual de usuario:
end;
if (Shift=[ssLeft]) then
begin
if (Owner as TVPrincipal).shape1.Pen.color=clRed then
begin
(Owner as TVPrincipal).shape1.brush.color:=colorElegido;
end else
if (Owner as TVPrincipal).shape2.Pen.color=clRed then
begin
(Owner as TVPrincipal).shape2.brush.color:=colorElegido;
end else
if (Owner as TVPrincipal).shape3.Pen.color=clRed then
begin
(Owner as TVPrincipal).shape3.brush.color:=colorElegido;
end else
if (Owner as TVPrincipal).shape4.Pen.color=clRed then
begin
(Owner as TVPrincipal).shape4.brush.color:=colorElegido;
end else
if (Owner as TVPrincipal).shape5.Pen.color=clRed then
begin
(Owner as TVPrincipal).shape5.brush.color:=colorElegido;
end;
end;
if((Owner as TVPrincipal).bEt.Down=true)and(primero=true)and(Shift=[ssLeft])then
begin
BoolDibuja:=true;
imagen1.canvas.moveTo(x1,y1);
Origen:=Point (x1,y1);
puntoM:=Origen;
primero:=false;
end
else
if((Owner as TVPrincipal).bLinea.Down=true)and(primero=true)and(Shift=[ssLeft])then
begin
BoolDibuja:=true;
imagen1.canvas.moveTo(x1,y1);
Origen:=Point (x1,y1);
puntoM:=Origen;
primero:=false;
end
else
96
Manual de usuario:
begin
if (x1+dx>=0)and(x1+dx<=imagen1.picture.Width-1)and(y1+dy>=0)and(y1+dy<=imagen1.picture.Height-1)then
begin
imagen1.AutoSize:=false; //un ano
imagen1.Canvas.pixels[x1+dx,y1+dy]:=RGB(255,255,255);
matrizByAux[x1+dx,y1+dy]:=0;
matrizBy[x1+dx,y1+dy]:=0;
bitmapAux.canvas.pixels[x1+dx,y1+dy]:=RGB(255,255,255);
end;
end;
end;
97
Manual de usuario:
if (Owner as TVPrincipal).MDIChildCount=1 then
begin
(Owner as TVPrincipal).impresion1.Enabled:=false;
(Owner as TVPrincipal).gardarImaxen1.Enabled:=false;
(Owner as TVPrincipal).distancia1.Enabled:=false;
(Owner as TVPrincipal).colores1.Enabled:=false;
(Owner as TVPrincipal).Panel1.Visible:=false;
(Owner as TVPrincipal).Panel2.Visible:=false;
(Owner as TVPrincipal).GDistancia.visible:=false;
(Owner as TVPrincipal).panel4.visible:=false;
(Owner as TVPrincipal).panel5.visible:=false;
(Owner as TVPrincipal).Blinea.down:=false;
if (DeleteFile(nomeFichero+'temporal.bmp'))then
begin
end
else
end;
end;
if (EstadoImagen=-1) then
begin
(Owner As TVPrincipal).PanelCores.visible:=false;
(Owner As TVPrincipal).PanelUnir.visible:=false;
(Owner As TVPrincipal).GrupoLineas.visible:=false;
(Owner As TVPrincipal).PanelET.visible:=false;
(Owner As TVPrincipal).grupo1.visible:=true;
(Owner As TVPrincipal).unir.visible:=true
end;
if (EstadoImagen=0) then
begin
(Owner As TVPrincipal).PanelCores.visible:=true;
(Owner As TVPrincipal).PanelUnir.visible:=false;
(Owner As TVPrincipal).GrupoLineas.visible:=false;
(Owner As TVPrincipal).PanelET.visible:=false;
(Owner As TVPrincipal).grupo1.visible:=false;
(Owner As TVPrincipal).unir.visible:=true
end;
if (EstadoImagen=1) then
begin
(Owner As TVPrincipal).PanelCores.visible:=false;
(Owner As TVPrincipal).PanelUnir.visible:=true;
(Owner As TVPrincipal).GrupoLineas.visible:=false;
(Owner As TVPrincipal).PanelET.visible:=false;
(Owner As TVPrincipal).grupo1.visible:=false;
(Owner As TVPrincipal).unir.visible:=true
end;
if (EstadoImagen=2) then
begin
(Owner As TVPrincipal).PanelCores.visible:=false;
(Owner As TVPrincipal).PanelUnir.visible:=true;
(Owner As TVPrincipal).GrupoLineas.visible:=false;
(Owner As TVPrincipal).PanelET.visible:=false;
(Owner As TVPrincipal).grupo1.visible:=false;
(Owner As TVPrincipal).unir.visible:=false;
end;
if (EstadoImagen=3) then
begin
98
Manual de usuario:
(Owner As TVPrincipal).PanelCores.visible:=false;
(Owner As TVPrincipal).PanelUnir.visible:=false;
(Owner As TVPrincipal).GrupoLineas.visible:=true;
(Owner As TVPrincipal).PanelET.visible:=false;
(Owner As TVPrincipal).grupo1.visible:=false;
(Owner As TVPrincipal).unir.visible:=false;
end;
if (EstadoImagen=4) then
begin
(Owner As TVPrincipal).PanelCores.visible:=false;
(Owner As TVPrincipal).PanelUnir.visible:=false;
(Owner As TVPrincipal).GrupoLineas.visible:=false;
(Owner As TVPrincipal).PanelET.visible:=true;
(Owner As TVPrincipal).grupo1.visible:=false;
(Owner As TVPrincipal).unir.visible:=false;
end;
end;
procedure Tfilla.cargarClick(nome:string);
var
fichero:file of byte;
auxFor,auxFor2:integer;
rectangulo:Trect;
numeroColores:byte;
begin
nomeFichero:=nome;
(Owner As TVPrincipal).Ventanita.Picture.LoadFromFile(nomeFichero); ;
(Owner As TVPrincipal).Grupo1.visible:=true;
(Owner As TVPrincipal).GrupoLineas.visible:=false;
(Owner As TVPrincipal).PanelCores.visible:=false;
EstadoImagen:=-1;
contadorZoom:=1;
contadorZoom2:=1;
caption:=nomeFichero;
Imagen1.Picture.LoadFromFile(nomeFichero);
Imagen1.Width:=Imagen1.Picture.Width;
Imagen1.Height:=Imagen1.Picture.Height;
Imagen2.Picture.LoadFromFile(nomeFichero);
Imagen2.Width:=Imagen2.Picture.Width;
Imagen2.Height:=Imagen2.Picture.Height;
assignFile(fichero,nomeFichero);
reset(fichero);
seek(fichero,54);
for auxFor:=0 to 255 do
for auxFor2:=1 to 4 do
read(fichero,paleta[auxFor,auxFor2]);
closeFile(fichero);
bitmap:=TBitmap.Create;
bitmap.Width:=imagen1.Picture.Width;
bitmap.Height:=Imagen1.Picture.Height;
bitmapAux:=TBitmap.Create;
bitmapaux.Width:=imagen1.Picture.Width;
bitmapaux.Height:=Imagen1.Picture.Height;
rectangulo.Left:=0;
rectangulo.Top:=0;
rectangulo.Right:=imagen1.Picture.Width;
rectangulo.Bottom:=Imagen1.Picture.Height;
bitmapAux.Canvas.CopyRect(rectangulo,imagen1.canvas,rectangulo);
matrizCero(matrizByAux,imagen1.Picture.Width,imagen1.Picture.Height);
imagen1.picture.bitmap.PixelFormat:=pf24bit;
imagen2.picture.bitmap.PixelFormat:=pf24bit;
bitmapN:=TBitmap.Create;
bitmapN.Width:=imagen1.Picture.Width;
bitmapN.Height:=Imagen1.Picture.Height;
bitmapN.Canvas.CopyRect(rectangulo,imagen2.canvas,rectangulo);
end;
procedure
Tfilla.grabarClick(Sender: TObject);
99
Manual de usuario:
var
nomeFicheiroGrabar:string;
fichero,ficheroOriginal:file of byte;
elemento,blanco,negro:byte;
auxForx,auxForY:integer;
begin
if FillaDialogoGrabar.Execute then
begin
screen.cursor:=CrHourGlass;
nomeFicheiroGrabar:=FillaDialogoGrabar.FileName;
Imagen1.Picture.Bitmap.PixelFormat:=pf8bit; //256 cores
Imagen1.Picture.SaveToFile(nomeFicheiroGrabar);
end;
screen.cursor:=CrDefault;
end;
x1:=StrToInt((Owner as TVPrincipal).EditX.text);
y1:=StrToInt((Owner as TVPrincipal).EditY.text);
100
Manual de usuario:
begin
if interpolacion then
begin
EncontrarEtiqueta(point(x1,y1),(Owner as TVPrincipal).CuadradoColor.Brush.Color,Faltura);
(Owner as TVPrincipal).EditA.text:=FloatToStr(FAltura)
end
else
(Owner as
TVPrincipal).EditA.text:=(IntToStr(Maltura.AlturaDeColor(bitmapaux.canvas.Pixels[x1,y1])));
end;
(Owner as TVPrincipal).CuadradoColor.Brush.Color:=Imagen2.Canvas.Pixels[x1,y1];
if ((Owner as TVPrincipal).BRegion.down=true)and(primero2=false) then
begin
Dibuja2(Origen,puntoM,pmNotXor,1);
PuntoM:=Point(x1,y1);;
dibuja2(origen,puntoM,pmNotXor,1);
end;
if ((Owner as TVPrincipal).BRuta.down=true)and(primero2=false) then
begin
Dibuja2(Origen,puntoM,pmNotXor,2);
PuntoM:=Point(x1,y1);;
dibuja2(origen,puntoM,pmNotXor,2);
end;
end;
end;
end;
// IM2 Down
procedure Tfilla.Imagen2MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
distanciaMetros,DistanciaPixels:real;
ColorElegido:Tcolor;
begin
x1:=StrToInt((Owner as TVPrincipal).EditX.text);
y1:=StrToInt((Owner as TVPrincipal).EditY.text);
colorElegido:=(Owner as TVPrincipal).cuadradoColor.Brush.color;
if (Shift=[ssLeft]) then
begin
101
Manual de usuario:
if (Owner as TVPrincipal).shape1.Pen.color=clRed then
begin
(Owner as TVPrincipal).shape1.brush.color:=colorElegido;
end else
if (Owner as TVPrincipal).shape2.Pen.color=clRed then
begin
(Owner as TVPrincipal).shape2.brush.color:=colorElegido;
end else
if (Owner as TVPrincipal).shape3.Pen.color=clRed then
begin
(Owner as TVPrincipal).shape3.brush.color:=colorElegido;
end else
if (Owner as TVPrincipal).shape4.Pen.color=clRed then
begin
(Owner as TVPrincipal).shape4.brush.color:=colorElegido;
end else
if (Owner as TVPrincipal).shape5.Pen.color=clRed then
begin
(Owner as TVPrincipal).shape5.brush.color:=colorElegido;
end;
end;
// NOVA COTA 2
// SEGUNDO MÉTODO 2
if ((Owner as TVPrincipal).Bpixels.down=true)and(Shift=[ssLeft])and(primero=true) then
begin
VColor:=TVColor.Create(0);
Vcolor.anhadir(Imagen2.Canvas.Pixels[x1,y1]);
Vcolor.muestra((owner as TVprincipal).panel5);
primero:=false;
end
else
if ((Owner as TVPrincipal).Bpixels.down=true)and(Shift=[ssLeft])
and(primero=false) then
begin
Vcolor.anhadir(Imagen2.Canvas.Pixels[x1,y1]);
Vcolor.muestra((owner as TVprincipal).Panel5);;
end;
//MEDIR 2
if ((Owner as TVPrincipal).BMedir.down=true)and(Shift=[ssLeft])
and(primero2=true) then
begin
Origen:=Point(x1,y1);
puntoM:=Origen;
primero2:=false;
end else
if ((Owner as TVPrincipal).BMedir.down=true)and(Shift=[ssLeft])
and(primero2=false) then
begin
imagen2.Canvas.Draw(0,0,bitmapN);
DibujarImagen(contadorZoom2,imagen2,imagen1.Picture.Width,imagen1.Picture.Height);
puntoM:=point(x1,y1);
distanciaPixels:=distancia(origen.x,origen.y,puntoM.x,puntoM.y,matrizBy);
distanciaMetros:=distanciaPixels*fraccion;
(Owner as TVPrincipal).LDistancia.caption:=(IntToStr(Round(distanciaMetros))+' m.');
primero2:=true;
end;
102
Manual de usuario:
// RUTA 2
if ((Owner as TVPrincipal).BRuta.down=true)and(Shift=[ssLeft])
and(primero2=true) then
begin
Origen:=Point(x1,y1);
puntoM:=Origen;
primero2:=false;
distanciaAcumulada:=0;
ULTIMOcOLOR:=bitmapAux.Canvas.Pixels[x1,y1];
Penultimo:=ultimoColor;
Antepenultimo:=UltimoColor;
Application.CreateForm(TVChar,Ficha);
Ficha.Series1.AddXY(0,Maltura.AlturaDeColor(bitmapaux.canvas.pixels[x1,y1])
,'',bitmapaux.canvas.Pixels[x1,y1]);
end
else
if ((Owner as TVPrincipal).BRuta.down=true)and(Shift=[ssLeft])
and(primero2=false) then
begin
dibuja2(origen,Point(x1,y1),pmNotXor,2);
puntoM:=point(x1,y1);
anhadirSerie(oRIGEN,pUNTOm,matrizByAux,bitmapAux,fraccion,distanciaAcumulada);
ultimoColor:=(bitmapaux.canvas.pixels[X1,Y1]); //?
dibuja2(origen,Point(x1,y1),pmNotXor,2);
origen:=puntoM;
primero2:=true;
Ficha.Series1.AddXY(distanciaAcumulada*fraccion,Maltura.AlturaDeColor(bitmapaux.canvas.pixels[x1,y1])
,'',bitmapaux.canvas.Pixels[x1,y1]);
mostrarFicha;
imagen2.Canvas.Draw(0,0,bitmapN);
DibujarImagen(contadorZoom2,imagen2,imagen1.Picture.Width,imagen1.Picture.Height);
end
else if ((Owner as TVPrincipal).BRuta.down=true)and(Shift=[ssLeft,SSCtrl])
and(primero2=false) then
begin
end;
//REGION 2
if ((Owner as TVPrincipal).BRegion.down=true)and(Shift=[ssLeft])
and(primero2=true) then
begin
Origen:=Point(x1,y1);
OrigenRegion:=Origen;
puntoM:=Origen;
primero2:=false;
end
else
if ((Owner as TVPrincipal).BRegion.down=true)and(Shift=[ssLeft])
and(primero2=false) then
begin
puntoM:=point(x1,y1);
DibujarLinea(bitmap,matrizByAux,y1,x1,origen.y,origen.x,clGreen,18);
Dibuja2(Origen,puntoM,pmcOPY,1);
origen:=puntoM;
end
else if ((Owner as TVPrincipal).BRegion.down=true)and
(Shift=[ssLeft,SSCtrl])and(primero2=false) then
begin
DibujarLinea(bitmap,matrizByAux,y1,x1,origen.y,origen.x,clGreen,18);
DibujarLinea(bitmap,matrizByAux,y1,x1,origenRegion.y,origenRegion.x,ClGreen,18);
Dibuja2(Origen,puntoM,pmcOPY,1);
puntoM:=point(x1,y1);
Dibuja2(OrigenRegion,puntoM,pmcOPY,1);
103
Manual de usuario:
primero2:=true;
end;
// AREA 2
if ((Owner as TVPrincipal).BArea.down=true)and(Shift=[ssLeft])
and(primero2=true) then
begin
(Owner as TVPrincipal).BArea.down:=false;
(Owner as TVPrincipal).LArea.caption:=(IntToStr(
Round(
contarPixels(x1,y1,RGB(250,200,30),imagen1.picture.Width,imagen1.Picture.height)*fraccion*fraccion
)
)
+' m2.' );
end;
// Referencia 2
if ((Owner as TVPrincipal).BReferencia.down=true)and(Shift=[ssLeft])
and(primero2=true) then
begin
Origen:=Point (x1,y1);
puntoM:=Origen;
primero2:=false;
end else
if ((Owner as TVPrincipal).BReferencia.down=true)and(Shift=[ssLeft])and(primero2=false) then
begin
imagen2.Canvas.Draw(0,0,bitmapN);
DibujarImagen(contadorZoom2,imagen2,imagen1.Picture.Width,imagen1.Picture.Height);
puntoM:=Point(x1,y1);
distanciaPixels:=distancia(origen.x,origen.y,puntoM.x,puntoM.y,matrizBy);
//distanciaMetros:=StrToInt(InputBox('Introduce Distancia','Introduce Distancia en Metros:','1000'));
Application.CreateForm(TFPregunta,FPregunta);
DistanciaMetros:=FPregunta.showModal;
if DistanciaMetros=-1 then DistanciaMetros:=0;
Fpregunta.Free;
fraccion:=distanciaMetros/distanciaPixels;
primero2:=true;
end;
end;
end.
104
Manual de usuario:
5.4. COMPOSICION.PAS
x1:=strToInt(editX1.text);
x2:=strToInt(editX2.text);
y1:=strToInt(editY1.text);
y2:=strToInt(editY2.text);
nx1:=strToInt(eX1.text);
nx2:=strToInt(eX2.text);
ny1:=strToInt(eY1.text);
ny2:=strToInt(eY2.text);
factorX:=image1.Width/(X2-X1);
factorY:=image1.Height/(Y2-Y1);
recta.left:=round(nx1*factorx);
recta.top:=round(ny1*factorY);
recta.Right:=round(nx2*factorX);
recta.bottom:=round(ny2*factorY);
recta2.left:=0;
recta2.top:=0;
recta2.Right:=recipiente.Width;
recta2.bottom:=recipiente.Height;
image1.Canvas.CopyRect(recta,recipiente.Bitmap.canvas,recta2)
end;
end;
106
Manual de usuario:
5.5. DESCONTINUIDADESAUX.PAS
end;
function LongitudLinea(x:integer;y:integer;var matrizBy:matrizByte;var borde:boolean;ancho:integer;alto:integer):integer;
var
vecinosNoCero,dx,dy,auxFx,auxFy,longitud:integer;
antiguoX,antiguoY,nx,ny:integer;
begin
longitud:=0;
antiguoX:=x;
antiguoY:=y;
repeat
vecinosNoCero:=0;
if (matrizBy[x-1,y-1]=1)and((x-1<>antiguox)or(y-1<>antiguoY))
then
begin
vecinosNoCero:=1;
antiguoX:=x;
antiguoY:=y;
x:=x-1;
y:=y-1;
end;
if (matrizBy[x-1,y]=1)and((x-1<>antiguox)or(y<>antiguoY)) then
begin
vecinosNoCero:=1;
antiguoX:=x;
antiguoY:=y;
x:=x-1;
y:=y;
end;
if (matrizBy[x-1,y+1]=1)and((x-1<>antiguox)or(y+1<>antiguoY)) then
begin
vecinosNoCero:=1;
107
Manual de usuario:
antiguoX:=x;
antiguoY:=y;
x:=x-1;
y:=y+1;
end;
if (matrizBy[x,y-1]=1)and((x<>antiguox)or(y-1<>antiguoY)) then
begin
vecinosNoCero:=1;
antiguoX:=x;
antiguoY:=y;
x:=x;
y:=y-1;
end;
if (matrizBy[x,y+1]=1)and((x<>antiguox)or(y+1<>antiguoY)) then
begin
antiguoX:=x;
antiguoY:=y;
vecinosNoCero:=1;
x:=x;
y:=y+1;
end;
if (matrizBy[x+1,y-1]=1)and((x+1<>antiguox)or(y-1<>antiguoY)) then
begin
antiguoX:=x;
antiguoY:=y;
vecinosNoCero:=1;
x:=x+1;
y:=y-1;
end;
if (matrizBy[x+1,y]=1)and((x+1<>antiguox)or(y<>antiguoY)) then
begin
antiguoX:=x;
antiguoY:=y;
vecinosNoCero:=1;
x:=x+1;
y:=y;
end;
if(matrizBy[x+1,y+1]=1)and((x+1<>antiguox)or(y+1<>antiguoY)) then
begin
antiguoX:=x;
antiguoY:=y;
vecinosNoCero:=1;
x:=x+1;
y:=y+1;
end;
if vecinosNoCero=1 then inc(longitud);
until (vecinosNoCero=0) or (longitud>2000);
if (x=ancho-1) or (y=alto-1) or (y=1)or (x=1) then
borde:=true
else borde:=false;
LongitudLinea:=longitud;
end;
108
Manual de usuario:
if (VecinosNoCero=1)or(VecinosNoCero=0) then es:=true;
esExtremo:=es;
end;
end.
109
Manual de usuario:
5.6. DESCONTINUIDADES.PAS
//***************************EliminarDescontinuidades***************************
procedure EliminarDescontinuidades(var matrizBy:matrizByte;var bitmap:Tbitmap;ancho:integer;alto,maxLinea:integer);
var
auxFX,auxFY:integer;
rectangulo:Trect;
VecinosNoCero,dx,dy:integer;
borde:boolean;
begin
//borrado dos bordes da matrizBy:
for auxFX:=0 to ancho do
matrizBy[auxFX,0]:=0;
for auxFX:=0 to ancho do
matrizBy[auxFX,alto]:=0;
for auxFy:=0 to alto do
matrizBy[0,auxFy]:=0;
for auxFy:=0 to alto do
matrizBy[ancho,auxFy]:=0;
// Parte alta da imaxen::
for auxFX:=0 to ancho do
if matrizBy[auxFX,1]=1 then UnirLinea(matrizBy,bitmap,auxFx,1,maxLinea,ancho,alto);
//Lado izquierdo da imaxen:
for auxFY:=0 to alto do
if matrizBy[1,auxFY]=1 then UnirLinea(matrizBy,bitmap,1,auxFy,maxLinea,ancho,alto);
//Parte baixa da imaxen:
for auxFX:=0 to ancho do
if matrizBy[auxFx,alto-1]=1 then UnirLinea(matrizBy,bitmap,auxFx,alto-1,maxLinea,ancho,alto);
111
Manual de usuario:
end;
for auxFX:=1 to ancho do
for auxFy:=1 to alto do
begin
if matrizby[auxFx,auxFy]<>0 then
begin
if ((matrizby[auxFx,auxFy-1]<>0) and (matrizby[auxFx-1,auxFy]<>0) and (matrizby[auxFx+1,auxFy+1]=0))
or ((matrizby[auxFx-1,auxFy]<>0) and (matrizby[auxFx,auxFy+1]<>0) and (matrizby[auxFx+1,auxFy-1]=0))
or ((matrizby[auxFx,auxFy+1]<>0) and (matrizby[auxFx+1,auxFy]<>0) and (matrizby[auxFx-1,auxFy-1]=0))
or ((matrizby[auxFx+1,auxFy]<>0) and (matrizby[auxFx,auxFy-1]<>0) and (matrizby[auxFx-1,auxFy+1]=0)) then
begin
matrizby[auxFx,auxFy]:=0;
bitmap.Canvas.Pixels[auxFx,auxFy]:=RGB(255,255,255);
end;
end;
end;
end;
112
Manual de usuario:
5.7. ZHANGSUES.PAS
// 1ª parte do algoritmo
for X:=1 to ancho-1 do
begin
for Y:=1 to alto-1 do
begin
if matrizBy[x,y]<>Cero then
begin
VecinosNoCero:=-1;
for dx:=-1 to 1 do
for dy:=-1 to 1 do
if matrizBy[x+dx,y+dy]<>Cero then
Inc(VecinosNoCero);
TransicionesCeroUno:=0;
if(matrizBy[x-1,y-1]=Cero)and(matrizBy[x,y-1]<>Cero)
then inc(transicionesCeroUno);
if(matrizBy[x,y-1]=Cero)and(matrizBy[x+1,y-1]<>cero)
then inc(transicionesCeroUno);
if(matrizBy[x+1,y-1]=Cero)and(matrizBy[x+1,y]<>cero)
then inc(transicionesCeroUno);
if(matrizBy[x+1,y]=Cero)and(matrizBy[x+1,y+1]<>cero)
then inc(transicionesCeroUno);
if(matrizBy[x+1,y+1]=Cero)and(matrizBy[x,y+1]<>cero)
then inc(transicionesCeroUno);
if(matrizBy[x,y+1]=Cero)and(matrizBy[x-1,y+1]<>cero)
then inc(transicionesCeroUno);
if(matrizBy[x-1,y+1]=Cero)and(matrizBy[x-1,y]<>cero)
then inc(transicionesCeroUno);
if(matrizBy[x-1,y]=Cero)and(matrizBy[x-1,y-1]<>cero)
then inc(transicionesCeroUno);
if(matrizBy[x-1,y-1]=Cero)and(matrizBy[x,y-1]<>Cero)
then inc(transicionesCeroUno);
if(matrizBy[x,y-1]=Cero)and(matrizBy[x+1,y-1]<>cero)
then inc(transicionesCeroUno);
if(matrizBy[x+1,y-1]=Cero)and(matrizBy[x+1,y]<>cero)
then inc(transicionesCeroUno);
if(matrizBy[x+1,y]=Cero)and(matrizBy[x+1,y+1]<>cero)
then inc(transicionesCeroUno);
if(matrizBy[x+1,y+1]=Cero)and(matrizBy[x,y+1]<>cero)
then inc(transicionesCeroUno);
if(matrizBy[x,y+1]=Cero)and(matrizBy[x-1,y+1]<>cero)
then inc(transicionesCeroUno);
if(matrizBy[x-1,y+1]=Cero)and(matrizBy[x-1,y]<>cero)
then inc(transicionesCeroUno);
if(matrizBy[x-1,y]=Cero)and(matrizBy[x-1,y-1]<>cero)
then inc(transicionesCeroUno);
114
Manual de usuario:
for X:=1 to ancho-1 do
begin
for Y:=1 to alto-1 do
begin
if matrizBy[x,y]=128 then
begin
matrizBy[x,y]:=Cero;
cambio:=true;
end
end;
end;
end; //del while
for X:=1 to ancho do
for y:=1 to alto do
begin
if matrizby[x,y]=1 then
begin
if ((matrizby[x,y-1]=1) and (matrizby[x-1,y]=1) and (matrizby[x+1,y+1]=0))
or ((matrizby[x-1,y]=1) and (matrizby[x,y+1]=1) and (matrizby[x+1,y-1]=0))
or ((matrizby[x,y+1]=1) and (matrizby[x+1,y]=1) and (matrizby[x-1,y-1]=0))
or ((matrizby[x+1,y]=1) and (matrizby[x,y-1]=1) and (matrizby[x-1,y+1]=0))
then matrizby[x,y]:=0;
end; //do if
end; //do for
115
Manual de usuario:
5.8. DIBUJO.PAS
for x:=x1 to x2 do
begin
aux:=y1+(y2-y1)*(x-x1)/(x2-x1);
y:=round(aux);
if (aux-y)>0.5 then inc(y);
matrizby[y,x]:=ColorByte;
bitmap.canvas.Pixels[y,x]:=colorBitmap;
end;
end;
end;
end;
5.9. UNIDADFPREGUNTA.PAS
117
Manual de usuario:
5.10. ZOOM.PAS
end;
end;
end;
end;
118
Manual de usuario: Código Fuente
5.11. TIPOS.PAS
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, Menus;
type
matrizByte=array[0..2000,0..2000]of byte;
TAC=record
Altura:integer;
color:tcolor;
cambio:boolean;
numeroPixels:Cardinal;
end;
TmatrizAc=array[1..256]of TAC;
Tdoble=record
valido:boolean;
color:Tcolor;
end;
TMAltura=class
private
NumElementos:integer;
matrizAC:tmatrizAC; //matriz Altura-color
cambio:boolean;
colorAntiguo,colorNuevo:tcolor;
Public
Constructor Create(num:integer);
procedure cambiarColor(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
Procedure Anhadir(var color:Tcolor;altura:integer);
Procedure ensenha;
function fCambios:boolean;
function ColorDeAltura(altura:integer):tcolor;
function AlturaDeColor(color:Tcolor):integer;
function CambioDeAltura(altura:integer):boolean;
function colorA:tcolor;
function colorN:tcolor;
procedure PonherCambioFalse;
Procedure Borrar(color:Tcolor;altura:integer);
function NElementos:integer;
function ColorDeIndice(indice:integer):tcolor;
function AlturaDeIndice(indice:integer):integer;
function SumaDeIndice(indice:integer):integer;
function indiceDeColor(color:tcolor):integer;
procedure SumaColor(color:tcolor);
procedure SumaCero;
Destructor Destroy;Override;
End;
TVColor=Class
Private
numElementos:integer;
vector:Array[0..255]of TDoble;
Public
Constructor Create(num:integer);
Procedure Anhadir(color:Tcolor);
Procedure Borrar(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
Destructor Destroy;Override;
Procedure Muestra(Panel:TPanel);
function Esta(color:tcolor):boolean;
function NElementos:integer;
End;
Implementation
Constructor TMAltura.Create(num:integer);
Begin
Inherited Create;
119
Manual de usuario: Código Fuente
NumElementos:=num;
cambio:=false;
End;
End;
Procedure TMAltura.ensenha;
var
ficha:Tform;
etiqueta:Tlabel;
auxF:integer;
cuadrado:tShape;
begin
Application.CreateForm(Tform,Ficha);
Ficha.Caption:='Cores - Alturas';
ficha.Width:=100;
ficha.left:=410;
ficha.top:=80;
ficha.height:=350;
etiqueta:=TLabel.Create(Ficha);
etiqueta.parent:=Ficha;
etiqueta.left:=20;
etiqueta.top:=1;
etiqueta.caption:='Altura Cor';
cuadrado:=Tshape.Create(Ficha);
with cuadrado do
begin
cuadrado.name:='cuadrado'+intToStr(auxF);
left:=55;
top:=auxF*20;
width:=15;
height:=15;
120
Manual de usuario: Código Fuente
Brush.Color:=MatrizAC[auxF].color;
Parent:=Ficha;
cuadrado.OnMouseDown:=CambiarColor;
end;
end;
Ficha.ShowModal;
Ficha.Free;
end;
function TMAltura.fCambios:boolean;
begin
fCambios:=cambio;
cambio:=false;
end;
function TMAltura.ColorDeAltura(altura:integer):tcolor;
var auxF:integer;
begin
for auxF:=1 to numElementos do
begin
if MatrizAC[auxF].altura=altura then ColorDeAltura:=MatrizAC[auxF].color;
end;
end;
function TMAltura.AlturaDeColor(color:Tcolor):integer;
var
auxF:integer;
encontrado:boolean;
begin
encontrado:=false;
if (numElementos=0) then
begin
AlturaDeColor:=0;
end else
for auxF:=1 to numElementos do
begin
if MatrizAC[auxF].color=color then
begin
AlturaDeColor:=MatrizAC[auxF].altura;
encontrado:=true;
end;
end;
if (encontrado=false) then
begin
AlturaDeColor:=0;
end
end;
function TMAltura.CambioDeAltura(altura:integer):boolean;
var auxF:integer;
begin
for auxF:=1 to numElementos do
begin
if MatrizAC[auxF].altura=altura then
begin
CambioDeAltura:=matrizAC[auxF].cambio;
matrizAC[auxF].cambio:=true;
end;
end;
end;
procedure TMAltura.PonherCambioFalse;
begin
cambio:=false
end;
Destructor TMAltura.Destroy;
Begin
inherited Destroy;
End;
function TMAltura.colorA:tcolor;
121
Manual de usuario: Código Fuente
begin
colorA:=colorAntiguo;
end;
function TMAltura.colorN:tcolor;
begin
colorN:=colorNuevo;
end;
function TMAltura.NElementos:integer;
begin
NElementos:=numElementos;
end;
function TMAltura.ColorDeIndice(indice:integer):tcolor;
begin
colorDeIndice:=matrizAC[indice].color;
end;
function TMAltura.AlturaDeIndice(indice:integer):integer;
begin
AlturaDeIndice:=matrizAC[indice].altura;
end;
function TMAltura.indiceDeColor(color:tcolor):integer;
var auxF:integer;
begin
indiceDeColor:=0;
for auxF:=1 to numElementos do
begin
if MatrizAC[auxF].color=color then
indiceDeColor:=auxF
end
end;
function TMAltura.SumaDeIndice(indice:integer):integer;
begin
SumaDeIndice:=matrizAC[indice].numeroPixels;
end;
procedure TMAltura.SumaColor(color:tcolor);
var auxF:integer;
begin
for auxF:=1 to numElementos do
begin
if MatrizAC[auxF].color=color then
begin
122
Manual de usuario: Código Fuente
inc(MatrizAC[auxF].numeroPixels);
end;
end;
end;
procedure TMAltura.SumaCero;
var auxF:integer;
begin
for auxF:=1 to numElementos do
begin
MatrizAC[auxF].numeroPixels:=0;
end;
end;
{*******************************************************************}
Constructor TVColor.Create(num:integer); //Tipo Vector-Color
Begin
Inherited Create;
NumElementos:=num;
End;
Procedure TVcolor.Anhadir(Color:Tcolor);
var
encontrado:boolean;
auxF:integer;
Begin
if numElementos<=260 then
begin
encontrado:=false;
auxF:=1;
while(encontrado=false)and (auxF<=numElementos) do
begin
if Vector[auxF].Color=Color then
begin
encontrado:=true;
color:=Vector[auxF].color;
end
else
inc(AuxF);
end;
if encontrado=false then
begin
inc(numelementos);
Vector[AuxF].Color:=color;
Vector[AuxF].valido:=true;
end;
end;
End;
Destructor TVColor.Destroy;
Begin
inherited Destroy;
End;
Procedure TVColor.Muestra(Panel:TPanel);
var
AuxF:integer;
cuadrado:Tshape;
elementosPanel:integer;
123
Manual de usuario: Código Fuente
ficha:Tform;
etiqueta:Tlabel;
begin
Panel.visible:=true;
elementosPanel:=panel.controlCount;
124
Manual de usuario: Tabla de ilustraciones
6.TABLA DE ILUSTRACIONES
126
Manual de usuario
127