Ver Mensaje Individual
  #6  
Antiguo 28-04-2008
Avatar de cHackAll
[cHackAll] cHackAll is offline
Baneado?
 
Registrado: oct 2006
Posts: 2.159
Reputación: 20
cHackAll Va por buen camino
Un barrido podría ser visto como ésto;

Código Delphi [-]
...

 y := bmp.Height;
 repeat Dec(y);                       // barrido vertical
  x := bmp.Width;
  repeat Dec(x);                      // barrido horizontal
   Color := bmp.Canvas.Pixels[X, Y];
   if GetRValue(Color) > 10 then
    bmp.Canvas.Pixels[X, Y] := RGB(GetRValue(Color) - 10, GetGValue(Color), GetBValue(Color));
  until not LongBool(x);
 until not LongBool(y);

...
ó con el uso de un while o un for (simplemente un bucle dentro de otro), sin embargo se puede hacer un barrido de toda la imagen directamente en memoria, lo que mejoraría conciderablemente la velocidad de acceso y el trabajo plano en un vector (a diferencia de en una matriz XY como la del anterior ejemplo).

Código Delphi [-]
uses jpeg;

procedure TForm1.Button1Click(Sender: TObject);
var
 jpg: TJPEGImage;
 bmp: TBitmap;
 Count: Cardinal;
 lpBuffer: PByte;
begin
 jpg := TJPEGImage.Create;
 jpg.LoadFromFile('c:\windows\web\wallpaper\autumn.jpg');
 bmp := TBitmap.Create;
 bmp.Assign(jpg);
 bmp.PixelFormat := pf24bit;
 Count := bmp.Width * bmp.Height;
 lpBuffer := PByte(Cardinal(bmp.ScanLine[bmp.Height - 1]) + 2);
 while LongBool(Count) do // Barrido
  begin
   if lpBuffer^ > 64 then //  Si el tono excede el mínimo
    Dec(lpBuffer^, 64);   // reducimos dicho valor.
//    lpBuffer^ := 255{Ej. enrojecido total};
   Inc(lpBuffer, 3);
   Dec(Count);
  end;
 Image2.Picture.Assign(bmp);
 Image1.Picture.Assign(jpg);
 bmp.Destroy;
 jpg.Destroy;
end;

Saludos

Última edición por cHackAll fecha: 28-04-2008 a las 18:39:48. Razón: REM
Responder Con Cita