Ver Mensaje Individual
  #5  
Antiguo 31-05-2004
bububin bububin is offline
Registrado
 
Registrado: may 2004
Posts: 4
Reputación: 0
bububin Va por buen camino
Cita:
Empezado por cht666cht
yo lo hago asi:

Bitmap1 := TBitmap.Create;
Bitmap2 := TBitmap.Create;
try
Bitmap1.LoadFromFile('c:\imagen.bmp');
Bitmap2.PixelFormat := Bitmap1.PixelFormat;
Bitmap2.Width := 200; // nuevo tamaño
Bitmap2.Height := 200;
Bitmap2.Canvas.StretchDraw(0, 0, Bitmap2.Width, Bitmap2.Height, Bitmap1);
Bitmap2.SaveToFile('c:\imagencambiada.bmp');
finally
Bitmap2.Free;
Bitmap1.Free;
end;



y si es un jpg:

JPG := TJPEGImage.Create;
Bitmap := TBitmap.Create;
try
JPG.LoadFromFile('c:\imagen.jpg');
Bitmap.PixelFormat := pf24Bit;
Bitmap.Width := 200; // nuevo tamaño
Bitmap.Height := 200;
Bitmap.Canvas.StretchDraw(0, 0, Bitmap.Width, Bitmap.Height, JPG);
JPG.Assign(Bitmap);
JPG.SaveToFile('c:\imagencambiada.jpg');
finally
Bitmap.Free;
JPG.Free;
end;

lo hago asi porque no puedes acceder directamente al canvas de un jpegimage, pero si que puedes hacerlo con un bitmap, y luego con el assign lo conviertes a jpg.

para usar el tjpegimage añade la unit JPEG al uses.

espero que te sirva, bueno, que te funcione, pq lo he escrito de memoria
Como se puede añadir en el uses el JPEG?. A mi me da error y me dice que no encuentra el jpeg.dcuil.. QUe puede pasar?
Responder Con Cita