Solved

Read display a gif using a socket or fileinputstream in applet

Posted on 1997-07-19
3
334 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

617 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