Creating BufferedImage from Image
I've figured out one way to create a BufferedImage from an Image, but I'm sure it's not the best way.Image im = Toolkit.getDefaultToolkit().getImage(files.getAbsolutePath());
JLabel jl = new JLabel(new ImageIcon(im));
BufferedImage bim = new BufferedImage(im.getWidth(null), im.getHeight(null), BufferedImage.TYPE_BYTE_INDEXED);
Graphics g = bim.getGraphics();
jl.paint(bim.getGraphics());
This works, but I'm sure there has to be a better/easier way. Any suggestions?
Thanks,
m
close, the best way is this...
public BufferedImage createBufferedImage(Image img)
BufferedImage bimg = new BufferedImage(img.getWidth(null),img.getHeight(null),BufferedImage.TYPE_INT_RGB);//or whatever type is appropriate
bimg.getGraphics().drawImage(img,0,0,null);
return bimg;
}
Similar Messages
-
Illustrator script to create symbols from images in folder
Time to give back to the community...
Here is a script I recently devised to bulk create symbols from images in a folder. Tested with Illustrator CC 2014.
// Import Folder's Files as Symbols - Illustrator CC script
// Description: Creates symbols from images in the designated folder into current document
// Author : Oscar Rines (oscarrines (at) gmail.com)
// Version : 1.0.0 on 2014-09-21
// Reused code from "Import Folder's Files as Layers - Illustrator CS3 script"
// by Nathaniel V. KELSO ([email protected])
#target illustrator
function getFolder() {
return Folder.selectDialog('Please select the folder to be imported:', Folder('~'));
function symbolExists(seekInDoc, seekSymbol) {
for (var j=0; j < seekInDoc.symbols.length; j++) {
if (seekInDoc.symbols[j].name == seekSymbol) {
return true;
return false;
function importFolderContents(selectedFolder) {
var activeDoc = app.activeDocument; //Active object reference
// if a folder was selected continue with action, otherwise quit
if (selectedFolder) {
var newsymbol; //Symbol object reference
var placedart; //PlacedItem object reference
var fname; //File name
var sname; //Symbol name
var symbolcount = 0; //Number of symbols added
var templayer = activeDoc.layers.add(); //Create a new temporary layer
templayer.name = "Temporary layer"
var imageList = selectedFolder.getFiles(); //retrieve files in the folder
// Create a palette-type window (a modeless or floating dialog),
var win = new Window("palette", "SnpCreateProgressBar", {x:100, y:100, width:750, height:310});
win.pnl = win.add("panel", [10, 10, 740, 255], "Progress"); //add a panel to contain the components
win.pnl.currentTaskLabel = win.pnl.add("statictext", [10, 18, 620, 33], "Examining: -"); //label indicating current file being examined
win.pnl.progBarLabel = win.pnl.add("statictext", [620, 18, 720, 33], "0/0"); //progress bar label
win.pnl.progBarLabel.justify = 'right';
win.pnl.progBar = win.pnl.add("progressbar", [10, 35, 720, 60], 0, imageList.length-1); //progress bar
win.pnl.symbolCount = win.pnl.add("statictext", [10, 70, 710, 85], "Symbols added: 0"); //label indicating number of symbols created
win.pnl.symbolLabel = win.pnl.add("statictext", [10, 85, 710, 100], "Last added symbol: -"); //label indicating name of the symbol created
win.pnl.errorListLabel = win.pnl.add("statictext", [10, 110, 720, 125], "Error log:"); //progress bar label
win.pnl.errorList = win.pnl.add ("edittext", [10, 125, 720, 225], "", {multiline: true, scrolling: true}); //errorlist
//win.pnl.errorList.graphics.font = ScriptUI.newFont ("Arial", "REGULAR", 7);
//win.pnl.errorList.graphics.foregroundColor = win.pnl.errorList.graphics.newPen(ScriptUIGraphics.PenType.SOLID_COLOR, [1, 0, 0, 1], 1);
win.doneButton = win.add("button", [640, 265, 740, 295], "OK"); //button to dispose the panel
win.doneButton.onClick = function () //define behavior for the "Done" button
win.close();
win.center();
win.show();
//Iterate images
for (var i = 0; i < imageList.length; i++) {
win.pnl.currentTaskLabel.text = 'Examining: ' + imageList[i].name; //update current file indicator
win.pnl.progBarLabel.text = i+1 + '/' + imageList.length; //update file count
win.pnl.progBar.value = i+1; //update progress bar
if (imageList[i] instanceof File) {
fname = imageList[i].name.toLowerCase(); //convert file name to lowercase to check for supported formats
if( (fname.indexOf('.eps') == -1) &&
(fname.indexOf('.png') == -1)) {
win.pnl.errorList.text += 'Skipping ' + imageList[i].name + '. Not a supported type.\r'; //log error
continue; // skip unsupported formats
else {
sname = imageList[i].name.substring(0, imageList[i].name.lastIndexOf(".") ); //discard file extension
// Check for duplicate symbol name;
if (symbolExists(activeDoc, sname)) {
win.pnl.errorList.text += 'Skipping ' + imageList[i].name + '. Duplicate symbol for name: ' + sname + '\r'; //log error
else {
placedart = activeDoc.placedItems.add(); //get a reference to a new placedItem object
placedart.file = imageList[i]; //link the object to the image on disk
placedart.name = sname; //give the placed item a name
placedart.embed(); //make this a RasterItem
placedart = activeDoc.rasterItems.getByName(sname); //get a reference to the newly created raster item
newsymbol = activeDoc.symbols.add(placedart); //add the raster item to the symbols
newsymbol.name = sname; //name the symbol
symbolcount++; //update the count of symbols created
placedart.remove(); //remove the raster item from the canvas
win.pnl.symbolCount.text = 'Symbols added: ' + symbolcount; //update created number of symbols indicator
win.pnl.symbolLabel.text = 'Last added symbol: ' + sname; //update created symbol indicator
else {
win.pnl.errorList.text += 'Skipping ' + imageList[i].name + '. Not a regular file.\r'; //log error
win.update(); //required so pop-up window content updates are shown
win.pnl.currentTaskLabel.text = ''; //clear current file indicator
// Final verdict
if (symbolcount >0) {
win.pnl.symbolLabel.text = 'Symbol library changed. Do not forget to save your work';
else {
win.pnl.symbolLabel.text = 'No new symbols added to the library';
win.update(); //update window contents
templayer.remove(); //remove the temporary layer
else {
alert("Action cancelled by user");
if ( app.documents.length > 0 ) {
importFolderContents( getFolder() );
else{
Window.alert("You must open at least one document.");Thank you, nice job & I am looking forward to trying it out!
-
Creating bufferedimage from scene in different resolution than the Canvas?
Is it possible to create a bufferedimage from a Canvas, but with a higher resolution without loosing image quality?
Need to take high-quality screenshots of the 3d-scene.
Thanks.I'm trying to back up and simultaneously organize my photos from my Mac OS 10.8.5 by dragging groups of photos from iPhoto to an external HD.
One more thought - if you want to backup your photos, why not simply copy your iPhoto Library to the external drive? That would save your photos as well as the work you invested in editing and tagging them.
If you do the backup by storing only the photos on your external drive, you need to export all edited photos twice - first the original photo like described in Old Toad's screenshot, and then the edited version as well, or you will lose your editing work, if you need your backup.
Copying the iPhoto Library would save all in one, without too much trouble.
Your second goal, reorganizing, could be done directly in iPhoto. -
I am trying to make video from images
here is my program
import java.awt.Dimension;
import java.awt.Image;
import javax.media.*;
import javax.media.control.*;
import javax.media.protocol.*;
import javax.media.protocol.DataSource;
import javax.media.datasink.*;
import javax.media.format.VideoFormat;
import javax.media.util.ImageToBuffer;
import java.io.*;
import java.util.*;
*For AVI files, each frame must have a time stamp set. See the following message from the jmf-interest archives for details:
http://archives.java.sun.com/cgi-bin/wa?A2=ind0107&L=jmf-interest&P=R34660
public class AviCreator implements ControllerListener, DataSinkListener
private boolean doIt(
int width,
int height,
int frameRate,
MediaLocator outML)
File folder=new File("c:/images1");
File [] files=folder.listFiles();
ImageDataSource ids = new ImageDataSource(width, height, frameRate,files);
Processor p;
try
System.err.println(
"- create processor for the image datasource ...");
p = Manager.createProcessor(ids);
catch (Exception e)
System.err.println(
"Yikes! Cannot create a processor from the data source.");
return false;
p.addControllerListener(this);
// Put the Processor into configured state so we can set
// some processing options on the processor.
p.configure();
if (!waitForState(p, Processor.Configured))
System.err.println("Failed to configure the processor.");
return false;
// Set the output content descriptor to QuickTime.
p.setContentDescriptor(
new ContentDescriptor(FileTypeDescriptor.MSVIDEO));
// Query for the processor for supported formats.
// Then set it on the processor.
TrackControl tcs[] = p.getTrackControls();
Format f[] = tcs[0].getSupportedFormats();
if (f == null || f.length <= 0)
System.err.println(
"The mux does not support the input format: "
+ tcs[0].getFormat());
return false;
tcs[0].setFormat(f[0]);
System.err.println("Setting the track format to: " + f[0]);
// We are done with programming the processor. Let's just
// realize it.
p.realize();
if (!waitForState(p, Processor.Realized))
System.err.println("Failed to realize the processor.");
return false;
// Now, we'll need to create a DataSink.
DataSink dsink;
if ((dsink = createDataSink(p, outML)) == null)
System.err.println(
"Failed to create a DataSink for the given output MediaLocator: "
+ outML);
return false;
dsink.addDataSinkListener(this);
fileDone = false;
System.err.println("start processing...");
// OK, we can now start the actual transcoding.
try
p.start();
dsink.start();
catch (IOException e)
System.err.println("IO error during processing");
return false;
// Wait for EndOfStream event.
waitForFileDone();
// Cleanup.
try
dsink.close();
catch (Exception e)
p.removeControllerListener(this);
System.err.println("...done processing.");
return true;
* Create the DataSink.
private DataSink createDataSink(Processor p, MediaLocator outML)
DataSource ds;
if ((ds = p.getDataOutput()) == null)
System.err.println(
"Something is really wrong: the processor does not have an output DataSource");
return null;
DataSink dsink;
try
System.err.println("- create DataSink for: " + outML);
dsink = Manager.createDataSink(ds, outML);
dsink.open();
catch (Exception e)
System.err.println("Cannot create the DataSink: " + e);
return null;
return dsink;
private Object waitSync = new Object();
private boolean stateTransitionOK = true;
* Block until the processor has transitioned to the given state.
* Return false if the transition failed.
private boolean waitForState(Processor p, int state)
synchronized (waitSync)
try
while (p.getState() < state && stateTransitionOK)
waitSync.wait();
catch (Exception e)
return stateTransitionOK;
* Controller Listener.
public void controllerUpdate(ControllerEvent evt)
if (evt instanceof ConfigureCompleteEvent
|| evt instanceof RealizeCompleteEvent
|| evt instanceof PrefetchCompleteEvent)
synchronized (waitSync)
stateTransitionOK = true;
waitSync.notifyAll();
else if (evt instanceof ResourceUnavailableEvent)
synchronized (waitSync)
stateTransitionOK = false;
waitSync.notifyAll();
else if (evt instanceof EndOfMediaEvent)
evt.getSourceController().stop();
evt.getSourceController().close();
private Object waitFileSync = new Object();
private boolean fileDone = false;
private boolean fileSuccess = true;
* Block until file writing is done.
private boolean waitForFileDone()
synchronized (waitFileSync)
try
while (!fileDone)
waitFileSync.wait();
catch (Exception e)
return fileSuccess;
* Event handler for the file writer.
public void dataSinkUpdate(DataSinkEvent evt)
if (evt instanceof EndOfStreamEvent)
synchronized (waitFileSync)
fileDone = true;
waitFileSync.notifyAll();
else if (evt instanceof DataSinkErrorEvent)
synchronized (waitFileSync)
fileDone = true;
fileSuccess = false;
waitFileSync.notifyAll();
public static String[] createParam()
File folder=new File("c:/images1");
String [] files=folder.list();
String param[]=new String[files.length+8];
param[0]="-w";
param[1]="400";
param[2]="-h";
param[3]="300";
param[4]="-f";
param[5]="1";
param[6]="-o";
param[7]="file:/c:/images/abc.avi";
for(int i=8;i<files.length+8;i++)
param="file:/c:/images1/"+files[i-8];
return param;
public static void main(String args1[]) throws Exception
//jpegCreator.main(null);
//if (args.length == 0)
// prUsage();
//String [] args ={"-w","320" ,"-h","240", "-f","1", "-o", "file:/c:/images/abc.mov","file:/c:/images/surya_jo1.jpg", "file:/c:/temp/flower1_jpg.jpg" };
String [] args=createParam();
// Parse the arguments.
int i = 0;
int width = -1, height = -1, frameRate = 1;
Vector inputFiles = new Vector();
inputFiles.add("file:/c:/images/surya_jo1.jpg");
inputFiles.add("file:/c:/images/flower1_jpg.jpg");
String outputURL = null;
width = 128;
height = 128;
outputURL = "file:/c:/images/abc.avi";
// Generate the output media locators.
MediaLocator oml;
if ((oml = createMediaLocator(outputURL)) == null)
System.err.println("Cannot build media locator from: " + outputURL);
System.exit(0);
AviCreator imageToMovie = new AviCreator();
imageToMovie.doIt(width, height, frameRate, oml);
System.exit(0);
static void prUsage()
System.err.println(
"Usage: java JpegImagesToMovie -w <width> -h <height> -f <frame rate> -o <output URL> <input JPEG file 1> <input JPEG file 2> ...");
System.exit(-1);
* Create a media locator from the given string.
private static MediaLocator createMediaLocator(String url)
MediaLocator ml;
if (url.indexOf(":") > 0 && (ml = new MediaLocator(url)) != null)
return ml;
if (url.startsWith(File.separator))
if ((ml = new MediaLocator("file:" + url)) != null)
return ml;
else
String file =
"file:" + System.getProperty("user.dir") + File.separator + url;
if ((ml = new MediaLocator(file)) != null)
return ml;
return null;
// Inner classes.
* A DataSource to read from a list of JPEG image files and
* turn that into a stream of JMF buffers.
* The DataSource is not seekable or positionable.
/************************************************* private class ImageDataSource extends PullBufferDataSource
private ImageSourceStream streams[];
ImageDataSource(int width, int height, int frameRate)
streams = new ImageSourceStream[1];
streams[0] = new ImageSourceStream(width, height, frameRate);
public void setLocator(MediaLocator source)
public MediaLocator getLocator()
return null;
public String getContentType()
return ContentDescriptor.RAW;
public void connect()
public void disconnect()
public void start()
public void stop()
public PullBufferStream[] getStreams()
return streams;
public Time getDuration()
System.out.println("dur is " + streams[0].nextImage);
//return new Time(1000000000);
return DURATION_UNKNOWN;
public Object[] getControls()
return new Object[0];
public Object getControl(String type)
return null;
* A DataSource to read from a list of JPEG image files or
* java.awt.Images, and
* turn that into a stream of JMF buffers.
* The DataSource is not seekable or positionable.
private static class ImageDataSource extends PullBufferDataSource {
private final Time durTime;
private final PullBufferStream[] streams = new JpegSourceStream[1];
* Constructor for creating movies out of jpegs
ImageDataSource(int width, int height, int frameRate, File[] jpegFiles) {
streams[0] = new JpegSourceStream(width, height, frameRate, jpegFiles);
this.durTime = new Time(jpegFiles.length / frameRate);
* Constructor for creating movies out of Images
* NOTE - this is all done IN MEMORY, so you'd better have enough
/*ImageDataSource(int width, int height, int frameRate, Image[] images) {
streams[0] = new AWTImageSourceStream(width, height, frameRate, images);
this.durTime = new Time(images.length / frameRate);
public void setLocator(MediaLocator source) {
public MediaLocator getLocator() {
return null;
* Content type is of RAW since we are sending buffers of video
* frames without a container format.
public String getContentType() {
return ContentDescriptor.RAW;
public void connect() {
public void disconnect() {
public void start() {
public void stop() {
* Return the ImageSourceStreams.
public PullBufferStream[] getStreams() {
return streams;
public Time getDuration() {
return durTime;
public Object[] getControls() {
return new Object[0];
public Object getControl(String type) {
return null;
* The jpeg-based source stream to go along with ImageDataSource.
private static class JpegSourceStream implements PullBufferStream {
private final File[] jpegFiles;
private final int width, height;
private final VideoFormat videoFormat;
private int nextImage = 0; // index of the next image to be read.
private boolean ended = false;
// Bug fix from Forums - next one line
long seqNo = 0;
public JpegSourceStream(int width, int height, int frameRate, File[] jpegFiles) {
this.width = width;
this.height = height;
this.jpegFiles = jpegFiles;
this.videoFormat = new VideoFormat(VideoFormat.JPEG,
new Dimension(width, height),
Format.NOT_SPECIFIED,
Format.byteArray,
(float)frameRate);
* We should never need to block assuming data are read from files.
public boolean willReadBlock() {
return false;
* This is called from the Processor to read a frame worth
* of video data.
public void read(final Buffer buf) {
try {
// Check if we've finished all the frames.
if (nextImage >= jpegFiles.length) {
// We are done. Set EndOfMedia.
System.out.println("Done reading all images.");
buf.setEOM(true);
buf.setOffset(0);
buf.setLength(0);
ended = true;
return;
File imageFile = jpegFiles[nextImage];
nextImage++;
System.out.println(" - reading image file: " + imageFile);
// Open a random access file for the next image.
RandomAccessFile raFile = new RandomAccessFile(imageFile, "r");
byte[] data = (byte[])buf.getData();
// Check to see the given buffer is big enough for the frame.
if (data == null || data.length < raFile.length()) {
// allocate larger buffer
data = new byte[(int)raFile.length()];
buf.setData(data);
// Read the entire JPEG image from the file.
raFile.readFully(data, 0, (int)raFile.length());
System.out.println(" read " + raFile.length() + " bytes.");
// Bug fix for AVI files from Forums ( next 3 lines).
long time = (long) (seqNo * (1000 / videoFormat.getFrameRate()) * 1000000);
buf.setTimeStamp(time);
buf.setSequenceNumber(seqNo++);
buf.setOffset(0);
buf.setLength((int)raFile.length());
buf.setFormat(videoFormat);
buf.setFlags(buf.getFlags() | buf.FLAG_KEY_FRAME);
// Close the random access file.
raFile.close();
} catch (Exception e) {
// it's important to print the stack trace here because the
// sun class that calls this method silently ignores
// any IOExceptions that get thrown
e.printStackTrace();
throw new RuntimeException(e);
* Return the format of each video frame. That will be JPEG.
public Format getFormat() {
return videoFormat;
public ContentDescriptor getContentDescriptor() {
return new ContentDescriptor(ContentDescriptor.RAW);
public long getContentLength() {
return LENGTH_UNKNOWN;
public boolean endOfStream() {
return ended;
public Object[] getControls() {
return new Object[0];
public Object getControl(String type) {
return null;
* The source stream to go along with ImageDataSource.
/*************************************************************** class ImageSourceStream implements PullBufferStream
final int width, height;
final VideoFormat format;
// Bug fix from Forums - next two lines
float frameRate;
long seqNo = 0;
int nextImage = 0; // index of the next image to be read.
boolean ended = false;
public ImageSourceStream(int width, int height, int frameRate)
this.width = width;
this.height = height;
// Bug fix from Forums (next line)
this.frameRate = (float) frameRate;
final int rMask = 0x00ff0000;
final int gMask = 0x0000FF00;
final int bMask = 0x000000ff;
format =
new javax.media.format.RGBFormat(
new Dimension(width, height),
Format.NOT_SPECIFIED,
Format.intArray,
frameRate,
32,
rMask,
gMask,
bMask);
public boolean willReadBlock()
return false;
public void read(Buffer buf) throws IOException
// Check if we've finished all the frames.
if (nextImage >= 100)
// We are done. Set EndOfMedia.
System.err.println("Done reading all images.");
buf.setEOM(true);
buf.setOffset(0);
buf.setLength(0);
ended = true;
return;
nextImage++;
int data[] = null;
// Check the input buffer type & size.
if (buf.getData() instanceof int[])
data = (int[]) buf.getData();
// Check to see the given buffer is big enough for the frame.
if (data == null || data.length < width * height)
data = new int[width * height];
buf.setData(data);
// Bug fix from Forums ( next 3 lines).
long time = (long) (seqNo * (1000 / frameRate) * 1000000);
buf.setTimeStamp(time);
buf.setSequenceNumber(seqNo++);
java.awt.Color clr = java.awt.Color.red;
if (nextImage > 30)
clr = java.awt.Color.GREEN;
if (nextImage > 60)
clr = java.awt.Color.BLUE;
for (int i = 0; i < width * height; i++)
// TODO - figure what the guy was trying to do here.
data[i] = clr.getRGB();
buf.setOffset(0);
buf.setLength(width * height);
buf.setFormat(format);
buf.setFlags(buf.getFlags() | Buffer.FLAG_KEY_FRAME);
public Format getFormat()
return format;
public ContentDescriptor getContentDescriptor()
return new ContentDescriptor(ContentDescriptor.RAW);
public long getContentLength()
return 0;
public boolean endOfStream()
return ended;
public Object[] getControls()
return new Object[0];
public Object getControl(String type)
return null;
* The java.awt.Image-based source stream to go along with ImageDataSource.
* Not sure yet if this class works.
private static class AWTImageSourceStream implements PullBufferStream {
private final Image[] images;
private final int width, height;
private final VideoFormat videoFormat;
private int nextImage = 0; // index of the next image to be read.
private boolean ended = false;
// Bug fix from Forums - next one line
private long seqNo = 0;
public AWTImageSourceStream(int width, int height, int frameRate, Image[] images) {
this.width = width;
this.height = height;
this.images = images;
// not sure if this is correct, especially the VideoFormat value
this.videoFormat = new VideoFormat(VideoFormat.RGB,
new Dimension(width, height),
Format.NOT_SPECIFIED,
Format.byteArray,
(float)frameRate);
* We should never need to block assuming data are read from files.
public boolean willReadBlock() {
return false;
* This is called from the Processor to read a frame worth
* of video data.
public void read(final Buffer buf) throws IOException {
try {
// Check if we've finished all the frames.
if (nextImage >= images.length) {
// We are done. Set EndOfMedia.
System.out.println("Done reading all images.");
buf.setEOM(true);
buf.setOffset(0);
buf.setLength(0);
ended = true;
return;
Image image = images[nextImage];
nextImage++;
// Open a random access file for the next image.
//RandomAccessFile raFile = new RandomAccessFile(imageFile, "r");
Buffer myBuffer = ImageToBuffer.createBuffer(image, videoFormat.getFrameRate());
buf.copy(myBuffer);
// Bug fix for AVI files from Forums ( next 3 lines).
long time = (long) (seqNo * (1000 / videoFormat.getFrameRate()) * 1000000);
buf.setTimeStamp(time);
buf.setSequenceNumber(seqNo++);
//buf.setOffset(0);
//buf.setLength((int)raFile.length());
//buf.setFormat(videoFormat);
//buf.setFlags(buf.getFlags() | buf.FLAG_KEY_FRAME);
} catch (Exception e) {
// it's important to print the stack trace here because the
// sun class that calls this method silently ignores
// any Exceptions that get thrown
e.printStackTrace();
throw new RuntimeException(e);
* Return the format of each video frame.
public Format getFormat() {
return videoFormat;
public ContentDescriptor getContentDescriptor() {
return new ContentDescriptor(ContentDescriptor.RAW);
public long getContentLength() {
return LENGTH_UNKNOWN;
public boolean endOfStream() {
return ended;
public Object[] getControls() {
return new Object[0];
public Object getControl(String type) {
return null;
bit i am getting following exception at run time
1
2
3
4
5
6
- create processor for the image datasource ...
Setting the track format to: JPEG
- create DataSink for: file:/c:/images/abc.mov
start processing...
- reading image file: file:/c:/images/surya_jo1.jpg
- reading image file: file:/c:/images/flower1_jpg.jpg
Done reading all images.
Exception in thread "JMF thread: SendEventQueue: com.sun.media.processor.unknown.Handler" java.lang.NullPointerException
at com.sun.media.multiplexer.video.QuicktimeMux.writeVideoSampleDescription(QuicktimeMux.java:936)
at com.sun.media.multiplexer.video.QuicktimeMux.writeSTSD(QuicktimeMux.java:925)
at com.sun.media.multiplexer.video.QuicktimeMux.writeSTBL(QuicktimeMux.java:905)
at com.sun.media.multiplexer.video.QuicktimeMux.writeMINF(QuicktimeMux.java:806)
at com.sun.media.multiplexer.video.QuicktimeMux.writeMDIA(QuicktimeMux.java:727)
at com.sun.media.multiplexer.video.QuicktimeMux.writeTRAK(QuicktimeMux.java:644)
at com.sun.media.multiplexer.video.QuicktimeMux.writeMOOV(QuicktimeMux.java:582)
at com.sun.media.multiplexer.video.QuicktimeMux.writeFooter(QuicktimeMux.java:519)
at com.sun.media.multiplexer.BasicMux.close(BasicMux.java:142)
at com.sun.media.BasicMuxModule.doClose(BasicMuxModule.java:172)
at com.sun.media.PlaybackEngine.doClose(PlaybackEngine.java:872)
at com.sun.media.BasicController.close(BasicController.java:261)
at com.sun.media.BasicPlayer.doClose(BasicPlayer.java:229)
at com.sun.media.BasicController.close(BasicController.java:261)
at JpegImagesToMovie.controllerUpdate(JpegImagesToMovie.java:196)
at com.sun.media.BasicController.dispatchEvent(BasicController.java:1254)
at com.sun.media.SendEventQueue.processEvent(BasicController.java:1286)
at com.sun.media.util.ThreadedEventQueue.dispatchEvents(ThreadedEventQueue.java:65)
at com.sun.media.util.ThreadedEventQueue.run(ThreadedEventQueue.java:92)
plz help me
thanks in advanceStep 1) Copy that code into a .java file
Step 2) Compile it
Step 3) Run it
Step 4) Look at the output
Step 5 (optional)) If it didn't work, post a specific question about the code, and use [co[b]de] tags. -
Can we create thumbnail from a image in Oracle 11g database?
The image is stored as blob secure file in oracle 11g database.
What is the difference between blob and ORDImage?
Can I create thumbnail from a image and store it in the database? -
Creating BufferedImage from int[] (not RGB's)
Hi,
I have an int[] that contains how many intersections occur between each pixel and a series of overlapping rectangles. So the array would look like this:
int [] intersections = { 0,1,1,1,1,0,2,4,4...etc} each number representing the number of times each pixel intersects a rectangle.
What I would like to do is create a bufferedImage where each pixel in the image is a color based on the number of intersections from the array. 0 intersections is transparent, 1 intersection is a blue pixel , 2 intersections is green etc.
I implemented it first looping through the array and painting a 1X1 rectangle colored according to the number of intersections but it is slow. Can I use a ColorModel for this (never used one)?. If so, what is a good method to convert these integers that represent the number of intersections to the corresponding color in a BufferedImage? The maximum number of intersections would be far fewer than 256, probably in the range of 10-50. I would also like to create the image in grayscale, the larger number of intersections getting darker and as hues of one color where an index of 0 would be transparent and as the number of intersections got larger the color gets darker. It all works the way I did it but it is way too slow. Will a ColorModel do transparent pixels? Is MemorySourceImage a good way to do this? Any ideas?
Thanks very much!
PaulYou're more or less describing a IndexColorModel, except the data bank is usually a byte[]:
import java.awt.*;
import java.awt.image.*;
import java.util.*;
import javax.swing.*;
public class IndexColorModelTest {
public static void main(String[] args) {
int w = 300, h = 200;
BufferedImage bi = createImage(w, h, createData(w, h));
JLabel label = new JLabel(new ImageIcon(bi));
label.setOpaque(true);
label.setBackground(Color.RED);
final JFrame f = new JFrame("IndexColorModelTest");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(label);
f.pack();
SwingUtilities.invokeLater(new Runnable(){
public void run() {
f.setLocationRelativeTo(null);
f.setVisible(true);
static byte[] createData(int w, int h) {
byte[] data = new byte[w*h];
new Random().nextBytes(data);
return data;
static BufferedImage createImage(int w, int h, byte[] data) {
//create a color model with grays
int SIZE = 256;
byte[] gray = new byte[SIZE];
for(int i=0; i<256; ++i)
gray[i] = (byte) i;
ColorModel cm = new IndexColorModel(8, SIZE, gray, gray, gray, 0); //0 is transparent pixel
DataBuffer db = new DataBufferByte(data, w*h);
WritableRaster r = Raster.createInterleavedRaster(db, w, h, w, 1, new int[]{0}, null);
return new BufferedImage(cm, r, false, null);
} -
Javascript to create vector from image and save as eps
Hi,
I started writing a script which open all images in a folder and i need to turn those into vectors.
How do i write the following in JavaScript:
Open the JPG file
Select the image layer/object
Create a vector from the image using the Image Trace for high fidelity
Reduce the new vector objec size by %50.
save as eps
any help with any of the stages would be very helpful.
thank youPERFECT!!!!!!
This is exactly what I was going to build. No need to create when it is already done.
Thank you very much.
-Mike -
Unusual Bug when creating pdf from image files
Hi I have a very mindboggling problem which I cant seem to get my head around.
basically I am trying to create a pdf using a large amount of image files, these images are scans of pages of a book. so I have been trying to create a pdf file from these images, and everytime i try, it all looks ok except for one page which comes up smaller in size than the rest which is a big problem and very unusual. If I change the view of acrobat so that it shows two pages at a time then this is clearly visable where one page is normal and the page next to it is like a third of the size. Ive checked the image file properties for that page and they are more or less the same as the rest, the dimensions of the image file too, but when I add it into a PDF it seems to shrink in size, any ideas as to why? any help would be much appreciated! (and I hope what I said made sense lol )
Thanks
NavHi Davew000
Can you please tell the steps you are doing to create the PDF ?
Thanks,
Tanvi -
Creating ImageIcon from Image is very slow
Hi I have a program which reads a number of files which may contain (amongst other things) image data in various formats such as JPG.I read scale this down into an image object fine, and then I want to display a small version of it on screen so I put the scale dimage into an ImageIcon which i display later using a JLabel.
Anyway it runs very slow , the funny thing is using JProbe Ive tracked the problem down to creation of the ImageIcon constructor, the actual thumbnail image creation is very quick.
Why does ImageIcon take so long or is there a simple way of displaying the image in a Swing Application
without using JLabel.
BufferedImage bi = ImageIO.read(new DataInputStream(new ByteArrayInputStream(imageData)));
Image thumbnaiImage = image.getScaledInstance(20,20Image.SCALE_FAST);
ImageIcon thumbnail = new ImageIcon(thumbnailImage);If you're not too picky about the image quality (and I see you're using SCALE_FAST), you can set the
source subsampling on your ImageReadParam so that you never construct the large image: you start
with the thumbnail.
import java.awt.*;
import java.awt.image.*;
import java.io.*;
import java.net.*;
import java.util.*;
import javax.imageio.*;
import javax.swing.*;
public class AllThumbs {
public static void main(String[] args) throws MalformedURLException {
String prefix = "http://www3.us.porsche.com/english/usa/carreragt/modelinformation/experience/desktop/bilder/icon";
String suffix = "_800x600.jpg";
JPanel p = new JPanel(new GridLayout(0,3));
for(int i=1; i<9; ++i) {
try {
p.add(getThumb(new URL(prefix + i + suffix), 200, 150));
} catch (IOException e) {
System.out.println(e.getMessage());
JFrame f = new JFrame("AllThumbs");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(p);
f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true);
public static JLabel getThumb(URL url, int maxWidth, int maxHeight) throws IOException {
String suffix = getSuffix(url);
Iterator readers = ImageIO.getImageReadersBySuffix(suffix);
if (!readers.hasNext())
throw new IOException("No reader for suffix " + suffix);
ImageReader reader = (ImageReader) readers.next();
reader.setInput(ImageIO.createImageInputStream(url.openStream()), true, true);
int w = reader.getWidth(0), h = reader.getHeight(0);
int subsampling = Math.max(1, Math.max(w/maxWidth, h/maxHeight));
ImageReadParam param = reader.getDefaultReadParam();
param.setSourceSubsampling(subsampling, subsampling, 0, 0);
BufferedImage image = reader.read(0, param);
String path = url.getPath();
String text = path.substring(1+path.lastIndexOf('/'));
JLabel label = new JLabel(text, new ImageIcon(image), SwingConstants.CENTER);
label.setHorizontalTextPosition(SwingConstants.CENTER);
label.setVerticalTextPosition(SwingConstants.BOTTOM);
label.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
return label;
public static String getSuffix(URL url) throws IOException {
String path = url.getPath();
int dot = path.lastIndexOf('.');
if (dot == -1)
throw new IOException("No . in " + path);
return path.substring(1+dot);
}It is also possible for there to be thumbnail images stored in an image file. (These thumbnails
don't even have to be related to the main image.) ImageIO has methods to read these directly,
so if you have control over your image files you can create them with thumbnails in place. -
Unable to create cd from Image file
I downloaded the Solaris 8 for Intel, unzipped the files. I have been unsuccessful creating an image file for the file sol-8-1_01-fcs-bin-ia-v1. I have tried various CD writing applications.
I was able to create images from the other files.
ThanksYou are not supposed to create an image file from the unzipped data. These unzipped files are image
files! You just have to rename them using the proper file extension so that your CD-R burning software
recognizes them as cd image files. (common extension are .ISO or .RAW; check with your CD recording
software) -
Any applications to batch create qts from image sequences.
I've got about 15 tiff image sequences that I've got to creates qts of. QTPro does a great job, but it would be great if I could just drag all the folders to an application that would do all the grunt work for me (hey I know, I'm a lazy so and so and this kind of task happens every month or so).
I am sure this is something an Apple Script could do.
I had someone create something for me recently to do a similar thing. Afraid I cant help, you would need to ask arounda to see if someone can compile one for you
theres also an Apple Script discussion here:
http://discussions.apple.com/forum.jspa?forumID=724
Gary -
Trying to Create Cone from Image
I am attempting to take a circular image (a logo of something) and edit it so that it can be printed and turned into a small cone. I have spent HOURS researching this and cannot seem to find the the problem. I've followed the steps below (found on a tutorial at another website) and the gap (where the circle gets slid under itself to create the cone shape) is so small. I have messed around with it since this morning and am at my wit's end. Thank you, in advance, for any assistance!
Let's consider my avatar as the original image. I make sure it is cropped into a circle.
Then in photoshop, I do Filter->Distort->Polar coordinates->Polar to rectangular:
Then, I resize the contents (but not the container [e.g. select all, edit->transform->scale]) of the image horizontally. The percentage I reduce is the percentage of degrees I will remove:
Finally, I go back to polar coordinates, and retrim as a circle: (OP: I don't know what they mean by "retrim as a circle," though, so I stop after selecting "rectangular to polar")
Wrapping the image around the removed wedge is an exercise left to the reader.Thank you for your reply, Nancy! I actually want to print this and then "assemble" it into a cone.
Here is the original tutorial. The original person was able to accomplish exactly what I want...I just can't figure out where I'm going wrong!
http://design.tutsplus.com/tutorials/illustrate-a-traffic-cone-icon-in-photoshop--psd-121 -
Hello,
I would like to know if it is possible to create an outline out of the image, instead of manually tracing with a pen, is it possible in Illustrator using some plugins to create the outline?
The image I'd like to do so with is this one:
http://25.media.tumblr.com/tumblr_mc1b233iBE1qerx9uo1_500.jpg
Basically would like the camo pieces to be outline one by one separately.
Thank you.Sorry for the brevity.
Make your tracing panel to these settings:
Then click on the Expand button.
Then Ungroup.
Then, draw a marquee or select on the edge where the next screen shot shows.
What will be selected is the outline of what would have been the White fill...then delete it.
Your pieces are all individual. You can select by color and group each color individually if desired. If you don't know how to do this, please look in the help. But in brief, select one colored item, Select menu, Same, Fill Color. This will make changing the color of all like-colored items easy.
Mike -
Kuler's Create colors from image not working
Whenever I try to create a color scheme from a photo, the
little spin graphic hangs and the percentage done gets stuck on 19%
or 31%. It's not working. Any help??Hi,
We were experiencing issues with one of our servers
yesterday. It should all be working now. Please let us know if
you're still experiencing the same problems.
Thanks,
The Kuler Team -
New release! Create themes from images and more
It's a new release of kuler!
- Try color extraction, a new feature to create themes using
photos and other images, with different "mood" options.
- You've requested it, here at last: endless favorites. Save
all that color goodness to Mykuler.
- Random browsing: Try your luck and see what randomly
selected themes kuler serves up.
We've made a few other tweaks, I'll let you discover them for
yourselves. Please post your feedback here; we're especially
curious about color extraction and how this creative group will put
it to use. Enjoy, folks!
the kuler teamAwesome, Sami! I haven't tried the site yet, but the new AIR
extension is
great. I'll try out the site .. soon .. and give some
feedback. Terrific
so far!
Nancy Gill
Adobe Community Expert
Author: Dreamweaver 8 e-book for the DMX Zone
Co-Author: Dreamweaver MX: Instant Troubleshooter (August,
2003)
Technical Editor: Dreamweaver CS3: The Missing Manual,
DMX 2004: The Complete Reference, DMX 2004: A Beginner's
Guide
Mastering Macromedia Contribute
Technical Reviewer: Dynamic Dreamweaver MX/DMX: Advanced PHP
Web Development
"Sami Iwata" <[email protected]> wrote in
message
news:frpioi$mp3$[email protected]..
> It's a new release of kuler!
>
> - Try color extraction, a new feature to create themes
using photos and
> other
> images, with different "mood" options.
> - You've requested it, here at last: endless favorites.
Save all that
> color
> goodness to Mykuler.
> - Random browsing: Try your luck and see what randomly
selected themes
> kuler
> serves up.
>
> We've made a few other tweaks, I'll let you discover
them for yourselves.
> Please post your feedback here; we're especially curious
about color
> extraction
> and how this creative group will put it to use. Enjoy,
folks!
>
> the kuler team
>
Maybe you are looking for
-
[SOLVED] ISO C++ forbids declaration of 'linkedStackType' with no type
I got an error when building my program. The program was working fine for a while before showing this error: In file included from truck.cpp:1: truck.h:62: error: ISO C++ forbids declaration of 'linkedStackType' with no type truck.h:62: e
-
Safari not displaying lists properly as defined in CSS
I have been successfully using my .css file for a while on my website for work. Now I need to default to the 2nd level of ordered list as my first, but just for this page. However, Safari is showing it as 1st level ordered list even with override. Op
-
Help on analytical and hiererarchial queries
Hi, could any one please throw some light on the usage of analytical and hiererchial queries please.
-
What is business one ? how is it different from sap R/3,?
Does B1 needs special expertise in SAP ?can an R/3 consultant run the transactions and customisations in B1 with ease ?please answer my queries. REGARDS Sunkari
-
BC Forum - get rid of search text
Can BC please get rid of already written text "What can we help you with?" in the forum search bar, it gets in the way everytime we write up a question and stuffs up the search.