Teen Programmers Unite  
 

 

Return to forum top

Binary or text mode?

Posted by manoj [send private reply] at August 08, 2002, 01:49:30 PM

Recently I was doing a simple C prog to read a windows-bmp, apply some masking (edge detection) and generate another bmp as output. I was using a 24-bit image and it turned out that the prog worked fine only for a 256 colored one. By studying the output for the 24 bit one and after lots of brainwork I found out that I was using putc which was taking more space for storing the numbers (text mode). I switched to fwrite (binary) and it worked fine. This led me to think that how can one know that which format should be used for reading/writing std filetypes? Is there a way using C to find out what to use (if not, is there some other method/tool)? Also, I didn't completely get the problem....when I applied the masking the o/p was wrong but when I simply read the numbers (getc) and write them without any change (putc) the original image was reproduced!! If the problem was not using binary mode, the how come it worked fine without masking??

Posted by Psion [send private reply] at August 08, 2002, 02:20:54 PM

Text mode converts line breaks as appropriate for your environment, i.e. write two characters, carriage return and linefeed, when your program outputs '\n' on Windows. You should only use text mode for "text" files, simply enough. =) I think nothing as complicated as what you described is actually going on.

Posted by manoj [send private reply] at August 18, 2002, 03:14:25 PM

Hey thanks Psion, I'd read that text mode takes up more space so I was thinking on that line only. Your answer clarifies it.

Posted by CodeRed [send private reply] at August 18, 2002, 07:52:36 PM

manoj a twa?

Posted by RedX [send private reply] at August 19, 2002, 06:41:16 AM

"manoj a twa?"

You ment "maison a trois" right. For that you should look at a adult group. :-)

Posted by buzgub [send private reply] at August 19, 2002, 07:00:37 AM

I always thought it was "menage" (as in, menagerie)

Posted by RedX [send private reply] at August 19, 2002, 03:15:59 PM

heu, yeah. Well I have a hate-hate relationship with French.

Posted by manoj [send private reply] at August 19, 2002, 07:25:25 PM

"Manoj a twa"???? What was that? Where did that adult group came from!!
Somebody tell me, what is going on (in english/hindi/sanskrit=))?

Posted by CodeRed [send private reply] at August 20, 2002, 12:19:10 AM

A menage a trois (pronounce "twa") is a threesome

Posted by CViper [send private reply] at August 20, 2002, 03:03:25 AM

redx: me too.. never liked french, and neither did the french (teachers) me.

Posted by RedX [send private reply] at August 20, 2002, 06:47:11 AM

Then imagine getting french lessons 2 houres a week for 10 years. And living in a country where a little less than half the population speaks mutant-french and the complete west border is next to France.

Posted by CViper [send private reply] at August 20, 2002, 02:02:58 PM

Hmm... now that sounds awefully lot like switzerland :) thats where i got my french lessons too (don't live there anymore though).

Anyway, you're lucky; you just had 2 french lessons/week..

Posted by regretfuldaydreamer [send private reply] at September 01, 2002, 12:02:05 PM

My French Teacher LOVED me ... I hated her, she was a bitch, and she always made me do twice as much work as everyone else 'cause I was the only person in the class who had a clue about any of her damned worksheets(well, 1 or 2 did, but they never did extra work). Luckily shes gone, no more listening to the whineing bitch. Class was sometimes funny though cause she had the worst possible set for a class, and they never stopped checking things around the room and shouting abuse at her, oh and French is the one class in our school that everyone insists on rebelling in.

Posted by RedX [send private reply] at September 01, 2002, 01:41:27 PM

"and French is the one class in our school that everyone insists on rebelling in." Sounds like my first year highschool to me. We studied computer gameology and practiced our hand-eye coordination on target practice.

Posted by regretfuldaydreamer [send private reply] at September 01, 2002, 02:24:02 PM

Well I suppose we rebel in Irish as well(Though I quit Irish, I learnt about 5 words in 3 years)

Dia Duit - Hello
Dia Is Muire Duit - Hello Back(Don't ask, Irishis seriously fucked up)
Is Mise Donal - My Name is Donal
Slan - Goodbye
coc- coke
bialann - Reasraunt
Iasc - Fish
Iascaireact - Fishing
Je joue ma flute - I play my flute , no wait thats French
- All you ever needed to know in Irish ;) Well actually it isn't but the only things I remember now are a couple of items of food - My Irish teacher was crap - he was called Freaky, His eyes wereso freaky and so was his beard.

- And NO American Pie Comparisons, I may be multilingual like Nadia and I may play the flute like the Band Camp Geek played by Alison Hannigan but
1) I'd never have sex on the internet
2) I'm not a girl so therefore I can't "And this one time, at band camp, I stuck a flute up my pussy".
And Yes I am in a band aand No I've never been to band camp.

Posted by CodeRed [send private reply] at September 01, 2002, 02:26:54 PM

Deutch ist gut!
Ich spreche Deutch gut!

Posted by unknown_lamer [send private reply] at September 01, 2002, 02:55:04 PM

Ja!

Only I thought "Deutsch" should be lowercase in this case?

Posted by CViper [send private reply] at September 02, 2002, 02:40:26 AM

chuchich?schtli (almost 100% chance that you pronounce it wrong)

Posted by buzgub [send private reply] at September 02, 2002, 03:12:57 AM

And it should be spelt correctly, just to be boring.

Posted by CViper [send private reply] at September 02, 2002, 10:42:44 AM

yeah.. don't know what happened to the '?' there though...

EDIT: grr.. make that character the stuff ä in html means.

You must be logged in to post messages and see which you have already read.

Log on
Username:
Password:
Save for later automatic logon

Register as a new user
 
Copyright TPU 2002. See the Credits and About TPU for more information.