I am working on a program that should be basically a paint program but with the possibility to save the drawn image to like 5 formats or so. So I figured out that in order to save it I need to draw on bitmap. But when I try to save the image, in the drop down menu I have only one option and it shows the two formats next to each other, and it always saves it as .bmp. http://s8.postimg.org/97wj3x2v9/Bez_n_zvu.jpg
I am using a save file dialog. How can I save it to more formats? For example .jpg, .png and others?
This is the code for saving i curently have.
{
saveFileDialog1.Filter = "Image Files (*.bmp, *.jpg)|*.bmp;*.jpg";
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
bitmapa.Save(saveFileDialog1.FileName);
}
}
The filter is divided to two parts: description of the filter and the filter pattern.
For each format you need a "filter"(a new description and pattern). So for .bmp, .jpg and .png:
"Bmp Files (*.bmp)|*.bmp |Jpeg Files (*.jpg)|*.jpg |Png Files (*.png)|*.png";
description pattern description pattern description pattern
And if you want a general filter for all three formats:
"Image Files (*.bmp, *.jpg, *.png)|*.bmp;*.jpg;*.png|Bmp Files (*.bmp)|*.bmp|Jpeg Files (*.jpg)|*.jpg|Png Files (*.png)|*.png";
Related
Noticed that images sometimes are sliced up in PDFs.
Steps:
insert an image with a high resoultion (3000x1800) into a .docx
use "Microsoft Print to PDF" option of Word to convert to PDF
extracting all images with pdfimages or pymupdf
Result:
Image is sliced horizontally into three images
Questions:
What exactly happens in the in the transition from .docx to pdf (or in generell in the process to pdf) that makes the converter slice it up into three images instead of one?
Do the individuell XObjects of the sliced images contain information which says that these three images belong to originally one?
How do I know how the images are sliced (horizontally / vertically) and what if originally there were two images inserted into the .docx file and both of them are sliced. Can you tell if slice x belongs to original image y or z?
So, as you have found out: because the code which generates the PDF choose to do so.
The technical reasons may be various - it could be that historically there were printers which would only have so much memory, and would need to get limiterd size-images when printing, and someone at some point when writing the PDF export code present in Microsoft Office choose to apply this limit.
Anyway, technically, as put in the comments, an image in a PDF file could be composed of unlimited smaller images collated together.
Now, the second part, and your actual question: to know whether images ibn a PDF file belong together in a single original image one would need a custom extractor tool to check the geometry of all images in the document and find out which images have no margins or boundaries with others - it would not be that hard to do for well behaved files (which we can't know if MS Office generated files are: there are ways to obfuscate image positioning by making it indirectly). The metadata in the image-parts may or may not contain information that would allow one to recompose the original image: it would be up to the code generating the PDF to include this metadata or not - but the geometry can't lie in this case: if the final document presents a single image visually, it is possible to detect that when fetching the images.
I don't have much knowledge of imaging tools but I need to extract images contained within the layers of a psd file. I tried using GIMP with a "save all layers" plugin but that is just saving the root layers so I am ending up with just two .pngs. I need every image in a separate file with the correct sizes.
The reason I need the files is that I have been asking to create an animation with CSS using the images. An example animations is at http://srv1.contobox.com/frontend/ads/preview.html?id=981
The psd document I am trying to extract is
https://www.dropbox.com/sh/ud2eaesej08o0g3/AAAi-_pPHGESOFOBpA0uQfjta
The problem is that these files are structured with Layer Groups (I opened just one of them).
While GIMP is supporting open the file, the "save all layers" plug-in you are using probably is not aware of layer groups.
(BTW, GIMP unstable - the 2.9 development version is likely currently broken for opening PSDs - the image opens garbled there. It opens in gimp 2.8.10, though)
It is possible to save all layers - including sublayers, as separate images with an interaction in the Python console.
With you PSD being the only image open in GIMP, go to filters->python->console and type something along this:
img = gimp.image_list()[0] # retrieves a reference to the image
folder = "/tmp/" # folder of you choice for saving the files
counter = 0
def save_recurse(item):
global counter
if hasattr(item, "layers"):
for layer in reversed(item.layers):
save_recurse(layer)
else:
counter += 1
name = folder + "layer_%03d.png" % counter
pdb.gimp_file_save(img, item, name, name)
save_recurse(img)
(btw, I typed it here in a way you can just copy and paste the listing above in GIMP's Python console)
I have question about creating a binary / raw image file.
I've made an image in photoshop and now I want to load that in a C program.
I followed this tutorial http://www.nullterminator.net/gltexture.html but I don't know how to convert my own image to a .RAW file.
Can anyone help me out with this question?
Download ImageMagick, it is a command-line utility that can convert images into all kind of ways. And it supports many platforms.
So you could save your file in Photoshop to for example a PNG file, then run the following command to convert it to raw grayscale 8 bit:
convert MyImage.png -depth 8 gray:MyRawImage.raw
Try Save As and selecting RAW from the format drop-down. Humorously, it is listed under "P" for Photoshop RAW.
I don't know if it is the right kind of RAW which GLUT requires...
This worked for me, with that tutorial code:
Open your image in GIMP
Go to Layer/Transparency/Remove Alpha Channel. If it's already removed the option will be greyed out, which is fine. If you have
multiple layers, do this for all of them. (You MUST remove the alpha channel or else GIMP will write RGBA instead of RGB, and you'll just see a repeating lattice pattern instead of your image.)
File/Save As... and at the very bottom of the save popup, there's an option "Select File Type (By Extension)" with a (+). Expand it.
Select Raw image data
At the top of the save popup, manually give your file a .raw extension and save. Click OK to accept the default options.
Then you should be able to save it, move it to your program's directory, and read it in with the code from that tutorial.
Also, to save yourself another headache source, I suggest adding an error message if the file isn't found, like replace the line
if ( file == NULL ) return 0;
with
if ( file == NULL ){
printf("texture file not found.");
return 0;
}
When we try to save msword doc file as html file we get "wmz" files for the math equation objects.
I tried decompressing the wmz file and saving the content as jpg.
I can open this jpg file in the "Microsoft Picture manager" properly. But trying to open the file in browser displays the error message "The image cannot be displayed, because it contain errors".
What is the procedure to decompress this wmz file and convert it to jpg.
What will be the extension of decompressed file?
.WMZ seems to be a zipped .WMF file.
You can open the unzipped file with a picture view/editor (just tried IrfanView) and save as .jpg.
When you save your Word documents as "Web Page, filtered" you won't get these WMZ files but just PNG files.
Set the "Web Options" to target to a low version of IE (i.e. 4.0) and check "allow PNG files" and "disable features not supported by these browsers".
Added advantage is that the webpage will display better in different browsers.
However, you should do all of this after you first make a copy of your document (and associated files) using Explorer into another location. Open this copy with Word and then Save as "Web Page, filtered". The original you keep for editing. (Don't save the original as a "web page, filtered" or you will loose the ability to edit the equation objects).
Thanks for the help.
Finally i could not remove the black background from the image file.
So using the round about approach for now
1)Decompress the wmz file to byte array(wmf).
2)Open a new word document
3)Paste the byte array into word document.(this document should only contain this data, and no other extra information)
4)Save the doc as html file (WdSaveFormat.wdFormatFilteredHTML)
5)open the "_files" directory created for the html output
6)Find the only "gif" file created inside the directory
I ran into this trying to throw together a simple Automator script to combine several one-page PDF files. I had 88 files to combine, each just about exactly 300KB, so I expected the final product to be about 30MB; the resulting PDF file, using the Combine PDFs Automator action, was 300+MB.
Poking around, the Automator action uses a Python script, with Foundation bindings, to create the new PDF document with the CoreGraphics PDF APIs. Nothing seems out of place. Basically, it's doing this (simplified, but these are the high points):
writeContext = CGPDFContextCreateWithURL(outURL, None, None)
for url in inURLs:
doc = CGPDFDocumentCreateWithURL(url)
page = CGPDFDocumentGetPage(doc, 1)
mediaBox = CGPDFPageGetBoxRect(page, kCGPDFMediaBox)
CGContextBeginPage(writeContext, mediaBox)
CGContextDrawPDFPage(writeContext, page)
CGContextEndPage(writeContext)
CGPDFContextClose(writeContext)
I can't imagine that CGContextDrawPDFPage, when drawing to a PDF context, would do anything but copy the PDF data for that page (with some window-dressing).
Even when "combining" just one PDF, the output is 2.8MB, compared to the 300KB original one-page PDF.
The resulting PDFs look exactly the same page-by-page as the original pages: text is selectable in the same places, graphics look identical, the pages are exactly the same size.
Any ideas?
Do the input PDFs contain the same set of fonts, or different sets? Maybe if the originals don't contain embedded fonts, but the output does, that could account for some of the growth.