Tnasparent JPEG

I have many large pictures that need to display them with a transparent background. The JPEG gives me the best compression on these images then I prefer to use JPEG format. I tried to change pictures to bitmap and apply transparency to bitmap when I need to display them but pictures show as noisy.

There is any way to show JPEG images with a transparent background? Or do you know any other compression algorithm with power of the JPEG compression.

Thanks in advance for you help.

LVL 2
kambizAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TheNeilCommented:
JPEG compression works by being 'lossy' and because of this you won't be getting flat colour anymore which is why your Bitmap approach won't work (transparency works on only one colour but the 'flat' areas of your image are now made up of several colours). There isn't anything that offers JPEG compression that ISN'T lossy so you're going to hit this problem all the time.

A possible solution is to convert the JPEG to Bitmap (as you tried) and then go through the image and replace all the colours SIMILAR to the one that you want to make transparent (e.g. if you're treating black as transparent then replace all the colours CLOSE to black to actual black). Sadly this is a slow process as you're processing the image on a pixel level. Things can be sped up a lot by using scanlines.

If you need some sample code then just ask.

The Neil
0
kambizAuthor Commented:
Thank you Neil,

Do you know other image format (except GIF) or any other compression algorithm that can be used for my situation.

0
kifahCommented:
My advise is to use bitmap, because it is large file, but faster in display, all other format's like tiff, fractals, jpeg, gif, or any other format, they will be small size, but slower in display, especially if they are very large images.

so if you are plan to store your bitmaps in your exe (not advised), you willhave a large exe file, but the as you know, the user dose not care for some more time at load time, if you comapre it in the diplay time...
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

TheNeilCommented:
Another compression system for images. Hmmmm. It all depends what you're trying to store. If you're storing 16.7m colour images (espcially scanned images) then JPEG is your best bet (fractal comprfession is even beter but far too slow) but whatever format you use you'll hit your original problem.

You would be a lot better off using 256 colour images - they're smaller, there are a lot more formats that handle it, they are usually NON-lossy (no quality loss), and you have a better chance of solving your original problem. I would suggest GIF but you say EXCEPT GIF then my next suggestion would be PCX. It might be a bit old but it's really easy to understand (and therefore code if you want to do it all by hand rather than get a component) and offers fairly good compression on images that have a lot of flat colour BUT if you're dealing with scanned images or images which DON'T have a lot of flat colour then it can be really INefficient.

What type of images are you dealing with?

The Neil
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JaymolCommented:
Kambiz : I've done this kind of stuff before.  If you like, email me a zip file of your code and JPEGs and I'll go through it for you. (jaymol@hotmail.com)

Ta,

John.
0
kambizAuthor Commented:
Thanks everybody,

I found my mistake by The Neil's comment. Thank you Neil. I actually need 256 colors and I have used 16.7m colors. Why? I don't know.

But there is another problem. Let I first explain more about my job.

I have written an Office 97 Assistant package (for public domain) with all features that you have seen in Office 97. For animations, I have provided a special formats because each frame of the animation can be had a sound and many branches. I also have provided an editor to create actor of the assistant (This cause the problem). The actor actually is a DLL that loads by the assistant component. Each actor has at least 64 animations with average 15 frames. Animations store as LZH compress format.

Now the problem:
If I reduce the color depth to 256 color I will have about 60% reduce in the actor size.
Reducing the color depth cause the image loses its colors. The error diffusion method gives the best appearance for reducing the color depth but I don't know its algorithm.

John, If you still have a solution, I’m ready to send you the source of the actor editor.

Thank you again,
Kambiz

0
JaymolCommented:
Kambiz - Okay, let's have a look at it.  (I'll do my best for ya!)

John.
0
kambizAuthor Commented:
Thank you friends. I solved my problem and the Neil's comment leads me to the solution. I give points to The Neil.

John - You can download the Package and the Actor Editor from my homepage about 10 days later.

http://www.geocities.com/k_khojasteh/
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Graphics Software

From novice to tech pro — start learning today.