Solved

Read display a gif using a socket or fileinputstream in applet

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
xampp tool 12 56
fibonacci ten numbers 4 45
Can anyone please tell me why i can not find ID  investorCoolGrid inside the jsp page? 1 22
how to debug htl and js pages 8 38
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
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…
This video teaches viewers about errors in exception handling.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

789 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