Aqui te envio el código que tengo..........
mi intención es que haga cada proceso por separado pero lo muestre en la misma ventana.......No habia comentado que el menú es de la ventana principal y las imagenes aparecerán en una segunda ventana sin menú.........
#include <vcl.h>
#include <stdio.h>
#include <math.h>
#pragma hdrstop#include "hyal.h"
#include "hyal1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
TImage *Image1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::GradienteX1Click(TObject *Sender)
{
Form2->Show();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Salir1Click(TObject *Sender)
{
exit(0);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Abrir1Click(TObject *Sender)
{
if(OpenDialog1->Execute())
Form2->Show();
}
//---------------------------------------------------------------------------
#include <vcl.h>
#include <stdio.h>
#include <conio.h>
#include <math.h>
#pragma hdrstop
#include "hyal1.h"
#include "hyal.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
//TMainMenu *MainMenu1;
TMenuItem *Abrir1;
TMenuItem *GradienteX1;
unsigned char Imagen[256][256];
int w;
float tempo1[256][256];
unsigned char tempo2[256][256];
float GradX[256][256];
float GradY[256][256];
unsigned char GradXmos[256][256];
unsigned char GradYmos[256][256];
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm2::FormCreate(TObject *Sender)
{
FILE *p;
float filtroX[5][5]={
0.0, 1.0, 0.0, -1.0, 0.0,
1.0, 2.0, 0.0, -2.0, -1.0,
1.0, 2.0, 0.0, -2.0, -1.0,
1.0, 2.0, 0.0, -2.0, -1.0,
0.0, 1.0, 0.0, -1.0, 0.0, };
if(Form1->Abrir1->GroupIndex==1)
{
if((p=fopen("gventri0.raw","r+b"))==NULL)
{
Application->MessageBox("Error al abrir archivo!!!","Error!!",MB_OK);
return;
}
fread(Imagen,256,256,p);
fclose(p);
mostrar(Imagen, Image1);
}
if(Form1->GradienteX1->GroupIndex==3){
w=1;
generarg(Imagen, filtroX, w);
p=fopen("GradienteX.raw", "wb");
fwrite(GradX, sizeof(unsigned char), 256*256, p);
fclose(p);
mostrar(GradXmos, Image2);
}
}
//---------------------------------------------------------------------------
void mostrar(unsigned char I[][256], TImage *Imagen)
{
int x, y;
for(y=0; y<256; y++)
for(x=0; x<256; x++)
Imagen->Canvas->Pixels[y][x]=(I[x][y]<<16|I[x][y]<<8|I[x][y]);
}
//----------------------------------------------------------------------------
void generarg(unsigned char I[][256], float filtro[5][5], int w)
{
int x, y, f, c, cons;
float aux, centro, min, max, rescal;
for(y=0; y<256; y++)
for(x=0; x<256; x++)
tempo1[x][y] = I[x][y];
//Convolución
cons=2;
for(y=2; y<254; y++)
for(x=2; x<254; x++)
{
centro = 0.0;
for(c=-2; c<3; c++)
for(f=-2; f<3; f++)
{
aux = (float)(I[x+f][y+c])*(filtro[f+cons][c+cons]);
centro += aux;
}
tempo1[x][y] = centro;
}
//reescalamiento
min = 100000.0;
max = 0.0;
for(y=0; y<256; y++)
for(x=0; x<256; x++)
{
if(tempo1[x][y] > max)
max = tempo1[x][y];
if(tempo1[x][y] < min)
min = tempo1[x][y];
}
for(y=0; y<256; y++)
for(x=0; x<256; x++)
{
rescal = (float)255.0*(tempo1[x][y]-min)/(max-min);
tempo2[x][y] = (unsigned char)rescal;
}
if(w==1)
{
for(y=0; y<256; y++)
for(x=0; x<256; x++)
{
GradX[x][y] = tempo1[x][y];
GradXmos[x][y] = tempo2[x][y];
}
}
if(w==2)
{
for(y=0; y<256; y++)
for(x=0; x<256; x++)
{
GradY[x][y] = tempo1[x][y];
GradYmos[x][y] = tempo2[x][y];
}
}
}
En lo que me puedas ayudar te lo agradecere.....