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 23-06-2008
Avatar de RONPABLO
[RONPABLO] RONPABLO is offline
Miembro Premium
 
Registrado: oct 2004
Posts: 1.514
Poder: 21
RONPABLO Va por buen camino
copiar un sector de imagen que no esta visible

hola, tengo el siguiente procedimiento con el cual recorro una imagen origen y capturo el sector entre un área determinada en el que se encuentre el color negro, el área determinada es variable en su altura, de forma tal que siempre se recorre en X desde el punto 0 hasta el tamañano de la imagen y en Y desde y hasta un punto varibale dentro del rango de Y, el problema es que para poder copiar el sector tiene que estar visible dicha imagen origen y necesito que no este visible, la imagen la cargo desde un stream a un TImage....


Código Delphi [-]
procedure TFSectorVisualizar.asignarImagen(inY, finY : Integer);
var
  x,y, x1, y1, xIni, yIni : Integer;
  BitMap : TBitMap;
  P : PByteArray;
  lColor : TColor;
  rectanOrigen : TRect;
begin
  try
    x1 := 0;
    y1 := 0;
    xIni := ImagenOrigen.Width;
    yIni := ImagenOrigen.Height;
    Bitmap := TBitmap.Create;
    Bitmap.Width:= ImagenOrigen.Width;
    Bitmap.Height:= ImagenOrigen.Height;
    Bitmap.Canvas.Draw(0,0,ImagenOrigen.Picture.Graphic);
    for y := inY to FinY do
    begin
      for x := 0 to BitMap.Width -1 do
      begin
         if BitMap.Canvas.Pixels[x,y] = clblack then
         begin
            if x > x1 then
               x1 := x;
            if y > y1 then
               y1 := y;
            if x < xIni then
               xIni := x;
            if y < yIni then
               yIni := y;
         end;
      end;
    end;
    imDestino.Width :=  x1 - xIni;
    imDestino.Height :=  y1 - yIni;
    xIni := ImagenOrigen.Left  + xIni;
    yIni := ImagenOrigen.Top + yIni;
    rectanOrigen := rect(xIni, yIni, x1, y1);
    if (x1 > xIni) and (y1 > YIni) then
          Copiar(Canvas.Handle,imPaciente.Canvas.Handle,rectanOrigen,1)
  finally
  end;
end;


procedure TFSectorVisualizar.Copiar(SrcDC, DestDc: HDC; SrcRect: TRect; Zoom: Integer);
begin
  StretchBlt(DestDC, 0,0, SrcRect.Right, SrcRect.Bottom, SrcDC, SrcRect.Left,
    SrcRect.Top, SrcRect.Right, SrcRect.Bottom, SRCCOPY);
end;


Y para llamar la función lo hago así:

Código Delphi [-]
    asignarImagen(0, 224);
    // ó asignarImagen(20, 100);
__________________
"Como pasa el tiempo..... ayer se escribe sin H y hoy con H"
Responder Con Cita
  #2  
Antiguo 23-06-2008
Avatar de RONPABLO
[RONPABLO] RONPABLO is offline
Miembro Premium
 
Registrado: oct 2004
Posts: 1.514
Poder: 21
RONPABLO Va por buen camino
Solución... (perdí tanto tiempo tratando de hacer esto y ahora que lo hice lo veo tan fácil, hay días que no le acierto un tiro al mundo aunque este hinchado.... )
Código Delphi [-]
procedure TFSectorVisualizar.asignarImagen(inY, finY : Integer);
var
  x,y, x1, y1, xIni, yIni : Integer;
  BitMap : TBitMap;
  P : PByteArray;
  lColor : TColor;
  rectanOrigen : TRect;
begin
  try
    x1 := 0;
    y1 := 0;
    xIni := ImagenOrigen.Width;
    yIni := ImagenOrigen.Height;
    Bitmap := TBitmap.Create;
    Bitmap.Width:= ImagenOrigen.Width;
    Bitmap.Height:= ImagenOrigen.Height;
    Bitmap.Canvas.Draw(0,0,ImagenOrigen.Picture.Graphic);
    for y := inY to FinY do
    begin
      for x := 0 to BitMap.Width -1 do
      begin
         if BitMap.Canvas.Pixels[x,y] = clblack then
         begin
            if x > x1 then
               x1 := x;
            if y > y1 then
               y1 := y;
            if x < xIni then
               xIni := x;
            if y < yIni then
               yIni := y;
         end;
      end;
    end;
    if (x1 > xIni) and (y1 > YIni) then
    begin
       imDestino.Width :=  x1 - xIni;
       imDestino.Height :=  y1 - yIni;
        rectanOrigen := rect(xIni, yIni, x1, y1);
        imDestino.Canvas.CopyRect(Rect(0,0, x1 - xIni, y1 - yIni),BitMap.Canvas,rectanOrigen);
    end;
  finally
  end;
end;
__________________
"Como pasa el tiempo..... ayer se escribe sin H y hoy con H"
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

Temas Similares
Tema Autor Foro Respuestas Último mensaje
copiar un fichero en el primer sector reinier Windows 4 28-02-2008 21:01:11
no visible componente de imagen kapullok_2006 Gráficos 0 07-06-2007 11:08:30
cómo saber en una listview el item que está visible (no seleccionado) en cada momento igc C++ Builder 1 16-02-2007 18:25:52
copiar fichero mas de 2Gb con esta funcion aram2r Varios 7 08-02-2006 17:28:22
Imagen siempre visible Alexander HTML, Javascript y otros 5 23-09-2005 23:37:23


La franja horaria es GMT +2. Ahora son las 11:26:56.


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