Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
jpg and tga
#1
how would i got about loading a jpg image in fb w/ and w/out using any libs .. .ok, and howw about a tga??? where can i dload other libs?
url=http://www.random-seed.net][Image: asylumsig.png][/url]
Reply
#2
For JPEG wait until Antoni finishes porting his loader.
For GIF you can try Rich Geldreich's one which I ported and posted in this forum two days ago.
For TGA/BMP/PCX there are plenty for QB, you just have to port them.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#3
In XP, there are GDI+ API calls delaing with JPEGS. Unfortunately they only works in XP...

When did i say I was porting the loader? It was supposed to be a secret...I speak too much :oops:

In fact the huffman decoder is giving me some headaches. My "creative" bit operations are not easily ported...
Antoni
Reply
#4
You can do it using SDL_image... but you would have trouble trying to load it on your own (the decompression algorithms for JPG and TGA are complex and confusing Smile).

Download Example ZIP

Here is an example of doing it with SDL_image.

[syntax="FreeBASIC"]
DIM myFirstImage AS SDL_Surface PTR
DIM mySecondImage AS SDL_Surface PTR

myFirstImage = IMG_Load("something.jpg")
mySecondImage = IMG_Load("something_else.tga")
[/syntax]

You should check whether the loading failed - this can be done by checking for either of the pointers being NULL (zero). Example:

[syntax="FreeBASIC"]
IF myFirstImage = 0 THEN
PRINT "Failed to load first image!"
SDL_Quit
END
END IF
[/syntax]


There is a more detailed example in the ZIP file I've put a link to at the top of this post.

By the way, you need to include a lot of DLLs if you use SDL_image. Smile

Hope this helps.

-shiftLynx
img]http://www.cdsoft.co.uk/misc/shiftlynx.png[/img]
Reply
#5
By the way, here is a full list of the types of images you can load with SDL_image: BMP, PNM, XPM, XCF, PCX, GIF, JPEG, TIF, PNG, TGA and LBM.

Just use IMG_Load to load any of them.


-shiftLynx
img]http://www.cdsoft.co.uk/misc/shiftlynx.png[/img]
Reply
#6
dang shiftLynx....your @ the top of my 1337 c0d3rz list!!! Big Grin
url=http://www.random-seed.net][Image: asylumsig.png][/url]
Reply
#7
hmm, i know the jpg is smaller in size compared to a bmp, but sinse its harder to load, or more is done to load it than w/ bmp, would it be more efficient to use a bmp??? or a jpg???
url=http://www.random-seed.net][Image: asylumsig.png][/url]
Reply
#8
Happy to help. Big Grin

It would be better to use JPG (or TGA or any other of those compressed formats). Once the IMG_Load function has loaded the JPG into memory, it is in the same format as any other BMP would be - the loading routine decompresses the file into its full form, which is then stored in memory.

Therefore, there is no difference in efficiency between using BMP or a compressed format - the only reason it would be better to use a compressed image file format is that the files you distribute with your program will be much smaller. Smile

-shiftLynx
img]http://www.cdsoft.co.uk/misc/shiftlynx.png[/img]
Reply
#9
thnx again...
url=http://www.random-seed.net][Image: asylumsig.png][/url]
Reply
#10
Quote:hmm, i know the jpg is smaller in size compared to a bmp, but sinse its harder to load, or more is done to load it than w/ bmp, would it be more efficient to use a bmp??? or a jpg???
It is more efficient to use BMP, and also preferred if you need to retain pixel perfect image quality since JPG is lossy. Use JPGs for stuff like photographs and realistic textures, but BMP is better suited for sprites and abstract textures.
I'd knock on wood, but my desk is particle board.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)