How to read the byte arry data?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • krishnasamy
    New Member
    • Jun 2007
    • 31

    #1

    How to read the byte arry data?

    Hi,

    I have invoking the "NewDll.Dll " which created using vc++. In this Dll a method return the array data following way,

    BYTE NewDemoDll::Ret LiveImg()
    {
    return bufferData[ImageSize];
    }

    How can I write the code in Java to get the data from the above method?

    Please help me to solve this problem.
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by krishnasamy
    Hi,

    I have invoking the "NewDll.Dll " which created using vc++. In this Dll a method return the array data following way,

    BYTE NewDemoDll::Ret LiveImg()
    {
    return bufferData[ImageSize];
    }

    How can I write the code in Java to get the data from the above method?

    Please help me to solve this problem.
    Try JNI

    Comment

    • krishnasamy
      New Member
      • Jun 2007
      • 31

      #3
      Originally posted by r035198x
      Try JNI

      Thanks for your reply.

      I already tried to JNI wrapper. Here I given that code,

      *************** **************W RAPPER********* *************** *************** *
      class ImageWrapper
      {
      Library library =null;
      Function function =null;

      PowerShot(Strin g libname)
      {
      library = new Library(libname );
      library.load();

      }


      public PrimitiveArray RetLiveImg(Stri ng fn_name)
      {
      function=librar y.getFunction(f n_name);
      PrimitiveArray data = new PrimitiveArray( UInt8.class, 20480);
      function.invoke (data);
      return data;
      }


      public static void main(String args[])throws IOException
      {

      ImageWrapper wrap=new ImageWrapper("n ewdll");

      function="?RetL iveImg@NewDemoD ll@NewDll@@SAEX Z";

      PrimitiveArray array=sdk.RetLi veImg(function) ;

      byte[] buffer= array.getBytes( );
      FileOutputStrea m out=new FileOutputStrea m("liveimage.jp g");
      out.write(buffe r);
      out.close();


      }
      }

      When I compile above program, I got the following error,

      *************** *************** ***ERROR *************** *************** *********

      D:>java ImageWrapper

      #
      # An unexpected error has been detected by HotSpot Virtual Machine:
      #
      # EXCEPTION_ACCES S_VIOLATION (0xc0000005) at pc=0x6d316eb0, pid=1416, tid=2440
      #
      # Java VM: Java HotSpot(TM) Client VM (1.5.0_12-b04 mixed mode, sharing)
      # Problematic frame:
      # C [java.dll+0x6eb0]
      #
      # An error report file with more information is saved as hs_err_pid1416. log


      Shall you give a example to read the Binary Data from DLL?

      Comment

      Working...