Como redimensionar na tela uma imagem que peguei de um campo Blob?

1 resposta
gustavocsb

Esse é meu problema…
Eu gravo a imagem num campo blob do meu BD.
Porém, quando quero mostras a imagem, não quero mostrá-la no tamanho que gravei no campo.
Também não quero forçar esse redimensionamento na tag usando width e height…

Como posso fazer isso ?

Abraços

1 Resposta

goofed

A classe Image tem o seguinte método:

getScaledInstance
public Image getScaledInstance(int width,
                               int height,
                               int hints)
Creates a scaled version of this image. A new Image object is returned which will render the image at the specified width and height by default. The new Image object may be loaded asynchronously even if the original source image has already been loaded completely. 
If either width or height is a negative number then a value is substituted to maintain the aspect ratio of the original image dimensions. If both width and height are negative, then the original image dimensions are used. 


Parameters:
width - the width to which to scale the image.
height - the height to which to scale the image.
hints - flags to indicate the type of algorithm to use for image resampling. 
Returns:
a scaled version of the image. 
Throws: 
IllegalArgumentException - if width or height is zero.
Since: 
JDK1.1 
See Also:
SCALE_DEFAULT, SCALE_FAST, SCALE_SMOOTH, SCALE_REPLICATE, SCALE_AREA_AVERAGING

Outra maneira seria usar AffineTransform que tem o método ‘getScaleInstance(double sx, double sy)’
Mas é mais complicadim. :smiley:

Criado 12 de outubro de 2007
Ultima resposta 13 de out. de 2007
Respostas 1
Participantes 2