png to jpg
-
hi how can i convert image that is 32bppArgb (png image) to jpg so if the image is Transparent i don't get a black image, or if the image is semi Transparent (like red color and 50 % alpha) i get the color like the png image and not a full color?
The jpg format does not support an alpha mask, png does. Therefore, this will be lost when you convert to jpg. The rest of your question makes no sense to me.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
-
hi how can i convert image that is 32bppArgb (png image) to jpg so if the image is Transparent i don't get a black image, or if the image is semi Transparent (like red color and 50 % alpha) i get the color like the png image and not a full color?
Hi Nryk, This response assumes you are not using WPF. Well, if you want to do this outside your own code, any tool like ACDSee will convert your .png with transparency to a .jpg which looks okay : I have not experimented with this to any depth, but the default settings of ACDSee's .jpg conversion will produce a file with the transparent areas rendered in white. I would guess it is possible in PhotoShop (I use CS4) to change the settings when you save as .png (while PhotoShop only shows a 24bpp option .png, in fact it does save the alpha) so that what color shows up in the .jpg (where the transparency was) trasformed by ACDSee varies, but that's a guess. I have never tried making a .png in PhotoShop with partial transparency (unless this is a side-effect of "feathering," which I use often, that I am not aware of). But now that you mentioned it, I am curious to experiment. If you are doing conversion at run-time in your own code, I would guess you are going to have to construct a new bitmap and interpolate the alpha values into tints of color (luminance values ?) in the rgb source. But I would certainly go and research this with Google, and on StackOverFlow, and, of course, right here on CP. I would also advise you to check out Bob Powell's win forms and graphics for .NET sites (somewhat out of date, but still full of great hints and tips if you are using WinForms) : Tips/Tricks[^] GDI+ FAQ[^] Check out the CP AlphaForm article[^], by Jeff Anderson, and his source code, for great information on transparency via Layered Windows. While it is not specificly targeted at .png, I think you'll find it valuable. You can check out my raving about Jeff's article[^]; in that message I include a link to a very valuable on-line resource for understanding .png optimization. best, Bill
"Many : not conversant with mathematical studies, imagine that because it [the Analytical Engine] is to give results in numerical notation, its processes must consequently be arithmetical, numerical
-
hi how can i convert image that is 32bppArgb (png image) to jpg so if the image is Transparent i don't get a black image, or if the image is semi Transparent (like red color and 50 % alpha) i get the color like the png image and not a full color?
JPG doesn't have alpha layers In C++, if you are willing to assume you would be drawing the PNG image on a black background, look up AlphaBlend. You could draw the PNG to a bitmap or just create a 24 bit image using the raw bytes. The BLENDFUNCTION documentation has a chart of the multipliers you need to use. It looks confusing, but is rather straightforward once you think about it. I'm not sure the equivalent of AlphaBlend in C# (outside of the DirectX classes.) Again, if you assume the background, you could do it yourself. http://msdn.microsoft.com/en-us/library/aa452889.aspx[^]