Tai iraso ar neiraso? Nesuprantu.
>> kai i db rasau su sia komanda: fileUpload1.getUploadedFile().getBytes()
>> viskas ok, t.y. foto iraso is bet kurios narsykles
o veliau rasai
> su Opera ar Forefox
>> neiraso nei thumbnailo, nei 800x800px foto.
Jei visgi perduodi, tai:
- issaugok tuos baitus kurios gauni kiam nors faile
- atidziau paziurek ar duomenys teisingi, t.y lygiai tokia patys
kokius ir perdavei
- Ta, savo kodo gabala i nauja klase sudek
kad is konsoles galetum paleisti kaip atskira programa
- paleidi ta programa su tais duomenim kuriuos
issaugojai(java.io.FileInputStream)
- ziuri rezultatus (meti i FileOutputStream)
- analizuoji duomenys
Tadas B. wrote:
> zodziu kaip sakiau neesu java specas, tai iklijuoju koda, gal kas ka
> izvelgs...
>
> kai i db rasau su sia komanda: fileUpload1.getUploadedFile().getBytes()
> viskas ok, t.y. foto iraso is bet kurios narsykles
>
> su Opera ir firefax neveikia mazinimo metodas:
> public byte[] getPreview(byte[] imageBytes, String format, int
> previewWidth, int previewHeight ) {
> ByteArrayOutputStream result = new ByteArrayOutputStream();
> int newWidth;
> int newHeight;
> try {
> ByteArrayInputStream byteInput = new
> ByteArrayInputStream(imageBytes);
> BufferedImage image = ImageIO.read(byteInput);
> if (image.getWidth() <= previewWidth && image.getHeight() <=
> previewHeight) // picture is so small that it fits as preview itself
> {
> return imageBytes;
> }
> if (previewWidth * image.getHeight() < previewHeight *
> image.getWidth()) {
> // scale=previewWidth/image.getWidth();
> newWidth = previewWidth;
> newHeight = image.getHeight() * previewWidth /
> image.getWidth();
> } else {
> // scale=previewHeight/image.getHeight();
> newHeight = previewHeight;
> newWidth = image.getWidth() * previewHeight /
> image.getHeight();
> }
> BufferedImage newImage = new BufferedImage(newWidth,
> newHeight, BufferedImage.TYPE_INT_RGB);
> Graphics2D g2d = (Graphics2D) newImage.createGraphics();
> g2d.drawImage(image, 0, 0, newWidth, newHeight , null);
> ImageIO.write(newImage, format, result);
> } catch (Exception e) {
> error("Klaida mazinant foto: " + e.getMessage());
> }
> return result.toByteArray();
> }
>
> pas mane lokaliai kompe viskas ok, darbineje aplinkoje su IE nepadaro
> thumbnailo 50x50px, bet sumazina 800x800 ir iraso. su Opera ar Forefox
> neiraso nei thumbnailo, nei 800x800px foto. primenu, kad viskas veike ir
> darbineje aplinkoje, kol po neaiskiu aplinkybiu pradejo nebeveikti...