poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yegor Kozlov <ye...@dinom.ru>
Subject Re[2]: HSLF JPEG Insertion troubles
Date Wed, 30 Jan 2008 13:41:47 GMT
Try BufferedImage.TYPE_INT_RGB. PowerPoint seems to be happy with it.

Yegor

> Thanks a lot for your answer Yegor.

> Although both codes work, there seems to be incompatibility troubles
> while using "BufferedImage.TYPE_4BYTE_ABGR" type for the image.

> My code works fine if I use the same image type than yours
> That is to say, replacing :
>>>> BufferedImage bImage = new BufferedImage(width, height,
>>>>                                BufferedImage.TYPE_4BYTE_ABGR);
> By this :
>>>> BufferedImage bImage = new BufferedImage(width, height,
>>>>                                BufferedImage.TYPE_INT_RBG);

> I don't know anything about images types so I can't explain why
> TYPE_4BYTE_ABGR is not accepted...

> Cheers
> Benoit

> Le 30/01/08 12:40, « Yegor Kozlov » <yegor@dinom.ru> a écrit :

>> Works fine to me. Below is my test which produces a correct ppt.
>> 
>>       SlideShow ppt = new SlideShow();
>> 
>>       int width = 100, height = 100;
>>       BufferedImage bImage = new BufferedImage(width, height,
>> BufferedImage.TYPE_INT_RGB);
>>       Graphics2D g = bImage.createGraphics();
>>       g.setBackground(Color.white);
>>       g.clearRect(0, 0, width, height);
>>       g.setColor(Color.black);
>>       g.drawString("Hi there!", 20, 50);
>>       g.drawRect(10, 10, 80, 80);
>> 
>>       ByteArrayOutputStream bos = new ByteArrayOutputStream();
>> 
>>       JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(bos);
>>       JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bImage);
>>       param.setQuality(0.75f, false);
>>       encoder.setJPEGEncodeParam(param);
>>       encoder.encode(bImage);
>>       bos.close();
>> 
>>       int idx = ppt.addPicture(bos.toByteArray(), Picture.JPEG);
>>       Picture pict = new Picture(idx);
>>       pict.setAnchor(new java.awt.Rectangle(130, 70, width, height));
>> 
>>       Slide slide = ppt.createSlide();
>>       slide.addShape(pict);
>> 
>>       FileOutputStream out = new FileOutputStream("jpeg-test.ppt");
>>       ppt.write(out);
>>       out.close();
>> 
>> If the problem persists, can you create a bug in bugzilla and post a
>> sample code demonstrating the problem.
>>       
>> Regards,
>> Yegor
>>       
>>> Hello,
>> 
>>> I've got trouvbles while inserting a JPEG image in my presentation.
>>> Although i succeded in inserting other JPEG images (not home made), I've got
>>> a "red cross" instead of my image while trying to insert a home made JPEG
>>> image (made with Java of course)...
>> 
>>> Here is my code for creation of the JPEG image :
>>>> BufferedImage bImage = new BufferedImage(width, height,
>>>>                                BufferedImage.TYPE_4BYTE_ABGR);
>>>> Graphics2D g = bImage.createGraphics();
>>>> // Then I draw into my Graphics2D
>>>> // [...]
>>>> try {
>>>>    FileOutputStream out = new FileOutputStream(outPath);
>>>>    JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
>>>>    JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bImage);
>>>>    param.setQuality(0.75f, false);
>>>>    encoder.setJPEGEncodeParam(param);
>>>>    encoder.encode(bImage);
>>>>    out.close();
>>>>  } catch (IOException e) {
>>>>      e.printStackTrace();
>>>>  }
>> 
>>> I then insert it like this :
>>>> int idx = ppt.addPicture(new File("myImage.jpg"), Picture.JPEG);
>>>> Picture pict = new Picture(idx);
>>>> pict.setAnchor(new java.awt.Rectangle(130, 70, 200, 100));
>>>> slides[i].addShape(pict);
>> 
>>> And as I said it before, the result is a red cross instead of the image.
>>> I guess there are limitations dealing with pictures properties... Maybe
>>> something wrong with the BufferedImage type ?
>> 
>>> Has someone any idea to solve this problem ?
>> 
>>> Thanks a lot
>>> Benoit
>> 
>> 
>>> This email contains confidential and proprietary information some or all of
>>> which may be legally privileged. It is for the intended recipient only.
>>> If you have received this email in error, please notify the author
>>> immediately by telephone or by replying to this email. If you are not the
>>> intended recipient you must not use, disclose, distribute, copy, print, or
>>> rely on this email.
>>>  
>> 
>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
>>> For additional commands, e-mail: user-help@poi.apache.org
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
>> For additional commands, e-mail: user-help@poi.apache.org
>> 
>> 



> This email contains confidential and proprietary information some or all of
> which may be legally privileged. It is for the intended recipient only.
> If you have received this email in error, please notify the author
> immediately by telephone or by replying to this email. If you are not the
> intended recipient you must not use, disclose, distribute, copy, print, or
> rely on this email.



> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Mime
View raw message