Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > how to read 16 - bit values?

Reply
Thread Tools

how to read 16 - bit values?

 
 
Rajesh.Rapaka
Guest
Posts: n/a
 
      04-28-2005
HI all,

I guess I am lost with all the fundamentals and all logical thinking.
plz help me.

I am using java. and I have an 16-bit image file. but this image file
contains of integer values ( in 16-bit). now using java how can i read
the 16-bit signed integer value ??

plz help !!
I know this should be a very very simple question. but failed to think
or find a gateway at this last moment.

kindly help
regards,
Rajesh RApaka.

 
Reply With Quote
 
 
 
 
foo
Guest
Posts: n/a
 
      04-28-2005
Do the following until you have read all bytes. File should have even
bytes.
Assumption is that while writing the high byte was written before the
low byte. If it's not true exchange b0 and b1 in line 3 and 5 of the
code.

short s = 0;
byte b0 = in.read(); byte b1 = in.read();
s = s | b0;
s << 8;
s = s | b1;

 
Reply With Quote
 
 
 
 
Greg Stark
Guest
Posts: n/a
 
      04-28-2005
Also, consider using the DataInputStream class instead. Or perhaps
ByteBuffer might be more appropriate?

 
Reply With Quote
 
Rajesh.Rapaka
Guest
Posts: n/a
 
      04-29-2005
this what I did !! But somehow it wrked very differently!! I guess i'll
check my codes again.

regards,
Rajesh Rapaka

 
Reply With Quote
 
bugbear
Guest
Posts: n/a
 
      04-29-2005
Rajesh.Rapaka wrote:
> HI all,
>
> I guess I am lost with all the fundamentals and all logical thinking.
> plz help me.
>
> I am using java. and I have an 16-bit image file. but this image file
> contains of integer values ( in 16-bit). now using java how can i read
> the 16-bit signed integer value ??
>


Hmm Input. File. That might lead one to look in the java.io package.

java.io.DataInputStream


> A data input stream lets an application read primitive Java data

types > from an underlying input stream in a machine-independent way.

HTH.

BugBear
 
Reply With Quote
 
Lee Ryman
Guest
Posts: n/a
 
      04-29-2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

bugbear wrote:
>
> Hmm Input. File. That might lead one to look in the java.io package.
>
> java.io.DataInputStream
>


Your not, are you? You couldn't actually be suggesting someone reads the
API documentation? Don't you know that is utter madness? Do you not
realise the consequences of encouraging people to start reading API
docs? The constant flux of stupid newsgroup questions stemming from the
lack of common-sense is critical not only to the necessary daily
expression of sarcasm and wit by gurus (required to maintain the
inflation of their heads), but for the stability of our universe and the
space-time continuum. It is people like you with outrages implication
such as the necessity to RTFM before posting that will lead to the
downfall of society, the destruction of Earth, the Big-Crunch, and (god
give me the courage to mention it) actually _good_ software!

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iEYEARECAAYFAkJyJbQACgkQhbcFpQga0LDkYwCgvxawwv1MFx dx8PcBzHlQUOlB
aS8AoIftIresPXPk1jCHDDs7Zt5hivos
=620R
-----END PGP SIGNATURE-----
 
Reply With Quote
 
bugbear
Guest
Posts: n/a
 
      04-29-2005
Lee Ryman wrote:
>
>
> Your not, are you? You couldn't actually be suggesting someone reads the
> API documentation? Don't you know that is utter madness? Do you not
> realise the consequences of encouraging people to start reading API
> docs? The constant flux of stupid newsgroup questions stemming from the
> lack of common-sense is critical not only to the necessary daily
> expression of sarcasm and wit by gurus (required to maintain the
> inflation of their heads), but for the stability of our universe and the
> space-time continuum. It is people like you with outrages implication
> such as the necessity to RTFM before posting that will lead to the
> downfall of society, the destruction of Earth, the Big-Crunch, and (god
> give me the courage to mention it) actually _good_ software!
>


<<chuckle>>

BugBear
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What is the point of having 16 bit colour if a computer monitor can only display 8 bit colour? How do you edit 16 bit colour when you can only see 8 bit? Scotius Digital Photography 6 07-13-2010 03:33 AM
Reversing Bit Order.. i.e. MSB becomes bit 0, LSB becomes bit 15 benn686@hotmail.com C++ 9 08-22-2007 12:13 AM
"LoadLibrary" of a 32 bit so with 64 bit java on a 64 bit machine markryde@gmail.com Java 3 01-19-2007 10:30 PM
64 bit - Windows Liberty 64bit, Windows Limited Edition 64 Bit, Microsoft SQL Server 2000 Developer Edition 64 Bit, IBM DB2 64 bit - new ! vvcd Computer Support 0 09-17-2004 08:15 PM
64 bit - Windows Liberty 64bit, Windows Limited Edition 64 Bit,Microsoft SQL Server 2000 Developer Edition 64 Bit, IBM DB2 64 bit - new! Ionizer Computer Support 1 01-01-2004 07:27 PM



Advertisments