473,388 Members | 1,600 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

PGM Reader - Using UNSIGNED BYTES

Hi all.
I have a PGM file.
I am supposed to read in this file and find the pixel value for each pixel in the picture.

Currently, i am reading UNSIGNED bytes.

I got this function to covert it to integer.

public static int unsignedByteToInt(byte b) {
return (int) b & 0xFF;
}

Problem now is.
I am supposed to write to a new file with INTEGER values.
Same extension ( PGM )
Thus, am i supposed to write UNSIGNED bytes to it?
If so, is there anyway i can convert my INT to unsigned bytes?

Please advice.
Cheers!
Darence
Nov 18 '06 #1
0 2848

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: hcc | last post by:
Hi, Does anyone have experience with using Purify with db2 CLI application? We're using Purify to diagnose some problem in our multi-thread CLI application, and we're getting lots of the "UMR:...
19
by: becte | last post by:
I need to use three bytes to store four 6-bit integers (4 * 6 = 3 * 8) like this 11111122|22223333|33444444 Suppose the input is, int c1, c2, c3, c4, range 0 .. 2^6 -1 and the output is int...
4
by: Burns | last post by:
Hi I've just tried the following code FileStream objFS = new FileStream(strFileName, FileMode.Open, FileAccess.Read) BinaryReader objReader = new BinaryReader(objFS) UInt32 intFirst =...
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
6
by: Karl Seguin [MVP] | last post by:
The BinaryWriter/Reader's are little-endian only. Was hoping they were going to be made more flexible in 2.0, but that doesn't appear to be the case. Anyone already done all the work of...
1
by: xoinki | last post by:
hi experts, I need a little help in debugging this code.. would u pleeze kindly help me? here this program sends a datagram every 10 seconds and on reception it cheks whether the source IP is...
14
by: moumita | last post by:
Hi All, I need to convert 4 bytes to an unsigned long. Suppose I have one array like unsigned char buf.I need to convert these 4 bytes into a single unsigned long. Is the following piece of code...
5
by: sweeet_addiction16 | last post by:
hello experts...pls help me debug this code........im not able to write in the data bytes ..only the few header bytes are written... #include<stdio.h> struct mthd_chunk { char id;...
8
by: digz | last post by:
I saw the following code and comments in a source file, I am not able to appreciate what the author is trying to do in ALIGNED_ALLOC , can some one plz help me understand why CACHE_LINE_SIZE * 2...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.