OS2 World.Com Forum
2012.05.25, 23:17:04 *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Determine Image Size ( Bitmap and GIF )  (Read 2295 times)
jep
Global Moderator
Sr. Member
*****
Posts: 402


View Profile
« on: 2008.04.01, 09:39:47 »

Marked as: Easy
Hello,

found rexx code on the net how to determine the size of a bitmap image , but it was to bulky for me so I rewrote it.
Searched some more and found information in wikipedia http://en.wikipedia.org/wiki/BMP_file_format   
that contain alot of useful data about the bitmap format. There's a table that describe each part of the image format that tell you what to look for http://en.wikipedia.org/wiki/BMP_file_format#Bitmap_information_.28DIB_header.29 ( see table "Purpose" ).

That should be useful for other formats as well, so I used that to test gif images too http://en.wikipedia.org/wiki/Graphics_Interchange_Format.

Try yourself and write versions for other image formats!
Do also add tests to determine the real image format http://en.wikipedia.org/wiki/BMP_file_format#BMP_file_header first!
( Some people just rename the extension and think that's the difference between them ).



Code:
/* Determine size of images */

say rxGIFSize( 'Background.gif' )
say rxBMPSize( 'BlueBar.bmp' )
Return 0

rxGIFSize: PROCEDURE
    d = c2d( reverse( charin( ARG(1), 7, 2 ) ) )||';'||c2d( reverse( charin( ARG(1),, 2 ) ) ) /* In case bytes > 1 */
Return d

rxBMPSize: PROCEDURE
    d = c2d( reverse( charin( ARG(1), 19, 2 ) ) )||';'||c2d( reverse( charin( ARG(1), 23, 2 ) ) ) /* In case bytes > 1 */
Return d
Logged
warpcafe
Global Moderator
Hero Member
*****
Posts: 746


Failure is not an option.


View Profile
« Reply #1 on: 2008.04.01, 11:33:28 »

Hi jep,

wondering about the "code you found" that was too bulky... are you talking about gbmrx?
If not, check out gbmrx (from the gbm package). I found it to be very comfortable and reliable... OK, one has to use more dlls, but it's worth it I think and provides lots of features.

P.S.: Thanks for all your code snippets... I really like that idea.
How about putting this together into a -let's say- searchable snippets / knowledge base? :-)
One more question while we#re at it: Do we focus on "pure REXX" here (VIO rexx only so to say) or do we include the different GUI flavors (DrDialog, vx-rexx, etc.) too?

Regards,
Thomas
Logged

"It is not worth an intelligent man's time to be in the majority.
By definition, there are already enough people to do that"
- G.H. Hardy
jep
Global Moderator
Sr. Member
*****
Posts: 402


View Profile
« Reply #2 on: 2008.04.01, 17:58:20 »

Hello Thomas,

Nope, but since you brought it up... Grin
There's a rexx dll for it that can do most everything and it's very good. Visit Heiko Nitches homepage http://heikon.home.tlink.de/.

One drawback with the rexx version though is that it's a bit picky about what params you have to enter and you have to provide everythig even though you may only be interested in a fraction of the functions.

I used the included source code of the GBMScale executable to create a dll that may be easier for some to use as it can do most of the fancy stuff using only one function and it doesn't complain if you don't want to provide/add/use all params.

Regarding searchable snippets... well I hope you (Thomas) have accepted the position as the Moderator for this section? Be my guest/moderator Tongue and arrange searchable code snippets, I'll try to provide a couple every day (If I can come up with some).

Nope, not only command line... as this is in preparation for some heavier stuff, let's flood the market with knowledge! B.t.w. a little bird wispered in my ear that a "small" person has got some projects that he'd like to show as well. Let's hope he does!!!

//Jan-Erik

Hi jep,

wondering about the "code you found" that was too bulky... are you talking about gbmrx?
If not, check out gbmrx (from the gbm package). I found it to be very comfortable and reliable... OK, one has to use more dlls, but it's worth it I think and provides lots of features.

P.S.: Thanks for all your code snippets... I really like that idea.
How about putting this together into a -let's say- searchable snippets / knowledge base? :-)
One more question while we#re at it: Do we focus on "pure REXX" here (VIO rexx only so to say) or do we include the different GUI flavors (DrDialog, vx-rexx, etc.) too?

Regards,
Thomas
Logged
warpcafe
Global Moderator
Hero Member
*****
Posts: 746


Failure is not an option.


View Profile
« Reply #3 on: 2008.04.02, 17:08:45 »

There's a rexx dll for it that can do most everything and it's very good. Visit Heiko Nitches homepage http://heikon.home.tlink.de/.
That's exactly the one I meant.

One drawback with the rexx version though is that it's a bit picky about what params you have to enter and you have to provide everythig even though you may only be interested in a fraction of the functions.
...agree. However, I feel it's still better than nothing. At some point (and with limited skills and/or time) you just want to get something done and then it's OK. ;-)

I used the included source code of the GBMScale executable to create a dll that may be easier for some to use as it can do most of the fancy stuff using only one function and it doesn't complain if you don't want to provide/add/use all params.

WAIT!
Did I understand correctly that you are able to create DLLs in C which are callable from rexx?
If so - har-har, can I post my wishlist here? :-)

Regarding searchable snippets... well I hope you (Thomas) have accepted the position as the Moderator for this section? Be my guest/moderator Tongue and arrange searchable code snippets, I'll try to provide a couple every day (If I can come up with some).

Ehh... I don't know what you exactly mean by "accept the position"... Kim wrote me some time ago that I'll be given moderator status, and I said "thanks". As from the options in the forum, I seem to have moderator status now... if that is what you ask. ;-)
Still, it doesn't mean that I might be the right person for the job. What I can think of is some kind of CVS with web interface. That would enable multiple people to submit and work with snippets simultaneously (can't tell about available search functionality however).
Then again, "CVS at OS2World" this is the same topic as in http://www.os2world.com/component/option,com_smf/Itemid,63/topic,830.0/
where Christian admitted that it might be better to have such things at Netlabs. On the other hand - why not have a choice and put "live projects" sources to Netlabs CVS while "code snippets" are stored here?

Nope, not only command line... as this is in preparation for some heavier stuff, let's flood the market with knowledge! B.t.w. a little bird wispered in my ear that a "small" person has got some projects that he'd like to show as well. Let's hope he does!!!
Who told you that?? :-) Rumors, rumors... I will ask that guy when I next meet him. Sometimes he's just too busy with other things but I agree that some code samples might be useful for others too.

Regards,
Thomas
Logged

"It is not worth an intelligent man's time to be in the majority.
By definition, there are already enough people to do that"
- G.H. Hardy
RobertM
Global Moderator
Hero Member
*****
Posts: 2017



View Profile WWW
« Reply #4 on: 2008.04.03, 02:23:43 »

There's a rexx dll for it that can do most everything and it's very good. Visit Heiko Nitches homepage http://heikon.home.tlink.de/.
That's exactly the one I meant.

One drawback with the rexx version though is that it's a bit picky about what params you have to enter and you have to provide everythig even though you may only be interested in a fraction of the functions.
...agree. However, I feel it's still better than nothing. At some point (and with limited skills and/or time) you just want to get something done and then it's OK. ;-)

I used the included source code of the GBMScale executable to create a dll that may be easier for some to use as it can do most of the fancy stuff using only one function and it doesn't complain if you don't want to provide/add/use all params.

WAIT!
Did I understand correctly that you are able to create DLLs in C which are callable from rexx?
If so - har-har, can I post my wishlist here? :-)

You could probably turn any DLL (in various languages) into a REXX callable DLL. There are various programs out there written in other languages with REXX callable components and there are examples in the Programming Toolkits (which should come with WSeB and eCS). C should be very "easy". I think the toughest thing to take into account is the differences in how the two handle memory - unless you like buffer overruns.  Wink

...and no... I've never written a REXX callable DLL, so I cant help there. On a side note, you should be able to call any rexx dll function from within C (since it is really a C function exported to something rexx callable), and there is also a utility out there (rexx dll) that allows you to call various C functions from REXX that would otherwise be inaccessible (never used it - but I think I saw it in Rexx Tips and Tricks).

-Robert
Logged

|
|
Kirk's 5 Year Mission Continues at:
Star Trek New Voyages
|
|

jep
Global Moderator
Sr. Member
*****
Posts: 402


View Profile
« Reply #5 on: 2008.04.03, 15:30:59 »

...agree. However, I feel it's still better than nothing. At some point (and with limited skills and/or time) you just want to get something done and then it's OK. ;-)
Yes, I totally agree, but when it's a pain to use then you begin to investigate how things can be done differently as I did. Reusing already written code by Heiko (for gbmsize.exe) was very easy to do, let's see if more people can do that (copy & paste basically)!

WAIT!
Did I understand correctly that you are able to create DLLs in C which are callable from rexx?
If so - har-har, can I post my wishlist here? :-)
Duh!!! Roll Eyes
Hahaha, shouldn't have told you about that one I guess.

Go on, post all your wishes, maybe Santa will hear you! (If no one else can help out before that)

Ehh... I don't know what you exactly mean by "accept the position"... Kim wrote me some time ago that I'll be given moderator status, and I said "thanks". As from the options in the forum, I seem to have moderator status now... if that is what you ask. ;-)
Still, it doesn't mean that I might be the right person for the job. What I can think of is some kind of CVS with web interface. That would enable multiple people to submit and work with snippets simultaneously (can't tell about available search functionality however).
Then again, "CVS at OS2World" this is the same topic as in http://www.os2world.com/component/option,com_smf/Itemid,63/topic,830.0/ where Christian admitted that it might be better to have such things at Netlabs. On the other hand - why not have a choice and put "live projects" sources to Netlabs CVS while "code snippets" are stored here?
It's settled then, WarpCafe will be the moderator for the rexx area! The OS2WF board discussed your suggestions and my personal opinion is that the additions mentioned above should be added asap. ( except the part about Netlabs... to much "techno geek"/"assembler freak" about it ).

Who told you that?? :-) Rumors, rumors... I will ask that guy when I next meet him. Sometimes he's just too busy with other things but I agree that some code samples might be useful for others too.

Regards,
Thomas
You can ask him that the next time you look in the mirror!  Grin

Thank you WarpCafe for the excellent arrangement at Warpstock in Köln 2006.
//Jan-Erik
Logged
warpcafe
Global Moderator
Hero Member
*****
Posts: 746


Failure is not an option.


View Profile
« Reply #6 on: 2008.04.03, 15:40:10 »

You can ask him that the next time you look in the mirror!  Grin
I know... Wink

Thank you WarpCafe for the excellent arrangement at Warpstock in Köln 2006.
You're welcome! Did you enjoy the session/tpoic collection? I usually feel that "programming for beginners" is something that is missing from the list. Perhaps with a hands-on workshop - it would show people that it's not too complicated to start with it. I tried to prepare something about rexx and GUI but didn't had the time required. Hmm. Perhaps this year there is something I could do - no guarantee though.
Logged

"It is not worth an intelligent man's time to be in the majority.
By definition, there are already enough people to do that"
- G.H. Hardy
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.14 | SMF © 2006-2011, Simple Machines LLC Valid XHTML 1.0! Valid CSS!