CreateIcon from Gdiplus::Bitmap - winapi

Can you post example code,
to show how to CreateIcon() from Gdiplus::Bitmap?
I want to convert png, jpg, bmp to icon in memory

You can do that with the Gdiplus::Bitmap::GetHICON() method.
Remember to free the icon with DestroyIcon() when you're done with it.

Related

Is it possible to turn a png into a layered PSD file?

I have a PNG image that I would like to turn into a layered PSD image. The image itself is mostly white space with several areas of text.
I tried to convert this PNG to a PSD but I ended up with a flat image.
I am not too versed in image processing. Is there any service that can recognize areas of white space and turn the various components of an image into layers?
Sorry png or jpeg files cannot be converted into layers . For this, you need to break the image into layers and then convert the file as .psd
Yes .PNG can be layered (from Macromedia Fireworks back in the day)
I still have about 100,000 layered files in .PNG
If I remember right Corel Draw can convert these files.
Yes, but in Adobe Fireworks CS6 .PNG format.
Save your document with the Photoshop layers in .PSD format in a folder
Open saved .PSD with Adobe Fireworks CS6
In Fireworks CS6, click 'File' then 'Save As' and select the first 'Fireworks .PNG' format option. You will notice that the name of your file will have the following extensions: [name.fw.png].
Save
PS. Never Save to "PNG level.PNG" because the layers will be unified. Just like it should not be exported to any .PNG. That is, just save the .PSD document to .FW.PNG.

Convert png image to gif without losing transparency

Hi,
I have a transparent png format image.But SAP system does not support PNG format.So I want to convert it to either GIF or JPEG. I tried to convert it using Adobe Photoshop and some other tools but the resulted image loses its transparency. Can any body please tell me solution ??? Here is my image
yes you can convert png to either GIF or JPEG without losing transparency.......
this is done though the help of php lang...
<?php
$src = imagecreatefrompng("original_image.png");
$newImg = imagecreatetruecolor($nWidth, $nHeight);
imagealphablending($newImg, false);
imagesavealpha($newImg,true);
$transparent = imagecolorallocatealpha($newImg, 255, 255, 255, 127);
imagefilledrectangle($newImg, 0, 0, $nWidth, $nHeight, $transparent);
imagecopyresampled($newImg, $im, 0, 0, 0, 0, $nWidth, $nHeight,
$imgInfo[0], $imgInfo[1]);
imagejpeg($newImg,"jpec_test_1.JPG",100);
imagedestroy($src);
imagedestroy($newImg);
?>
You can't convert to JPEG as it does not support transparency. You should be able to conver to a GIF, just make sure to check the box next to transparency. However, the image you linked to actually does not appear to have transparency. Luckily, the image is a very simple gradient and you can easily reproduce this in Photoshop and then save it out as a GIF w/ transparency.
Even if I didn't quickly succeed to accomplish that with the Gimp, I've found a site which suits your needs. It is a online tool: you haven't to download anything, just upload your png image and then download the generated gif. Try it:
http://images.my-addr.com/converter_png_to_gif_online_freeware_tool.php
Hope it helps.
As noted by #Valjas, you JPEG doesn't support transparency. If you are converting just for reducing file size as JPEG has better compression, you might want to use https://tinypng.com/. It also has an API. I just used it for reducing file size of few PNGs.
BTW, I found this information while I was chasing the same problem ;)

How can i use GDI+ to save a HBITMAP

I want to save my created image as a PNG or JPEG file with the help of GDI+ but i can't find a way to do this. Seems that there is no way to create a non file based Image and fill it with a bitblit from the HBITMAP.
Or do i miss something?
Use the Bitmap::FromHBITMAP() method. Then just Save() it.

How to modify a .png image with VBScript

I have a need to select a portion of a .png file, with specific cordinators, and delete this area then save the file back with the same name.
I would appreciate if you can help to come up with a VBScript script that can accomplish this task.
It would be great if all proesses happen in the background, but it would be ok too if the image file has to be open and visible. Thanks a bunch!!!
A PNG file, like any other binary file can be edited with CMD or VBS.
A PNG file layout is as follows:
File header
"Chunks" within the file
Pixel format
Transparency of image
Compression
Interlacing
Animation
Read the PNG format in RFC 2083 to know how to edit/create a PNG file at binary/bit level.
To speed up the editing process, libraries are available for application level editing.
Here are some VBA codes for image manipulation.
ImageMagick also provides libraries that can be accessed via VBS for image editing.
Here's a VBScript Image Class for bmp and pcx files (which PNG can be converted to before editing via WIA).
Loadpicture function described here doesn't seem to support PNG, but this discussion might solve it.
The Windows Image Acquisition Library v2.0 supports PNG, BMP, JPG, GIF and TIFF image formats, and comes with Windows Vista and later versions. Sample scripts are available to demonstrate "image manipulation using the ImageFile object". The Vector.ImageFile property also "creates an ImageFile object from raw ARGB data".
More sample codes here & here show how to rotate, flip, scale, crop, etc with WIA Image constants in vbs. To remove unwanted areas of image (with given coordinates), use the crop function.
Here's a discussion of WIA 2.0 image editing on stackoverflow.
VBScript doesn't have any image editing functions, so you need an external tool for that. For example, GIMP can do image processing from the command line (see here). ImageMagick provides a scriptable component in addition to the command-line interface (details here).
To run a command line from a VBScript script, you can use the WShShell.Run method. To create an instance of a COM scriptable component, use the CreateObject function.

JPEG Shows in Firefox but Not IE8

I'm working on a Sidebar Gadget and cannot get my JPEGs to show up (PNGs work). When I try to open the file by itself in IE8 it doesn't work. Firefox, of course, can open it fine.
JPEG Details:
Dimensions: 1080X900
180 dpi
Bit depth 24
Color representation: uncalibrated
I've found some things talking about the images being compressed incorrectly (?) but I haven't been able to get it working...
Any clues?
IE8 drops support for CMYK JPEG and renders them as the infamous red X without so much as a warning.
If you have ImageMagick:
identify -verbose image.jpg
will show you the image colorspace. If it's CMYK, you can convert to RGB with:
convert broken.jpg -colorspace RGB fixed.jpg
If you need to do CMYK to RGB conversion on a whole batch of JPEG-images, this command may be helpful to you:
for i in *.jpg; do convert "$i" -colorspace RGB "$i"; done
PS: If you'd like to see what is going on, just add -verbose:
for i in *.jpg; do convert "$i" -colorspace RGB -verbose "$i"; done
I had a similar issue with IE8 not displaying two JPEG images. FF, Safari, Chrome all displayed them without complaint but IE acted as if the files were not there. I have no idea what was going on, but a quick image conversion to gif or png fixed the problem. Just another in a long line of confirmations that IE sucks.
Had similar problems with existing images, which will not show up in IE8.
Problem is, as converter42 says: CMYK-Images
Convert them to RGB colorspace and all is good
The Solution with the PNG is not the best, because PNG files can be MUUUCH larger than JPGS.
If you are using photoshop for creating the jpgs. Try the below.
Open the file and go to 'Image' menu
Go to Mode
Select RGB
Save and upload to server.
This should work.
Why are you dealing with the image at 180 dpi and not the 72dpi screen resolution? At screen resolution the image will be roughly double that size. Still, the size is manageable for any browser.
When creating a gadget, you should be using PNGs for all the elements of the gadgets. Are you having issues displaying JPEG photos?
Have you looked for the yellow bar at the top of IE that blocks certain suspicious content from being loaded (popups, activex, javascript, etc.)? If it appears, try telling it to "allow".
Lastly, what are you using to compress your images to JPEG?
EDIT: If you want to do batch conversion use the batch converter in photoshop or use the Actions panel to record the conversion process for a single image, then replay the action on an entire folder. Additionally, you can save this action to a "droplet" which is a small application containing the action that you can drop an image or folder on top to.
Alternatively, if you don't fell like learning Actions, XNView is an excellent image viewer and converter that supports something like 160 different image formats and can batch convert and batch rename huge lists of files.
I fixed this issue by opening the CMYK JPEG file in Windows Paint and then saving as a JPEG, which Paint encodes as RGB by default. Not a great solution because I'm sure that Paint's converter is not as robust as Photoshop's, but this can be a quick fix if the job needs to be done now and there's no access to the tools above.

Resources