How do i save my drawing as an image file?

hiee
I have made a drawing panel on an Internal frame.
I can draw basic 2D shapes on it.
Now , i wanted to save this as an image file (ie.gif or jpeg).
How do i do that??

* SaveAsGif_Demo.java
* Created on 13 mars 2005, 11:26
import java.awt.*;
import java.awt.image.*;
import java.io.*;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.NoSuchElementException;
import javax.swing.*;
* @author  Andr� Uhres
public class SaveAsGif_Demo extends javax.swing.JFrame {
    /** Creates new form SaveAsGif_Demo */
    public SaveAsGif_Demo() {
        initComponents();
        myPanel = new MyPanel();
        getContentPane().add(myPanel, BorderLayout.CENTER);
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
    private void initComponents() {                         
        jToolBar1 = new javax.swing.JToolBar();
        jButton1 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Save as .gif Demo");
        jToolBar1.setFloatable(false);
        jButton1.setText("Save");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
        jToolBar1.add(jButton1);
        jToolBar1.add(jLabel1);
        getContentPane().add(jToolBar1, java.awt.BorderLayout.NORTH);
        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-400)/2, (screenSize.height-300)/2, 400, 300);
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
        File file = new File("c:\\test.gif");
        if(SaveAsPic.saveGif(file, myPanel.captureJPanel(myPanel))){
            jLabel1.setText("The diagram was saved as " + file.getAbsolutePath());
            return;
        jLabel1.setText("Error:failed to save as gif");
     * @param args the command line arguments
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new SaveAsGif_Demo().setVisible(true);
    // Variables declaration - do not modify                    
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JToolBar jToolBar1;
    // End of variables declaration                  
    private MyPanel myPanel;
class MyPanel extends JPanel {
    MyPanel(){
        super();
    public void paint(Graphics g){
        g.drawRect(10, 10, 100,100);
    Image i ;
    public Image captureJPanel( JPanel jp ) {
        i = this.createImage( jp.getSize().height, jp.getSize().width );
        Graphics g = i.getGraphics();
        jp.paint( g );
        return i;
class SaveAsPic {
    public static boolean saveGif(File file, Image image) {
        boolean flag = true;
        try {
            FileOutputStream fileoutputstream = new FileOutputStream(file);
            GifEncoder gifencoder = new GifEncoder(image, fileoutputstream);
            gifencoder.encode();
            fileoutputstream.close();
        catch(IOException ioexception) {
            System.out.println("Error encoding Gif-file: " + ioexception.getMessage());
            flag = false;
        return flag;
    SaveAsPic() {
class IntHashtableEnumerator
    implements Enumeration {
    IntHashtableEnumerator(IntHashtableEntry ainthashtableentry[], boolean flag) {
        table = ainthashtableentry;
        keys = flag;
        index = ainthashtableentry.length;
    public boolean hasMoreElements() {
        if(entry != null)
            return true;
        while(index-- > 0)
            if((entry = table[index]) != null)
                return true;
        return false;
    public Object nextElement() {
        if(entry == null)
            while(index-- > 0 && (entry = table[index]) == null) ;
        if(entry != null) {
            IntHashtableEntry inthashtableentry = entry;
            entry = inthashtableentry.next;
            if(keys)
                return new Integer(inthashtableentry.key);
            else
                return inthashtableentry.value;
        } else {
            throw new NoSuchElementException("IntHashtableEnumerator");
    boolean keys;
    int index;
    IntHashtableEntry table[];
    IntHashtableEntry entry;
class IntHashtableEntry {
    protected Object clone() {
        IntHashtableEntry inthashtableentry = new IntHashtableEntry();
        inthashtableentry.hash = hash;
        inthashtableentry.key = key;
        inthashtableentry.value = value;
        inthashtableentry.next = next == null ? null : (IntHashtableEntry)next.clone();
        return inthashtableentry;
    IntHashtableEntry() {
    int hash;
    int key;
    Object value;
    IntHashtableEntry next;
class IntHashtable extends Dictionary
    implements Cloneable {
    public IntHashtable(int i, float f) {
        if(i <= 0 || (double)f <= 0.0D) {
            throw new IllegalArgumentException();
        } else {
            loadFactor = f;
            table = new IntHashtableEntry;
threshold = (int)((float)i * f);
return;
public IntHashtable(int i) {
this(i, 0.75F);
public IntHashtable() {
this(101, 0.75F);
public int size() {
return count;
public boolean isEmpty() {
return count == 0;
public synchronized Enumeration keys() {
return new IntHashtableEnumerator(table, true);
public synchronized Enumeration elements() {
return new IntHashtableEnumerator(table, false);
public synchronized boolean contains(Object obj) {
if(obj == null)
throw new NullPointerException();
IntHashtableEntry ainthashtableentry[] = table;
for(int i = ainthashtableentry.length; i-- > 0;) {
for(IntHashtableEntry inthashtableentry = ainthashtableentry[i]; inthashtableentry != null; inthashtableentry = inthashtableentry.next)
if(inthashtableentry.value.equals(obj))
return true;
return false;
public synchronized boolean containsKey(int i) {
IntHashtableEntry ainthashtableentry[] = table;
int j = i;
int k = (j & 0x7fffffff) % ainthashtableentry.length;
for(IntHashtableEntry inthashtableentry = ainthashtableentry[k]; inthashtableentry != null; inthashtableentry = inthashtableentry.next)
if(inthashtableentry.hash == j && inthashtableentry.key == i)
return true;
return false;
public synchronized Object get(int i) {
IntHashtableEntry ainthashtableentry[] = table;
int j = i;
int k = (j & 0x7fffffff) % ainthashtableentry.length;
for(IntHashtableEntry inthashtableentry = ainthashtableentry[k]; inthashtableentry != null; inthashtableentry = inthashtableentry.next)
if(inthashtableentry.hash == j && inthashtableentry.key == i)
return inthashtableentry.value;
return null;
public Object get(Object obj) {
if(!(obj instanceof Integer)) {
throw new InternalError("key is not an Integer");
} else {
Integer integer = (Integer)obj;
int i = integer.intValue();
return get(i);
protected void rehash() {
int i = table.length;
IntHashtableEntry ainthashtableentry[] = table;
int j = i * 2 + 1;
IntHashtableEntry ainthashtableentry1[] = new IntHashtableEntry[j];
threshold = (int)((float)j * loadFactor);
table = ainthashtableentry1;
for(int k = i; k-- > 0;) {
for(IntHashtableEntry inthashtableentry = ainthashtableentry[k]; inthashtableentry != null;) {
IntHashtableEntry inthashtableentry1 = inthashtableentry;
inthashtableentry = inthashtableentry.next;
int l = (inthashtableentry1.hash & 0x7fffffff) % j;
inthashtableentry1.next = ainthashtableentry1[l];
ainthashtableentry1[l] = inthashtableentry1;
public synchronized Object put(int i, Object obj) {
if(obj == null)
throw new NullPointerException();
IntHashtableEntry ainthashtableentry[] = table;
int j = i;
int k = (j & 0x7fffffff) % ainthashtableentry.length;
for(IntHashtableEntry inthashtableentry = ainthashtableentry[k]; inthashtableentry != null; inthashtableentry = inthashtableentry.next)
if(inthashtableentry.hash == j && inthashtableentry.key == i) {
Object obj1 = inthashtableentry.value;
inthashtableentry.value = obj;
return obj1;
if(count >= threshold) {
rehash();
return put(i, obj);
} else {
IntHashtableEntry inthashtableentry1 = new IntHashtableEntry();
inthashtableentry1.hash = j;
inthashtableentry1.key = i;
inthashtableentry1.value = obj;
inthashtableentry1.next = ainthashtableentry[k];
ainthashtableentry[k] = inthashtableentry1;
count++;
return null;
public Object put(Object obj, Object obj1) {
if(!(obj instanceof Integer)) {
throw new InternalError("key is not an Integer");
} else {
Integer integer = (Integer)obj;
int i = integer.intValue();
return put(i, obj1);
public synchronized Object remove(int i) {
IntHashtableEntry ainthashtableentry[] = table;
int j = i;
int k = (j & 0x7fffffff) % ainthashtableentry.length;
IntHashtableEntry inthashtableentry = ainthashtableentry[k];
IntHashtableEntry inthashtableentry1 = null;
for(; inthashtableentry != null; inthashtableentry = inthashtableentry.next) {
if(inthashtableentry.hash == j && inthashtableentry.key == i) {
if(inthashtableentry1 != null)
inthashtableentry1.next = inthashtableentry.next;
else
ainthashtableentry[k] = inthashtableentry.next;
count--;
return inthashtableentry.value;
inthashtableentry1 = inthashtableentry;
return null;
public Object remove(Object obj) {
if(!(obj instanceof Integer)) {
throw new InternalError("key is not an Integer");
} else {
Integer integer = (Integer)obj;
int i = integer.intValue();
return remove(i);
public synchronized void clear() {
IntHashtableEntry ainthashtableentry[] = table;
for(int i = ainthashtableentry.length; --i >= 0;)
ainthashtableentry[i] = null;
count = 0;
public synchronized Object clone() {
try {
IntHashtable inthashtable = (IntHashtable)super.clone();
inthashtable.table = new IntHashtableEntry[table.length];
for(int i = table.length; i-- > 0;)
inthashtable.table[i] = table[i] == null ? null : (IntHashtableEntry)table[i].clone();
return inthashtable;
catch(CloneNotSupportedException _ex) {
throw new InternalError();
public synchronized String toString() {
int i = size() - 1;
StringBuffer stringbuffer = new StringBuffer();
Enumeration enumeration = keys();
Enumeration enumeration1 = elements();
stringbuffer.append("{");
for(int j = 0; j <= i; j++) {
String s = enumeration.nextElement().toString();
String s1 = enumeration1.nextElement().toString();
stringbuffer.append(s + "=" + s1);
if(j < i)
stringbuffer.append(", ");
stringbuffer.append("}");
return stringbuffer.toString();
private IntHashtableEntry table[];
private int count;
private int threshold;
private float loadFactor;
abstract class ImageEncoder
implements ImageConsumer {
public ImageEncoder(Image image, OutputStream outputstream) throws IOException {
this(image.getSource(), outputstream);
public ImageEncoder(ImageProducer imageproducer, OutputStream outputstream) throws IOException {
width = -1;
height = -1;
started = false;
accumulate = false;
producer = imageproducer;
out = outputstream;
abstract void encodeStart(int i, int j) throws IOException;
abstract void encodePixels(int i, int j, int k, int l, int ai[], int i1, int j1) throws IOException;
abstract void encodeDone() throws IOException;
public synchronized void encode() throws IOException {
encoding = true;
iox = null;
producer.startProduction(this);
while(encoding)
try {
wait();
catch(InterruptedException _ex) { }
if(iox != null)
throw iox;
else
return;
private void encodePixelsWrapper(int i, int j, int k, int l, int ai[], int i1, int j1) throws IOException {
if(!started) {
started = true;
encodeStart(width, height);
if((hintflags & 2) == 0) {
accumulate = true;
accumulator = new int[width * height];
if(accumulate) {
for(int k1 = 0; k1 < l; k1++)
System.arraycopy(ai, k1 * j1 + i1, accumulator, (j + k1) * width + i, k);
return;
} else {
encodePixels(i, j, k, l, ai, i1, j1);
return;
private void encodeFinish() throws IOException {
if(accumulate) {
encodePixels(0, 0, width, height, accumulator, 0, width);
accumulator = null;
accumulate = false;
private synchronized void stop() {
encoding = false;
notifyAll();
public void setDimensions(int i, int j) {
width = i;
height = j;
public void setProperties(Hashtable hashtable) {
props = hashtable;
public void setColorModel(ColorModel colormodel) {
public void setHints(int i) {
hintflags = i;
public void setPixels(int i, int j, int k, int l, ColorModel colormodel, byte abyte0[], int i1,
int j1) {
int ai[] = new int[k];
for(int k1 = 0; k1 < l; k1++) {
int l1 = i1 + k1 * j1;
for(int i2 = 0; i2 < k; i2++)
ai[i2] = colormodel.getRGB(abyte0[l1 + i2] & 0xff);
try {
encodePixelsWrapper(i, j + k1, k, 1, ai, 0, k);
catch(IOException ioexception) {
iox = ioexception;
stop();
return;
public void setPixels(int i, int j, int k, int l, ColorModel colormodel, int ai[], int i1,
int j1) {
if(colormodel == rgbModel) {
try {
encodePixelsWrapper(i, j, k, l, ai, i1, j1);
return;
catch(IOException ioexception) {
iox = ioexception;
stop();
return;
int ai1[] = new int[k];
for(int k1 = 0; k1 < l; k1++) {
int l1 = i1 + k1 * j1;
for(int i2 = 0; i2 < k; i2++)
ai1[i2] = colormodel.getRGB(ai[l1 + i2]);
try {
encodePixelsWrapper(i, j + k1, k, 1, ai1, 0, k);
catch(IOException ioexception1) {
iox = ioexception1;
stop();
return;
public void imageComplete(int i) {
producer.removeConsumer(this);
if(i == 4)
iox = new IOException("image aborted");
else
try {
encodeFinish();
encodeDone();
catch(IOException ioexception) {
iox = ioexception;
stop();
protected OutputStream out;
private ImageProducer producer;
private int width;
private int height;
private int hintflags;
private boolean started;
private boolean encoding;
private IOException iox;
private static final ColorModel rgbModel = ColorModel.getRGBdefault();
private Hashtable props;
private boolean accumulate;
private int accumulator[];
class GifEncoderHashitem {
public GifEncoderHashitem(int i, int j, int k, boolean flag) {
rgb = i;
count = j;
index = k;
isTransparent = flag;
public int rgb;
public int count;
public int index;
public boolean isTransparent;
class GifEncoder extends ImageEncoder {
public GifEncoder(Image image, OutputStream outputstream) throws IOException {
super(image, outputstream);
interlace = false;
maxbits = 12;
maxmaxcode = 4096;
htab = new int[5003];
codetab = new int[5003];
hsize = 5003;
clear_flg = false;
accum = new byte[256];
public GifEncoder(Image image, OutputStream outputstream, boolean flag) throws IOException {
super(image, outputstream);
interlace = false;
maxbits = 12;
maxmaxcode = 4096;
htab = new int[5003];
codetab = new int[5003];
hsize = 5003;
clear_flg = false;
accum = new byte[256];
interlace = flag;
public GifEncoder(ImageProducer imageproducer, OutputStream outputstream) throws IOException {
super(imageproducer, outputstream);
interlace = false;
maxbits = 12;
maxmaxcode = 4096;
htab = new int[5003];
codetab = new int[5003];
hsize = 5003;
clear_flg = false;
accum = new byte[256];
public GifEncoder(ImageProducer imageproducer, OutputStream outputstream, boolean flag) throws IOException {
super(imageproducer, outputstream);
interlace = false;
maxbits = 12;
maxmaxcode = 4096;
htab = new int[5003];
codetab = new int[5003];
hsize = 5003;
clear_flg = false;
accum = new byte[256];
interlace = flag;
void encodeStart(int i, int j) throws IOException {
width = i;
height = j;
rgbPixels = new int[j][i];
void encodePixels(int i, int j, int k, int l, int ai[], int i1, int j1) throws IOException {
for(int k1 = 0; k1 < l; k1++)
System.arraycopy(ai, k1 * j1 + i1, rgbPixels[j + k1], i, k);
void encodeDone() throws IOException {
int i = -1;
int j = -1;
colorHash = new IntHashtable();
int k = 0;
for(int l = 0; l < height; l++) {
for(int i1 = 0; i1 < width; i1++) {
int j1 = rgbPixels[l][i1];
boolean flag = j1 >>> 24 < 128;
if(flag)
if(i < 0) {
i = k;
j = j1;
} else
if(j1 != j)
rgbPixels[l][i1] = j1 = j;
GifEncoderHashitem gifencoderhashitem = (GifEncoderHashitem)colorHash.get(j1);
if(gifencoderhashitem == null) {
if(k >= 256)
throw new IOException("too many colors for a GIF");
gifencoderhashitem = new GifEncoderHashitem(j1, 1, k, flag);
k++;
colorHash.put(j1, gifencoderhashitem);
} else {
gifencoderhashitem.count++;
byte byte0;
if(k <= 2)
byte0 = 1;
else
if(k <= 4)
byte0 = 2;
else
if(k <= 16)
byte0 = 4;
else
byte0 = 8;
int k1 = 1 << byte0;
byte abyte0[] = new byte[k1];
byte abyte1[] = new byte[k1];
byte abyte2[] = new byte[k1];
for(Enumeration enumeration = colorHash.elements(); enumeration.hasMoreElements();) {
GifEncoderHashitem gifencoderhashitem1 = (GifEncoderHashitem)enumeration.nextElement();
abyte0[gifencoderhashitem1.index] = (byte)(gifencoderhashitem1.rgb >> 16 & 0xff);
abyte1[gifencoderhashitem1.index] = (byte)(gifencoderhashitem1.rgb >> 8 & 0xff);
abyte2[gifencoderhashitem1.index] = (byte)(gifencoderhashitem1.rgb & 0xff);
GIFEncode(super.out, width, height, interlace, (byte)0, i, byte0, abyte0, abyte1, abyte2);
byte GetPixel(int i, int j) throws IOException {
GifEncoderHashitem gifencoderhashitem = (GifEncoderHashitem)colorHash.get(rgbPixels[j][i]);
if(gifencoderhashitem == null)
throw new IOException("color not found");
else
return (byte)gifencoderhashitem.index;
static void writeString(OutputStream outputstream, String s) throws IOException {
byte abyte0[] = s.getBytes();
outputstream.write(abyte0);
void GIFEncode(OutputStream outputstream, int i, int j, boolean flag, byte byte0, int k, int l,
byte abyte0[], byte abyte1[], byte abyte2[]) throws IOException {
Width = i;
Height = j;
Interlace = flag;
int k1 = 1 << l;
int j1;
int i1 = j1 = 0;
CountDown = i * j;
Pass = 0;
int l1;
if(l <= 1)
l1 = 2;
else
l1 = l;
curx = 0;
cury = 0;
writeString(outputstream, "GIF89a");
Putword(i, outputstream);
Putword(j, outputstream);
char c = '\uFF80';
c |= 'p';
c |= (byte)(l - 1);
Putbyte((byte)c, outputstream);
Putbyte(byte0, outputstream);
Putbyte((byte)0, outputstream);
for(int i2 = 0; i2 < k1; i2++) {
Putbyte(abyte0[i2], outputstream);
Putbyte(abyte1[i2], outputstream);
Putbyte(abyte2[i2], outputstream);
if(k != -1) {
Putbyte((byte)33, outputstream);
Putbyte((byte)-7, outputstream);
Putbyte((byte)4, outputstream);
Putbyte((byte)1, outputstream);
Putbyte((byte)0, outputstream);
Putbyte((byte)0, outputstream);
Putbyte((byte)k, outputstream);
Putbyte((byte)0, outputstream);
Putbyte((byte)44, outputstream);
Putword(i1, outputstream);
Putword(j1, outputstream);
Putword(i, outputstream);
Putword(j, outputstream);
if(flag)
Putbyte((byte)64, outputstream);
else
Putbyte((byte)0, outputstream);
Putbyte((byte)l1, outputstream);
compress(l1 + 1, outputstream);
Putbyte((byte)0, outputstream);
Putbyte((byte)59, outputstream);
void BumpPixel() {
curx++;
if(curx == Width) {
curx = 0;
if(!Interlace) {
cury++;
return;
switch(Pass) {
default:
break;
case 0: // '\0'
cury += 8;
if(cury >= Height) {
Pass++;
cury = 4;
return;
break;
case 1: // '\001'
cury += 8;
if(cury >= Height) {
Pass++;
cury = 2;
return;
break;
case 2: // '\002'
cury += 4;
if(cury >= Height) {
Pass++;
cury = 1;
return;
break;
case 3: // '\003'
cury += 2;
return;
int GIFNextPixel() throws IOException {
if(CountDown == 0) {
return -1;
} else {
CountDown--;
byte byte0 = GetPixel(curx, cury);
BumpPixel();
return byte0 & 0xff;
void Putword(int i, OutputStream outputstream) throws IOException {
Putbyte((byte)(i & 0xff), outputstream);
Putbyte((byte)(i >> 8 & 0xff), outputstream);
void Putbyte(byte byte0, OutputStream outputstream) throws IOException {
outputstream.write(byte0);
final int MAXCODE(int i) {
return (1 << i) - 1;
void compress(int i, OutputStream outputstream) throws IOException {
g_init_bits = i;
clear_flg = false;
n_bits = g_init_bits;
maxcode = MAXCODE(n_bits);
ClearCode = 1 << i - 1;
EOFCode = ClearCode + 1;
free_ent = ClearCode + 2;
char_init();
int j1 = GIFNextPixel();
int i2 = 0;
for(int j = hsize; j < 0x10000; j *= 2)
i2++;
i2 = 8 - i2;
int l1 = hsize;
cl_hash(l1);
output(ClearCode, outputstream);
int i1;
label0:
while((i1 = GIFNextPixel()) != -1) {
int k = (i1 << maxbits) + j1;
int l = i1 << i2 ^ j1;
if(htab[l] == k) {
j1 = codetab[l];
continue;
if(htab[l] >= 0) {
int k1 = l1 - l;
if(l == 0)
k1 = 1;
do {
if((l -= k1) < 0)
l += l1;
if(htab[l] == k) {
j1 = codetab[l];
continue label0;
} while(htab[l] >= 0);
output(j1, outputstream);
j1 = i1;
if(free_ent < maxmaxcode) {
codetab[l] = free_ent++;
htab[l] = k;
} else {
cl_block(outputstream);
output(j1, outputstream);
output(EOFCode, outputstream);
void output(int i, OutputStream outputstream) throws IOException {
cur_accum &= masks[cur_bits];
if(cur_bits > 0)
cur_accum |= i << cur_bits;
else
cur_accum = i;
for(cur_bits += n_bits; cur_bits >= 8; cur_bits -= 8) {
char_out((byte)(cur_accum & 0xff), outputstream);
cur_accum >>= 8;
if(free_ent > maxcode || clear_flg)
if(clear_flg) {
maxcode = MAXCODE(n_bits = g_init_bits);
clear_flg = false;
} else {
n_bits++;
if(n_bits == maxbits)
maxcode = maxmaxcode;
else
maxcode = MAXCODE(n_bits);
if(i == EOFCode) {
for(; cur_bits > 0; cur_bits -= 8) {
char_out((byte)(cur_accum & 0xff), outputstream);
cur_accum >>= 8;
flush_char(outputstream);
void cl_block(OutputStream outputstream) throws IOException {
cl_hash(hsize);
free_ent = ClearCode + 2;
clear_flg = true;
output(ClearCode, outputstream);
void cl_hash(int i) {
for(int j = 0; j < i; j++)
htab[j] = -1;
void char_init() {
a_count = 0;
void char_out(byte byte0, OutputStream outputstream) throws IOException {
accum[a_count++] = byte0;
if(a_count >= 254)
flush_char(outputstream);
void flush_char(OutputStream outputstream) throws IOException {
if(a_count > 0) {
outputstream.write(a_count);
outputstream.write(accum, 0, a_count);
a_count = 0;
private boolean interlace;
int width;
int height;
int rgbPixels[][];
IntHashtable colorHash;
int Width;
int Height;
boolean Interlace;
int curx;
int cury;
int CountDown;
int Pass;
static final int EOF = -1;
static final int BITS = 12;
static final int HSIZE = 5003;
int n_bits;
int maxbits;
int maxcode;
int maxmaxcode;
int htab[];
int codetab[];
int hsize;
int free_ent;
boolean clear_flg;
int g_init_bits;
int ClearCode;
int EOFCode;
int cur_accum;
int cur_bits;
int masks[] = {
0, 1, 3, 7, 15, 31, 63, 127, 255, 511,
1023, 2047, 4095, 8191, 16383, 32767, 65535
int a_count;
byte accum[];

Similar Messages

  • How do i save a frame to a image file?

    im trying to save a frame from Final Cut Pro 5 to my hard disk to save and edit with an editor such as Photoshop. how do i save it. what menu options do i use?

    The first thing you should do is check out the manual. This is a very, very basic export procedure; File->Export->Using QuickTime Conversion. Then choose still image from the format menu and your file type (JPG, TIF, PSD, etc) from the Option Menu.
    -DH

  • How do I save a pdf as an html file without losing formatting?

    How do I save a pdf as an html file without losing formatting?  My coworker is able to do this on her Adobe 9 by saving to html css 4.0 - I have Adobe 11 and have not been able to save as an html at all without loosing formatting.

    Are the PDF files that you are attempting to Save As HTML tagged?

  • How do I save a PDF as an excel file when the PDF is horizontal. Adobe tries to rotate the page, but the data is entered in an  horizontal format.

    How do I save a PDF as an excel file when the PDF is horizontal. Adobe tries to rotate the page, but the data is entered in an  horizontal format.

    Thanks for the quick reply.  I figured out how to get the desired results by using tagging.  For anyone who may reference this post in the future, I went to "Customize" in the top right corner of Adobe, then selected "Create new tool set...", looked under "accessiblity and found the "tag" option.  Hit ok, tag is added to the toolbar.  Then I highlighted the dataset in the PDF that was relevant to the output format, then clicked "tag", saved as spreadsheet.  Sorry I can't provide more details on how tagging works or if there's a more elegant solution available, but I'm sure one's out there.

  • How can I save a region of an image into another image?

    How can I save a region of an image into another image? Should I use JAI?
    Java2d? Is there an example?
    Thank you.

    Here is what I try, but I find out I just get a black square for my output image, can you please tell me what am I missing?
              ImageIcon file=new ImageIcon("images/clouds.jpg"); // You can't open bmp files
                   // width, height looks correct:
                   System.out.println (" width" + file.getIconWidth());
                   System.out.println (" height" + file.getIconHeight());
                   BufferedImage bi = new BufferedImage(file.getIconWidth(), file.getIconHeight(),
                   BufferedImage.TYPE_INT_RGB);
                   int x = 0;
                   int y = 0;
                   BufferedImage subimage = bi.getSubimage(x, y, 40, 40);
                   File outputFile = new File("newimage.png");
                   ImageIO.write(subimage, "png", outputFile);

  • Once image is edited- how do I save it to desktop or a file to later insert it in an illustrator layout?  I tried to save it and it saved but it opens into photoshop elements editing page

    once image is edited- how do I save it to desktop or a file to later insert it in an illustrator layout?  I tried to save it and it saved but it opens into photoshop elements editing page

    Right click > Open with and choose the program to open it.

  • How do I save my contact sheets as a file instead of printing?

    How do I save my contact sheets as a file instead of printing?

    In Aperture 3 there are two print dialogs. The first is Aperture specific. After you finish this dialog the printer specific dialog will open. In the PDF menu choose Save as PDF...
    I've forgotten how Aperture 2 works but it has a different print dialog I think. Look for the same PDF menu or a Preview button.

  • HT1553 i am upgrading my 2008 macbook to an ssd drive and want to save my settings. how do i save then? I have my files backed up with time machine ,but dont want to restore all files ,as there might be some junk backed up too. Help will be appretiated

    i am upgrading my 2008 macbook to an ssd drive and want to save my settings. how do i save then? I have my files backed up with time machine ,but dont want to restore all files ,as there might be some junk backed up too. Help will be appretiated

    When you restore from a Time Machine back up you can pick and chose what is restored. It is not an all or nothing process. Nor do you have to do the partial restores all at the same time. If days after the first partial restore you find something else you want you can restore just that.

  • How do you save an iMovie project as a file?

    how do you save an imovie as a windows file?

    You first have to format the External drive as Mac OS Extended. This can be done with Disk Utility which is located in the Utilities Folder inside the Applications Folder. Once formatted as a native Mac OS drive, iMovie will allow you to 'turn on' the visibility of the external drive. Make sure to make the hard drive visible in the Events Library by going to the View Menu > Group Events by Disk. In the Projects Folder you should also see the same drive.
    Drag your Project folders to the external drive icon in the Project Library. Also drag your Event Folders to the external drive (but make sure to drag it to the icon that is visible in the Event Library, don't drag it to the Project Library drive icon).
    This dragging operation will 'duplicate' your Project Folders and Event Folders on the external drive. So to make space on your internal drive, always delete the original folders AFTER you make copies of them on the External drive. In the future when you are importing video into a New Event, make sure to choose the external drive as the location for the the New Event folder. Similalrly create a new Project Folder in the external drive location in the Project Library.
    iMovie doesn't have save menu, it auto-saves in the background continuously as you work on the Project. That way you don't lose any work by forgetting to save the project.

  • How can I save an EXE front panel image to a file?

    The methods to save a VI front panel image to a file don't work on executable applications. How can I save an EXE front panel image to a file? (LabVIEW 6.1)

    Hi,
    i wrote some vi that save FP to image and created exe and it works fine. How do you save FP to image in VI?
    If you use VI server method "Get Panel Image" and use "Write JPG file" ( or BPM) it works fine.
    Attachments:
    fp.zip ‏40 KB

  • How do I save and play an asx.asf file?

    How do I save and play an asx.asf file?

    Those are Windows formats.
    VLC should be able to work with them as stated at http://www.iskysoft.com/article/asf-video-converter-mac.html
    Allan

  • How do you save a webpage as a single file like internet explorer

    how do you save a webpage as a single file like internet explorer

    *Mozilla Archive Format: https://addons.mozilla.org/firefox/addon/mozilla-archive-format/
    *UnMHT: https://addons.mozilla.org/firefox/addon/unmht/

  • How can I get the resolution of an image file in JSP?

    how can I get the resolution of an image file like jpg,gif,png in JSP ?

    Hii,
    If by the resolution, u mean size..this is how u can come to know....
    String add = "path/to/some.jpeg";
    javax.swing.ImageIcon chain = new javax.swing.ImageIcon(add);
    int height = chain.getIconHeight();
    int width = chain.getIconWidth();
    Hope that helps.
    regards
                   

  • How can i save differnts data in the same file?

        Hi all,
    i need some help.  I'm working  on a project  for students an th university. We have to devellop  a programm for LEDs measurement so that all the measure data must be save in de same file.  We have develloped the programm, but we have  a big problem to save the measure in the same File.
    When we do the first  measure , the file must be created and the fisrt data gonna be save in this file that is correct
    When wie do the second measure, the third  ....  measure, the programm ask us to comfirm the file or where we want save our data
    We need some help, to know how we can change  or devellop this programm so that, for the first measure , the file must be created and the fisrt data gonna be save in this file,  the second measure the same file must be chose and from the third and more the measure data must be automatically save in this file without the programm ask to chose or to confirme a file? 
    I attach a part off this programmm
    Thanks
    Attachments:
    SR830DSP19.vi ‏212 KB

    Move the "File Dialog" where you open your new file out of the while loop. Only pass the refnum inside the loop.

  • How do I save only part of a PDF file?

    I have a PDF of a book layout, which is 176 pages. It's one big file. How can I save only selected pages as a separate PDF?
    Thanks
    David Heim

    Document>Extract pages but only if you have Adobe Acrobat (you haven't mentioned that as of yet) and only if there is no security preventing modifications and such.

Maybe you are looking for

  • Image sequence of jpegs import into Premiere Pro CC 2014 out of sync!

    Ever since I left CS6 to CC 2014, image sequences as jpeg files do not properly import into Premiere in sync anymore.  I use Blender 3d to export render scenes as jpegs then convert them to h.264 mpeg4 video clips in Premiere.  What happens is that t

  • Bank key vs Electronic Bank Statement

    Hello, What is recommended by SAP is to have bank key for house bank the same as SWIFT code. I have case now that bank from Turkey has TGBATRIS Swift code and the same i use as bank key. But when they have sent bank statement and i import it using FF

  • Production issue with Smart Form

    Hi , Issue is: Data getting poplutated in Dev system but not getting in Production system. we are using standard FM CRM_OUTPUT_SINGLE_READ which contains FM SSF_FIELD_LIST to which our smartform name is passed. FM SSF_FIELD_LIST returns all the globa

  • Roadmap UI element functionality

    Gudday, I want to use roadmap UI element in my application,can anyone suggest me how to proceed with this...iam new to this concept. I have gone thr DEMO_ROADMAP in sdn ....but iam not getting anything from it. Awaiting your reply. Thanks, Deepthi.

  • New Apple ID and Movies Disappeared from iCloud

    I changed my apple id to my new email address and now when I go into "purchased" in iTunes, all my previously purchased movies are gone. It's not even a category at the top where it says "Apps" "Music" "Books" "TV Shows", there's no "Movies" Does any