FabianSiza
20-09-2014, 01:18:37
Hola mundo!.
tengo un imagen control y en el cargo imagenes y cuando presiono un boton se pintan unos cuadros a la imagen asi.
MyRect := TRectF.Create(0, 0, 1000, 300); //crea un rectangulo pos x, pos y , largo, alto
MyRect2 := TRectF.Create(1000, 0, 1910, 300); //crea un rectangulo pos x, pos y , largo, alto
MyRect3 := TRectF.Create({borde iz}0, 2800, {largo}1000,2300); //crea un rectangulo pos x, pos y , largo, alto
MyRect4 := TRectF.Create(1910, 100000, 1000, 2300); //crea un rectangulo pos x, pos y , largo, alto
ImageControl1.Bitmap.Canvas.BeginScene;
con esto los cuadros quedan arriba y abajo d la imagen importada pero solo funciona con las dimensiones de una imagen y cuando cargo una imagen de distinto tamaño los cuadros quedan perdidos por que no son dinamicos eso debe ser con variables pero como puedo hacer que los cuadros se auto-ajusten a las imagenes?. Gracias.!!
ecfisa
20-09-2014, 06:50:41
Hola Fabián.
¿ Cual es la declaración del tipo TRectF ?
Por favor cuando incluyas código en tus mensajes usa las etiquetas:
http://sia1.subirimagenes.net/img/2014/09/20/140920064308529777.jpg
Saludos :)
FabianSiza
20-09-2014, 07:01:22
a perdón cuando le doy al boton aplicar este le pone el texto y los cuadros a la imagen aca esta
procedure TForm1.Button1Click(Sender: TObject);
var
MyRect,MyRect2,MyRect3,MyRect4: TRectF;
begin
MyRect := TRectF.Create(0, 0, 1000, 300); //crea un rectangulo pos x, pos y , largo, alto
MyRect2 := TRectF.Create(1000, 0, 1910, 300); //crea un rectangulo pos x, pos y , largo, alto
MyRect3 := TRectF.Create({borde iz}0, 2800, {largo}1000,2300); //crea un rectangulo pos x, pos y , largo, alto
MyRect4 := TRectF.Create(1910, 100000, 1000, 2300); //crea un rectangulo pos x, pos y , largo, alto
ImageControl1.Bitmap.Canvas.BeginScene;
//*******************************************
ImageControl1.Bitmap.Canvas.Fill.Color := TAlphaColorRec.Black; //pinta el rectangulo
ImageControl1.Bitmap.Canvas.FillRect(MyRect, 30, 60, [], 100); //dibuja el rectangulo
//******************************************************
//****************************************************
ImageControl1.Bitmap.Canvas.Fill.Color := TAlphaColorRec.White; //pinta el texto
ImageControl1.Bitmap.Canvas.Font.Size:=55;
ImageControl1.Bitmap.Canvas.FillText(MyRect, 'NOMBRE: '+Edit1.Text, false, 100,
[TFillTextFlag.RightToLeft], TTextAlign.Center, TTextAlign.Center); //Agrega rectangulo y texto a la imagen
//*******************************************
//*******************************************
ImageControl1.Bitmap.Canvas.Fill.Color := TAlphaColorRec.Red; //pinta el rectangulo
ImageControl1.Bitmap.Canvas.FillRect(MyRect2, 30, 60, [], 100); //dibuja el rectangulo
ImageControl1.Bitmap.Canvas.Fill.Color := TAlphaColorRec.White; //pinta el texto
ImageControl1.Bitmap.Canvas.Font.Size:=50;
ImageControl1.Bitmap.Canvas.FillText(MyRect2, 'CODIGO: '+Edit2.Text, false, 100,
[TFillTextFlag.RightToLeft], TTextAlign.Center, TTextAlign.Center); //Agrega rectangulo y texto a la imagen
//*******************************************
//*******************************************
ImageControl1.Bitmap.Canvas.Fill.Color := TAlphaColorRec.Black; //pinta el rectangulo
ImageControl1.Bitmap.Canvas.FillRect(MyRect3, 30, 60, [], 100); //dibuja el rectangulo
ImageControl1.Bitmap.Canvas.Fill.Color := TAlphaColorRec.White; //pinta el texto
ImageControl1.Bitmap.Canvas.Font.Size:=55;
ImageControl1.Bitmap.Canvas.FillText(MyRect3,'MEDIDAS: '+Edit3.Text, false, 100,
[TFillTextFlag.RightToLeft], TTextAlign.Center, TTextAlign.Center); //Agrega rectangulo y texto a la imagen
//*******************************************
//*******************************************
ImageControl1.Bitmap.Canvas.Fill.Color := TAlphaColorRec.Red; //pinta el rectangulo
ImageControl1.Bitmap.Canvas.FillRect(MyRect4, 30, 60, [], 100); //dibuja el rectangulo
ImageControl1.Bitmap.Canvas.Fill.Color := TAlphaColorRec.White; //pinta el texto
ImageControl1.Bitmap.Canvas.Font.Size:=55;
ImageControl1.Bitmap.Canvas.FillText(MyRect4,'PRECIO: '+Edit4.Text, false, 100,
[TFillTextFlag.RightToLeft], TTextAlign.Center, TTextAlign.Center); //Agrega rectangulo y texto a la imagen
//*******************************************
ImageControl1.Bitmap.Canvas.EndScene;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
OpenDialog1.Execute;
if OpenDialog1.FileName <> '' then
ImageControl1.Bitmap.LoadFromFile(OpenDialog1.FileName);
este es mi codigo pero como decia no se ajusta automaticamente a el tamaño de las imagenes asi que el texto y los cuadros se pierden y se distrocionan creo que el Timagencontrol tiene algo para reconocer eso
zeeshan030
14-04-2015, 11:09:45
pero como decia no se ajusta automaticamente a el tamaño de las imagenes asi que el texto y los cuadros se pierden y se distrocionan creo que el Timagencontrol tiene algo para reconocer eso..
____________________
aliii
ecfisa
14-04-2015, 14:50:14
Hola zeeshan030, bienvenido a Club Delphi :)
Como a todo recién ingresado te invitamos a leer nuestra guía de estilo (http://www.clubdelphi.com/foros/guiaestilo.php).
Saludos :)
vBulletin v3.6.8, Derechos ©2000-2024, Jelsoft Enterprises Ltd.