Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Gráficos
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 19-05-2003
esquerda21 esquerda21 is offline
Miembro
 
Registrado: may 2003
Posts: 51
Poder: 22
esquerda21 Va por buen camino
Escalar y Rotar Vectores

Hola.
Cual es la mejor forma de escalar y rotar un conjunto de puntos que forman lineas y circulos del rollo vectorial?

Gracias una y otra vez.
Responder Con Cita
  #2  
Antiguo 19-05-2003
Avatar de delphi.com.ar
delphi.com.ar delphi.com.ar is offline
Federico Firenze
 
Registrado: may 2003
Ubicación: Buenos Aires, Argentina *
Posts: 5.932
Poder: 27
delphi.com.ar Va por buen camino
Para rotar Bitmaps, alguien ha pasado esta unit anteriormente, pero no pude encontrar esa respuesta:

Código:
unit RotMirBitmap;

interface

uses
  Windows, Graphics;

procedure MirrorHorizontal(Bitmap: TBitmap);
procedure MirrorVertical(Bitmap: TBitmap);
procedure Rotate90Degrees(Bitmap: TBitmap);
procedure Rotate270Degrees(Bitmap: TBitmap);
procedure Rotate180Degrees(Bitmap: TBitmap);

implementation

uses
  dialogs, Classes, SysUtils;

type
  EBitmapError = Class(Exception);
  TRGBArray = Array[0..0] of TRGBTriple;
  pRGBArray = ^TRGBArray;

procedure MirrorHorizontal(Bitmap: TBitmap);
var
  i, j, w: Integer;
  RowIn: pRGBArray;
  RowOut: pRGBArray;
begin
  w := bitmap.width * sizeof(TRGBTriple);
  GetMem(rowin, w);
  for j := 0 to Bitmap.Height - 1 do
  begin
   move(Bitmap.Scanline[j]^, rowin^, w);
   rowout := Bitmap.Scanline[j];
  for i := 0 to Bitmap.Width - 1 do
   rowout[i] := rowin[Bitmap.Width - 1 - i];
  end;
  bitmap.Assign(bitmap);
  FreeMem(rowin);
end;


procedure MirrorVertical(Bitmap : TBitmap);
var
  j, w: Integer;
  help: TBitmap;
begin
  help := TBitmap.Create;
  help.Width := Bitmap.Width;
  help.Height := Bitmap.Height;
  help.PixelFormat := Bitmap.PixelFormat;
  w := Bitmap.Width * sizeof(TRGBTriple);
  for j := 0 to Bitmap.Height - 1 do
   move(Bitmap.Scanline[j]^, Help.Scanline[Bitmap.Height - 1 - j]^, w);
  Bitmap.Assign(help);
  help.free;
end;


type
  THelpRGB = packed record
   rgb: TRGBTriple;
   dummy: byte;
end;


procedure Rotate270Degrees(Bitmap: TBitmap);
var
  aStream: TMemorystream;
  header: TBITMAPINFO;
  dc: hDC;
  P: ^THelpRGB;
  x, y, b, h: Integer;
  RowOut: pRGBArray;
begin
  aStream := TMemoryStream.Create;
  aStream.SetSize(Bitmap.Height * Bitmap.Width * 4);
  with header.bmiHeader do
  begin
   biSize := SizeOf(TBITMAPINFOHEADER);
   biWidth := Bitmap.Width;
   biHeight := Bitmap.Height;
   biPlanes := 1;
   biBitCount := 32;
   biCompression := 0;
   biSizeimage := aStream.Size;
   biXPelsPerMeter :=1;
   biYPelsPerMeter :=1;
   biClrUsed :=0;
   biClrImportant :=0;
  end;
  dc := GetDC(0);
  P := aStream.Memory;
  GetDIBits(dc,Bitmap.Handle, 0, Bitmap.Height, P,header, dib_RGB_Colors);
  ReleaseDC(0, dc);
  b := bitmap.Height;  {rotate}
  h := bitmap.Width;  {rotate}
  bitmap.Width := b;
  bitmap.height := h;
  for y := 0 to (h - 1) do
  begin
   rowOut := Bitmap.ScanLine[(h - 1) - y];
   P := aStream.Memory;  {reset pointer}
   inc(p, y);
   for x := (b - 1) downto 0 do
   begin
     rowout[x] := p^.rgb;
     inc(p, h);
   end;
  end;
  aStream.Free;
end;


procedure Rotate90Degrees(Bitmap: TBitmap);
var
  aStream: TMemorystream;
  header: TBITMAPINFO;
  dc: hDC;
  P: ^THelpRGB;
  x, y, b, h: Integer;
  RowOut:  pRGBArray;
begin
  aStream := TMemoryStream.Create;
  aStream.SetSize(Bitmap.Height * Bitmap.Width * 4);
  with header.bmiHeader do
  begin
   biSize := SizeOf(TBITMAPINFOHEADER);
   biWidth := Bitmap.Width;
   biHeight := Bitmap.Height;
   biPlanes := 1;
   biBitCount := 32;
   biCompression := 0;
   biSizeimage := aStream.Size;
   biXPelsPerMeter :=1;
   biYPelsPerMeter :=1;
   biClrUsed :=0;
   biClrImportant :=0;
  end;
  dc := GetDC(0);
  P := aStream.Memory;
  GetDIBits(dc, Bitmap.Handle, 0, Bitmap.Height, P, header, dib_RGB_Colors);
  ReleaseDC(0, dc);
  b := bitmap.Height;  {rotate}
  h := bitmap.Width;  {rotate}
  bitmap.Width := b;
  bitmap.height := h;
  for y := 0 to (h - 1) do
  begin
   rowOut := Bitmap.ScanLine[y];
   P := aStream.Memory;  {reset pointer}
   inc(p, y);
   for x := 0 to (b - 1) do
   begin
     rowout[x] := p^.rgb;
     inc(p, h);
   end;
  end;
  aStream.Free;
end;


procedure Rotate180Degrees(Bitmap: TBitmap);
var
  i, j: Integer;
  rowIn: pRGBArray;
  rowOut: pRGBArray;
  help: TBitmap;
begin
  help := TBitmap.Create;
  help.Width  := Bitmap.Width;
  help.Height := Bitmap.Height;
  help.PixelFormat := Bitmap.PixelFormat;  {only pf24bit for now}
  for j := 0 to Bitmap.Height - 1 do
  begin
   rowIn := Bitmap.ScanLine[j];
   rowOut := help.ScanLine[Bitmap.Height - j - 1];
   for i := 0 to Bitmap.Width - 1 do
     rowOut[Bitmap.Width - i - 1] := rowIn[i]
  end;
  bitmap.assign(help);
  help.free;
end;

end.
__________________
delphi.com.ar

Dedique el tiempo suficiente para formular su pregunta si pretende que alguien dedique su tiempo en contestarla.
Responder Con Cita
  #3  
Antiguo 20-05-2003
esquerda21 esquerda21 is offline
Miembro
 
Registrado: may 2003
Posts: 51
Poder: 22
esquerda21 Va por buen camino
Si, si esta muy bien pa los q saben pero en mi caso no es un BMP si no un conjunto de puntos que forman lineas del rollo :

Moveto(10,15);
Lineto(30,50);

en mi caso tengo un Array de vectores q forman circulos rectas y demas. Como calculo el escalamiento (estilo zoom) de los vectores? y con que referencia?

gracias de antemano.
Responder Con Cita
  #4  
Antiguo 20-05-2003
Avatar de delphi.com.ar
delphi.com.ar delphi.com.ar is offline
Federico Firenze
 
Registrado: may 2003
Ubicación: Buenos Aires, Argentina *
Posts: 5.932
Poder: 27
delphi.com.ar Va por buen camino
Si esos vectores no los has dibujado aún en un Bitmap, solo tienes que hacer funciones lógicas, para escalarlo tendrías que multiplicar los valores por el factor que necesites, y para rotarlos, tendrías que jugar con los valores de la misma forma que lo hacen estas funciones.
Si ya has dibujado estos vectores en un Bitmap, solo tienes que llamar a la función correcta.

¿Porque no aclaras un poco mas que es lo que quieres hacer?

Saludos!
__________________
delphi.com.ar

Dedique el tiempo suficiente para formular su pregunta si pretende que alguien dedique su tiempo en contestarla.
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro


La franja horaria es GMT +2. Ahora son las 14:31:51.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi