2010-05-07 18 views
5

Estoy usando Stretched = True en un TImage con un mapa de bits de 256x256. Esto se reduce en 1,2,4 u 8. Como era de esperar, el texto en el mapa de bits se vuelve más horrible cuanto más salgo de '1'. Observé sin embargo que el explorador de Windows 7 hace una versión reducida del mapa de bits 'más suave' y más agradable. ¿Es posible "desenfocar" un TBitmap de esta manera?¿Es posible suavizar un TBitmap escalado en Delphi?

Respuesta

8

Supongo que quiere decir Stretched = True en un TImage, no en A TBitmap.

Desafortunadamente TImage no tiene remuestradores incorporados, cuando se trata de cambiar el tamaño de las imágenes en él. Mi recomendación sería utilizar Graphics32 ya que es compatible con una variedad de resamplers (algunos son mejores que otros para aumentar el tamaño de la reducción de tamaño)

+0

Gracias, corrigió el texto. Buena sugerencia sobre Graphics32. –

9

Al utilizar el SEMITONO StretchBltMode, obtendrá resultados más suaves que el stretchdraw normal. Esto solo funcionará en Windows 2000 y posteriores

procedure SmoothResize(); 
var pt:TPoint; 
    h: HDC; 
begin 
    h := imgMainPicture.Canvas.Handle; 
    // Previous call to StretchDraw 
    // imgMainPicture.Canvas.StretchDraw(Rect(0, 0, imgMainPicture.Width - 1, 
    // imgMainPicture.Height - 1), curPicture.AnnotatedBitmap); 
    // Normal StretchDraw uses STRETCH_DELETESCANS as StretchBltMode , HALFTONE should give better results 
    GetBrushOrgEx(h, pt); 
    SetStretchBltMode(h, HALFTONE); 
    SetBrushOrgEx(h, pt.x, pt.y, @pt); 
    StretchBlt(h, 0, 0, imgMainPicture.Width - 1, 
    imgMainPicture.Height - 1, curPicture.AnnotatedBitmap.Canvas.Handle, 
    0, 0, curPicture.Width,curPicture.Height,SRCCOPY); 
end; 
+0

Excelente sugerencia, gracias. –

+0

@BrianFrost HALFTONE o STRETCH_HALFTONE es su mejor apuesta en mi humilde opinión, aquí hay un código http://code.google.com/p/delphigeist-delphi-stuff/source/browse/trunk/SynMiniMap/src/SynMiniMap.pas – ComputerSaysNo

Cuestiones relacionadas