Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

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

 
 
Herramientas Buscar en Tema Desplegado
  #4  
Antiguo 25-12-2006
Avatar de seoane
[seoane] seoane is offline
Miembro Premium
 
Registrado: feb 2004
Ubicación: A Coruña, España
Posts: 3.717
Poder: 26
seoane Va por buen camino
Ya solo nos queda aplicar otra vuelta de tuerca, y limitar el cifrado a un recuadro de la imagen, por ejemplo, para taparle la cara a alguien en una foto:

Código Delphi [-]
type
  Triple = array[1..3]of Byte;

procedure Cifrar(Imagen: TPicture; R: TRect; Clave: Longint);
var
  Bitmap: TBitmap;
  P1, P2: ^Triple;
  i, j, k, H, W: Integer;
  Temp: Triple;
  Sec: Array of Integer;
begin
  RandSeed:= Clave;
  if not (Imagen.Graphic is TBitmap) then
  begin
    Bitmap:= TBitmap.Create;
    try
      Bitmap.Width:= Imagen.Width;
      Bitmap.Height:= Imagen.Height;
      Bitmap.Canvas.Draw(0,0,Imagen.Graphic);
      Imagen.Assign(Bitmap);
    finally
      Bitmap.Free;
    end;
  end;
  Imagen.Bitmap.PixelFormat:= pf24bit;
  IntersectRect(R,R,Rect(0,0,Imagen.Bitmap.Width - 1,Imagen.Bitmap.Height - 1));
  H:= R.Bottom - R.Top;
  W:= R.Right - R.Left;
  SetLength(Sec,H div 2);
  for i:= 0 to High(Sec) do
    Sec[i]:= Length(Sec) + i;
  for i:= 0 to High(Sec) do
  begin
    k:= Sec[i];
    j:= Random(High(Sec));
    Sec[i]:= Sec[j];
    Sec[j]:= k;
  end;
  for j:= 0 to High(Sec) do
  begin
    P1:= Imagen.Bitmap.ScanLine[R.Top + j];
    P2:= Imagen.Bitmap.ScanLine[R.Top + Sec[j]];
    inc(P1,R.Left);
    inc(P2,R.Left);
    for i:= 0 to W - 1 do
    begin
      Temp:= P1^;
      P1^:= P2^;
      P2^:= Temp;
      inc(P1); inc(P2);
    end;
  end;
end;

// Por ejemplo
procedure TForm1.Button1Click(Sender: TObject);
begin
  // Por ejemplo
  Cifrar(Image1.Picture,Rect(100,100,200,200),1978);
  Image1.Refresh;
end;

Bueno, por ahora no se me ocurre nada mas, el siguiente paso seria aplicar algoritmos de criptografía fuerte (AES, Serpent, ...) para cifrar los puntos de la imagen en vez de usar un simple Random.

Roman, ya me contaras si esto se ajusta a lo que buscabas, estabas pensando en otra cosa o incluso si necesitas ir mas allá.
Responder Con Cita
 


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

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
encriptar xelip Varios 1 27-08-2006 21:47:10
encriptar tablas pablo Conexión con bases de datos 2 06-11-2004 18:26:15
Encriptar Clave agora18 Varios 1 17-10-2003 22:19:32
Encriptar datos miguelb Varios 1 17-07-2003 08:24:00
Encriptar datos? emeceuy Varios 2 03-07-2003 17:56:50


La franja horaria es GMT +2. Ahora son las 19:25:53.


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