It's easy to convert from cur-file to bitmap, using the LoadCursorFromFile API call and calling DrawIcon(..., hCursor) on that bitmap.
But how can I load it from stream without too much handcoding and convert into TBitmap?
There is an MSDN library article that describes the .cur and .ico file formats in great detail. It's pretty easy – I wrote some Delphi code to read .ico files not so long ago using this article as my reference.
Use Kicon.
Related
I am currently in the process of building a Brachiograph plotter. I am 75 years old and have a minor disability with my hands. I would like to find out if anybody can tell me how I can output Turtle Graphics to a file that can be read by the Brachiograph plotter. I believe that the linedraw.py converts a .svg to a .json file that is read by the Brachiograph. I would like to create some fractal image files and print them with the Brachiograph.
Thank you for any help that you can offer with this project.
Dick Burkhartzmeyer
Welcome to Stackoverflow. In your OP you state "I believe that the linedraw.py converts a .svg to a .json file[...]". Looking at the documentation it looks like linedraw.py will convert a bitmap to an svg file and a json file.
From the documentation:
The main use you will have for linedraw is to take a bitmap image file
as input, and save the vectorised version as:
an SVG file, to check it
a JSON file, to draw with the BrachioGraph.
The way I would approach this is to create an svg with Turtle and then in your Python script convert that to a png. Then linedraw.py can be used to convert that to your JSON BrachioGraph file. I found a solution to do that in another SO thread. The answer in that thread is using Cairosvg to convert the SVG to PNG format.
I need a sample code for converting DocumentFormat.OpenXml.Presentation.shape into a HTML SVG element in .net. Please help me for this.
Thanks in advance.
RagesH.
If the presentation has shapes stored as a WMF image, then you can pass the images as a file or stream and convert it to SVG format. There are tools to convert WMF2SVG.
Refer this page.
This is for Java https://code.google.com/p/wmf2svg/
For using it with .NET, you have to convert this Jar into DLL and use it.
For Converting Jar into DLL refer this https://code.google.com/p/jar2ikvmc/
This works for me.
Hope this helps!
I want to store small bitmaps in a text file similar to the way Delphi does it with it's dfm files.
Is there a function in the RTL or VCL that I could use to do this?
I suggest that you do the following:
Save to an in memory stream. Use TMemoryStream, and call SaveToStream on the bitmap.
Compress the stream, perhaps using the zlib unit. This step is optional.
Encode the stream using base64. For example you can use the functionality provided by Soap.EncdDecd.
And in the opposite direction, well you just reverse the steps.
Textual DFMs use the BinToHex() function to format binary data.
You can simply use Win32.WriteFile to write your bitmap-buffer into a file.
I am writing a program in Delphi which should get the date and time of the picture which was taken with photo cam and then it would rename the file to include the date+time it found.
So far i have achieved that by opening file as binary and searching for a special order of bytes. These bytes were then followed by the date and then time. So i've come to a problem. Actually few problems.
Because it reads the file 1 byte after another, reading a file is a slow process. If the date was found, it is usually at the start of file, it doesn't take long, however if 'special byte order' was not found, it will read the whole file. So my method is way too slow.
The special byte order may change in some pictures (i have no idea why) even if it was taken with the same camera. So my program sometimes fails to find the date in the file even though it is there.
Windows explorer has no problems finding date in all of the pictures, so i was thinking maybe there are some kind of special functions which could get me what i need?
How do i get the information i need from the picture so it works with all the formats?
Thanks
I think you only need to look at the EXIF information. http://en.wikipedia.org/wiki/Exif
There are some open source tools which accomplish that, but I don't know of anything Delphi specific. If you're not scared of Java, you can have a look at the source code of this open source project: http://sourceforge.net/projects/jexifviewer/ to see how they evaluate the date field.
You can then optimise your reader, to only look at the relevant area. You might want to keep in mind that the Endianness in Java is different to Delphi.
Jules is right about Exif data; you might want to try this Delphi library:
http://delphihaven.wordpress.com/ccr-exif/
This is an amazing site to view Exif data.
http://regex.info/exif.cgi
If it is a graphic file (as in your case), to open it with a dialog box, place a TOpenPictureDialog component on the form.
Also place the component TLabel, for displaying the date of creation of the file.
In the button's place the following code:
if OpenPictureDialog1.Execute then Label1.Caption := DateTimeToStr(FileDateToDateTime(FileAge(OpenPictureDialog1.FileName));
In order to open jpeg and png files in the code, in the line uses you need to add the name of the two libraries, JPEG, PNGImage.
If you have the full address of your file, you can write the code above instead of the code above:
Label1.Caption := DateTimeToStr(FileDateToDateTime(FileAge('full address to file')));
If you only need the date, without the file creation time, then instead of the DateTimeToStr command, use the DateToStr command.
how to read data from .dat files ?
i just tried like this memo1.lines.loadfromfile('c:\myfile.dat'); but not worked
Note : File type is binary
can any one please help me :)
#radick to show the contents of an binary file in a memo control you must encode o convert the data to valid ASCII characters, to turn it all into text. because you can not load something that is not text into a text control.
you can find a very nice sample from Peter Below in this link.
read a binary file and display the byte values as ASCII?
(source: swissdelphicenter.ch)
Use the TStream descendants from the VCL Classes unit to read binary files.
There are plenty Delphi TStream reading binary files examples you can find using Google.
--jeroen
You might look at this post as they seem to be discussing this very thing.