na gal per daug susimale, bet pakartoju:
- foto galiu uploadinti su bet kuria narsykle, jei nenaudoju ir nemazinu
foto, t.y. paprasta komanda: fileUpload1.getUploadedFile().getBytes()
- jei naudoju foto mazinimo metoda :
byte[] preview = null;
preview = getPreview(fileUpload1.getUploadedFile().getBytes(),
fileUpload1.getUploadedFile().getContentType().substring(7), 800, 800);
fotoDataProvider.setValue("foto.foto_preview", fotoRk1,
preview);
iraso tik su IE, Opera ir firefax ne. sis metodas ir yra atskiroje
klaseje, taigi bandysiu paanalizuoti, kaip sakei. jei tik mokesiu :)
siaip ieskau kito foto mazinimo pavyzduko, gal nebebus bedu
On Sat, 16 May 2009 12:27:33 +0300, JAlexoid <whereabout@mail333.com>
wrote:
> 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...