Solved

Read display a gif using a socket or fileinputstream in applet

Posted on 1997-07-19
3
322 Views
Last Modified: 2006-11-17
I need to read a gif using either a socket connection or FileInputStream, convert to an image and display using graphics.drawImage .  most methods seem to return an array of bytes, which I think I can convert to an image using MemoryImageSource, however I have found no concrete examples and just cannot get it to work.  I would just use getImage but the image is cached at the browser and I can't have that, need fresh reload.  I need a solid example of how to do this.

0
Comment
Question by:dsweeney
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
mann061997 earned 50 total points
ID: 1223419
Here's some sample code for a bilevel image:

    byte[] cmR = {(byte)0x00, (byte)0xFF};
    byte[] cmG = cmR;
    byte[] cmB = cmR;
    IndexColorModel cm = new IndexColorModel(1, 2, cmR, cmG, cmB);

    byte[] data;

    ... fill data array, e.g. from file input source.

    Image myImage = createImage(new MemoryImageSource(
                      width,
                      height,
                      cm,
                      data,
                      0,
                      width));
    g.drawImage(myImage, x, y , null);

0
 
LVL 1

Expert Comment

by:mann061997
ID: 1223420
I forgot to mention: the byte array must contain a decompressed image, i.e. a pixmap, for the above code to work. If you're working with GIF this means you must first decompress the GIF image.
0
 

Author Comment

by:dsweeney
ID: 1223421
The pic will be a JPG, and there is no way for me to decompress  it first (I am using Connectix Quickcam software that simply sends the image it 'sees' to disk every 10 seconds).  I can also save it as a BMP or TIFF file, if this helps??  Also, what the heck is a bilevel image?  I have been trying to get this project online so long that I will give you 200 points and an A if you can provide some code that does the trick!!!  
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
map related example 6 59
How to configure empty element in XML Document parser? 15 44
Selenium docs api java index 3 68
Bot application - advice 3 62
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
The viewer will learn how to implement Singleton Design Pattern in Java.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question