?
Solved

JPG -> BMP

Posted on 1998-08-18
7
Medium Priority
?
1,349 Views
Last Modified: 2013-12-03
I have my app to load some BMP's from resources . The problem is that BMP's are really large .. and my EXE is > 3MB . I wonder how could I load JPG and convert it to a HBITMAP or something .. Can anyone help me ?

Thanks
0
Comment
Question by:WxW
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 8

Expert Comment

by:Answers2000
ID: 1413623
You can, but you have to write some code

Insert file as custom resource into your app, for VC5 do it like this
1. Insert Menu, click Resource...
2. click Import... on the dialog.  
3. Browse the filename and press Import button
4. For resource type type a string e.g. "JPEG" (without the quotes)
If you do this write you get a custom resource called something like IDR_JPEG1 which when you open it up you get a tonne of hex (hex dump of the file)

Now coding
1. Get an HRSRC resource handle using FindResource or FindResourceHandleEx
2. Call LoadResource using the HRSRC to get an HGLOBAL which is the handle to a block of global memory containg the data.
3. Assuming you got this far, GlobalLock to get a pointer to the data
4. Decompress the JPEG into memory (see below)
5. GlobalUnlock the HGLOBAL
Be sure to put error checking in through out, as most of the opps can go wrong if out of memory of called with bad params

To decompress this JPEG into an HBITMAP you need to write code to do this.  Most code I've seen does this files rather than memory.  
You can either adapt this from scratch, or if starting MFC based code override CFile to work on memory (or use CMemFile and Attach it to the RAM)

One site with JPEG code is (haven't tried this one)
http://www.cs.tu-berlin.de/~uzadow/paintlib/index.html (check for BITMAP.ZIP near the bottom of the page)

Otherwise you can get the necessary code from Stingray (Objective Toolkit) or Periphere (Weekly MFC) if you don't want to live with the above's licensing rules





0
 
LVL 6

Expert Comment

by:snoegler
ID: 1413624
At this internet address:
http://einstein.ae.eng.ua.edu/nishita/index.htm 

you can get the freely distributable freeware 'nviewlib.dll' which contains a really simple
API to load multiple file formats(jpg,gif, ...). Try it, i've been using it in a semi-commercial
(in-house) application, and i got no problems yet (about 3/4 year long)
0
 
LVL 6

Author Comment

by:WxW
ID: 1413625
I will process both options to see which is best and faster .
0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
LVL 6

Author Comment

by:WxW
ID: 1413626
I found the dll & lib more effective and useful , please snoegler answer . Answer2000 thanks anyway :)
0
 
LVL 8

Expert Comment

by:Answers2000
ID: 1413627
Well I didn't know about that.  Programming's always better if you can somebody else to write the code for you :-)
0
 
LVL 6

Accepted Solution

by:
snoegler earned 60 total points
ID: 1413628
Thanks :)
0
 
LVL 6

Author Comment

by:WxW
ID: 1413629
Thanks snoegler also .
Answer2000 : I agree that writing your own code is much much much much more effective and you are "proud" of it . But lemme tell you that my first decision to start such a heavy app with plain C++ and API ( not using MFC or most OWL libraries ) , has allready filled 50000 lines of code and I might need more 50000 . I am a little tired , so I prefer not doing things that others have ready for me ....

Cya
Michael
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question