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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]