Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Gráficos (https://www.clubdelphi.com/foros/forumdisplay.php?f=8)
-   -   convertir BMP a 1bit (https://www.clubdelphi.com/foros/showthread.php?t=27733)

JAV 29-11-2005 14:09:23

convertir BMP a 1bit
 
Hola amigos. Necesito convertir una imagen BMP de 8 bits, escala de grises, a un BMP de 1 bit. Estoy utilizando el método SCANLINE pero sin obtener buenos resultados. Por favor, si alguien conoce cómo realizarlo, desde ya muchas gracias...

Casimiro Notevi 29-11-2005 14:46:43

Una búsqueda por los foros devuelve esto. Puede que te sirva.

JAV 30-11-2005 19:21:48

Gracias por los enlaces pero no encontré nada significativo. Este código lo utilizo y funciona, pero las imágenes que tengo que convertir son enormes. Este método con "Pixels" es muy lento. Alguien conoce el equivalente en "ScanLine"? Desde ya, muchas gracias.

Código Delphi [-]
var
  BMP1, BMP2: TBitmap;
begin
  BMP1 := TBitmap.Create;
  BMP1.LoadFromFile('C:\bitmap.bmp'); //Imagen de 8 bits
  BMP2 := TBitmap.Create;
  BMP2.PixelFormat := pf1bit;
  BMP2.Height := BMP1.Height;
  BMP2.Width := BMP1.Width;
  for X := 0 to BMP1.Width - 1 do
    for Y := 0 to BMP1.Height - 1 do
      BMP2.Canvas.Pixels[X, Y] := BMP1.Canvas.Pixels[X, Y];
  BMP1.Free;
end;

CCCP 20-02-2011 22:39:57

a ver si te vale
 
Código Delphi [-]
procedure GrayScale(PICT: TPicture);
  const
    MaxPixelCount = 32768;
  type
    pRGBArray = ^TRGBArray;
    TRGBArray = ARRAY[0..MaxPixelCount-1] of TRGBTriple;
  var
    i, j, Colr : Integer;
    sl : pRGBArray;  // Scanline
    bmp : TBitmap;
  begin
    bmp := TBitmap.Create;
    try
      bmp.PixelFormat := pf24bit;
      bmp.Width := PICT.Graphic.Width;
      bmp.Height := PICT.Graphic.Height;
      bmp.Canvas.Draw(0,0,PICT.Graphic);
      if bmp.PixelFormat <> pf24bit then begin
        // ShowMessage('Not a 24Bit color bitmap!');
        Exit;
      end;
      for j:=0 to bmp.Height-1 do begin
        sl := bmp.ScanLine[j];
        for i:=0 to bmp.Width-1 do begin
          Colr:=HiByte(sl[i].rgbtRed * 77 + sl[i].rgbtGreen * 151 +
             sl[i].rgbtBlue * 28);
          sl[i].rgbtRed := Colr;
          sl[i].rgbtGreen := Colr;
          sl[i].rgbtBlue := Colr;
        end;
      end;
      PICT.Assign(bmp);
    finally
      bmp.Free;
    end;
  end;


La franja horaria es GMT +2. Ahora son las 20:40:32.

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