This is the mail archive of the java-discuss@sourceware.cygnus.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Defining arrays...


I've been playing with trying to link the JPEG library into a class
compiled using gcj, and
have run into a strange problem...

When I compile the program it's all ok - no warnings, but on trying to
link the various
modules, I get the following error:

gcj -g -o vspoold main.o Configuration.o Connection.o DirectoryManager.o
Server.o Security.o HeaderManager.o SgiFile.o natConnection.o
jpgMemDst.o --main=main -Ljpeg -ljpeg
natConnection.o: In function `JArray<char> type_info function':
natConnection.cc:16: undefined reference to `__JArray type_info
function'
natConnection.cc:16: undefined reference to `__JArray type_info node'

I don't understand what this is telling me - I've tried adding in all
the headers from the
natString.cc file (which compiles fine) and it didn't make amy
difference. Do I have to
create additional code (templates ?) to handle arrays ?

Line 16 is the method-name line, so presumably it's when the method is
being called
that the problem would arise ?

Thanks in advance for any help - I'm slowly getting my head around gcj,
but this
particular problem has me stumped :-(


Here's the full source code for that module - 72 lines long.

#include <string.h>
#include <stdlib.h>
#include <iostream.h>

#include <cni.h>

#include <Connection.h>

#include "jpgMemDst.h"              // JPEG in-memory destination
manager

//
=======================================================================
// Native interface to the jpeg creation method
//
=======================================================================
jbyteArray Connection::toJPEG(jbyteArray rgb, jint w, jint h)
 {
 register jbyte *dPtr = elements (rgb);
 if (dPtr == NULL)
  {
  cerr << "Warning - passed NULL RGB pointer to JPEG compress" << endl;
  return NULL;
  }

 //
=======================================================================
 // Compress the RGB file into a JPEG image
 //
=======================================================================
 int numBytes = 0;
 struct jpeg_compress_struct cinfo;   // info for JPEG compressor

 JSAMPROW row_pointer[1];    // pointer to JSAMPLE row[s]
 int row_stride;       // physical row width in buffer

 // Open standard error output so we can report errors
 struct jpeg_error_mgr jerr;    // Error-handler
  cinfo.err = jpeg_std_error(&jerr);

 // Initialise the compressor
 jpeg_create_compress(&cinfo);

 // Allocate an initial buffer - will be expanded as necessary by the
 // destination memory manager code
 char * storage = new char[150000];
 jpeg_memory_dest(&cinfo, &numBytes, storage, 150000);

 // Set up the parameters for the compressor
   cinfo.image_width = (int)w;    // image width, in pixels
   cinfo.image_height = (int)h;   // image height, in pixels
   cinfo.input_components = 3;    // # of color components per pixel
   cinfo.in_color_space = JCS_RGB;   // colorspace of input image
   jpeg_set_defaults(&cinfo);

 // Start the compressor going
 jpeg_start_compress(&cinfo, TRUE);

 // And encode a line at a time
   row_stride = w * 3;      // JSAMPLEs per row in buffer
   while (cinfo.next_scanline < cinfo.image_height)
  {
     row_pointer[0] = (JSAMPLE *) & dPtr[cinfo.next_scanline *
row_stride];
     (void) jpeg_write_scanlines(&cinfo, row_pointer, 1);
    }


 // Close down the compressor
 jpeg_finish_compress(&cinfo);

 // Convert to a java array
 jbyteArray result = JvNewByteArray(numBytes);
 memcpy(elements(result), storage, numBytes);

 delete [] storage;
 return result;
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]