DEVELOPER'S DESCRIPTION imgkap - kap File Converter Tool V1.1 imgkap Version 1.1 Install For all system, tested on Windows 32 and on linux 32 and 64 bit FOR LINUX Having a C or C++ compiler : gcc, g++… Download and install freeimage-dev, on Ubuntu > sudo apt-get install libfreeimage-dev Prefer last version, see The FreeImage Project Download imgkap.c and compile width gcc or g++: > gcc imgkap.c -O3 -s -lfreeimage -o imgkap FOR WINDOWS : imgkap.exe is used with the command window. It is all that's needed :) Download imgkap as a zip or Download from forum as imgkap.1.doc to imgkap.4.doc and in the cmd window,type > copy /b imgkap.*.doc imgkap.zip and unzip imgkap.zip Optional : You can link this program into another program and use kap conversion function > gcc myprogram.c -D LIBIMGKAP imgkap.c -lfreeimage -o myprogram Contact me (MdJ)for more information. Command line : imgkap [options] [inputfile] [lat0 lon0 lat1 lon1 | headerfile] [outputfile] options can be anywhere in the command line This software can : convert map KAP file to image file convert image file to KAP file:using WGS84 coordinates of the image using data and coordinates from KAP file or header convert KML file to KAP file convert KAP file to KAP file used to change colors DSK and NGT extract header (text) KAP file File extensions : Input KAP : Can be KAP or N01 Header file format : TXT or KAP Image formats accepted are the formats accepted by FreeImage : bmp,gif,jpg or jpeg,pbm,pgm,png,ppm,tga,tif or tiff… KML imput : GroundOverlay kml file with image file. WGS84 positioning : lat0 lon0 is the top-left,corner lat1 lon1 is the ,bottom-right corner These need to be accurate. IMGKAP will tell you if they are not! and output corrections to image size. lat to be between -85 and +85 degree "-"latitude is South Latitude Long to be between -180 and +180 degree "-"long is West Longitude different Position Format are accepted : Decimal degrees,Degrees and minutes, and more! examples: -1.22 1°10' 20.123N -1d22.123 ... Option switches used in CMD line(options can be anywhere in the command line!) :) -f fix units to FATHOMS from default meters -s fix sounding datum as in LOWEST LOW WATER etc. -t change name of map -p color of map as in: color : ALL|RGB|DAY|DSK|NGT|NGR|GRY|PRC|PRG ALL generate multipage image, use only with GIF or TIF Image or Kap to Kap color : NONE|KAP|MAP|IMG NONE use colors in image file, default KAP only with KAP or header file, use color tag in KAP file MAP generate DSK and NGB colors for map scan (< 64 colors, Black -> Gray, White -> Black) IMG generates DSK(Dusk) and NGB(Night) colors for image (photo, satellite...) ***************************************************************************************************** DISCLAIMERS.This is for homemade kaps and is intended for users using their own images. IE:a photograph taken may be displayed in a navigation program, or a hand-drawn map and so forth.... They are not to be used for navigation. Please respect copyrights. GUIDE for IMGKAP.Edited from the original. ABOUT COLOURS: If your image has many,many colours,IMGKAP will churn awhile to simplify. It will reduce the number of colours to 128 colours. This is so navigation-type programs can understand your kap and display it. WINDOWS USAGE FOR BEGINNERS Tips for "Point+Click"ers You need to type a few things into the CMD window,but IMGKAP is very easy and simple to use.There's much info about cmd but I think this is minimum. Copy the image you want to use into a WORK folder with imgkap.exe in it Make some subfolders and put things "done" or "todo" etc. in them. Deal with one task at a time. Use Copies.Don't overwrite something you wanted to save! Next..in XP systems create a CMD shortcut(find and rightclick cmd.exe) and drag it into the folder too. Then,right-click the shortcut,choose Properties, and delete everything in the "Start In " box! This shortcut saves work typing "paths".(copies of it will "Start in" any folder you put it in) Another way,is to make a shortcut to imgkap.exe and in the Target Window,type /k after imgkap.exe to keep the cmd window open. thereafter,you don't need to type ".exe".Just "imgkap" will do UNLESS you have another file named "Imgkap.whatever"....That is how cmd works. As a test,double-click the shortcut and type "imgkap /k" without the quotes after the blinking > and hit ENTER >imgkap /k That about sums up the difficulty...and you've used a "switch" too! also,If you botch typing something and the command doesn't work, try tapping the F3 key .It should retype the last thing you tried. F7 shows previous commands. Then,use arrow keys to navigate and fix. Spaces are very important.Just one BETWEEN things,as a rule here as in >imgkap[space]myimage.img[space]myheader.txt[space]mynewkap.kap Names with spaces must be enclosed with quotemarks as in: >imgkap[space]"My Newest Map including a Wolf picture.tif"[space]"my own headerper wolf.txt"[space]"MY .............. You can see name is worth simplifying. Under_scores,-dashes-,CapitalLetters can help make easily read names. tap the ENTER key when done. When the CMD window closes,(or type /k at the end to keep it open!)your kap often appears in a second! But if the image is very large,with many colours,it will take a little longer. MAKING KAPS FROM SCRATCH WITH CORNER POSITIONS Don't overwrite something you wanted to save! Make some folders in the Work folder to tuck your successes in! :) and some to put everything else in "One at a time" is the way to go. NEED KNOWS USING CORNER POSITIONS to Create Kaps *WGS84 is the default position datum,METERS is the default soundings datum UNKNOWN is the default Tidal Datum The kap made with corner positions will be MERCATOR. Any Borders around the image will be seen in the Navigation Software But read about headers for very advanced usage... IMAGES to USE rectangular,many formats possible per png,tif etc See formats in Developer notes TIP:avoid messing about with jpeg and jpg s.These do not edit well and are "lossy" Turning them into another format before starting to make a kap is good practise. IMGKAP will convert+compress the image to a format nav software can use. IMGKAP uses the colours in the image. It is good to have at least 16 distinct colours,even if these are mere dots. This allows easier additions later,rather than more advanced image editing. a command line.... >imgkap mykap.png 47°87' -3°86' 45°82' -0°70' myresult.kap IMGKAP accepts MANY ways of writing positions!see developer notes for these. The positions of upper-left and lower-right image corners are typed in.Latitude upper-left is followed by longitude upper-left....then likewise for the lower right. These positions are the very corners of the image.They must be garnered accurately,or IMGKAP will tell you the image size is wrong.If your image has borders,they will appear in the nav software. Note again the one single space between "things" A very easy idea is to type your command beforehand in a text editor as a single line and then copy,paste into CMD window.A rightclick in cmd window gives this option. Keep this file in case you want to redo that image! You edit it,add things,and so on,but You cannot alter the image dimensions if you want to re-use these saved commands. ADVANCED CORNER POSITION USAGE (with switches ) >imgkap -s "LOWEST LOW WATER" myimg.png 47°87' -3°86' 45°82' -0°70' -f -p IMG ....The order and placement of switches doesn't matter. Here,the "-s" followed by "LOWEST LOW WATER" is a switch allowing the user to enter the Soundings datum.The default would be UNKNOWN without this. The quotes excuse spaces here and make a single thing as far as CMD knows...CAPITAL letters seem to be preferred by navigation software At the end is "-f".This writes the chart sounding datum in the header as FATHOMS.But you might try -f FEET The Default without this switch is METERS. The final "-p IMG" generates DSK and NGB colours for the chart image (photo, satellite...) EDITING EXTRACTING and EXPLORING kapfiles....ONLY USED WITH COPIES. Don't overwrite something you wanted to save! Only use copies of originals!Rename created kaps! Make some folders to tuck your successes in! :) >imgkap mykap.kap myimgextracted.png ....This extracts an image from a kap Image formats possible are the formats accepted by FreeImage : bmp,gif,jpg or jpeg,pbm,pgm,png,ppm,tga,tif or tiff… Input KAP can be KAP or N01 >imgkap mykap.kap myheader.txt ....This extracts just the chart header as a text file. "Headers" have all the calibration info the Navigation program uses to display the map and you on it,with a gps. Header file is text output but can be .TXT,.txt,.kap,or.KAP (header doesn't contain IFM and OST tag) >imgkap mykap.kap myheader.txt myimgextracted.png ....This extracts a "header" file and the image. Header file output is text Many choices for output image (header doesn't contain IFM (compression)or OST (Offset values)tags) MAKING AND REBUILDING >imgkap myimg.png myheader.txt ....Makes a kap from png using header The resulting kap will have the name that is IN header.txt Give it a different name than any kap in your workfolder or it will overwrite a kap of the same name in your workfolder! The colours in the KAP are RGB type taken from the image file. Modify the header with a text editor and save. Then,to make a kap using the modified header file with the same image file.... Advanced usage involves altering more than the name and sounding datum,etc. Large Scale Polyconic,UTM,etc can be extracted and rebuilt using the extracted header but cannot be built with IMGKAP using just corner positions ...the image will have wrong dimensions. See ADDENDUM about headers >imgkap myeditedimage.png header.txt myeditedkap.kap ....This Rebuilds the Kap using the header file and the edited image, but you have named the kap without relying on the header. Note:You could try any image with the SAME X,Y dimensions but you really SHOULD change the name in the header too and mydifferntkap.kap to the CMD line. as in: imgkap mydifferentimage.png myheader.txt mydifferntkap.kap These processes can be used to add something to the image. Idea:copy and paste in a photo of a harbour entrance or a mountain view. Add a detail or even text. and then rebuild as a kap! BUT you must not have changed the dimensions of the image. You should also give it a different name! You don't want to overwrite the original kap!if you forgot to move it out of the workfolder (Note:This "extract+rebuild" seems to work for Polyconic and more ... Advanced editing involves altering more than the name and sounding datum,etc. Research the header abbreviations.OpenCPN forum is a great place for this. ADVANCED (see the switches in DEVELOPER NOTES) >imgkap mykap.kap -p NGT myimg.png ....extracts to a png using NGT palette in KAP file. >imgkap mykap.kap -p ALL myimg.gif ....extracts a gif multipage from the kap using all palettes in KAP file (DSK, NGT...) MORE :for these,you need to use a different name for the output kap...! >imgkap mykap.kap result.kap ....Maybe not so very useful, the original kap has it's image extracted and this image is converted to a kap file-Almost a CLONE but IMGKAP may clean things up in the process...For instance, if the original kap has compression problems. >imgkap mykap.kap -p NONE result.kap ....Creates a kap with only RGB colours. >imgkap mykap.kap -p MAP result.kap ....Creates a kap with DAY,DSK and NGT colours. Useful for old KAP (French SHOM MAP) used in OpenCPN >imgkap myimg.png mykap.kap ....This uses a kap as the template to make a kap from a png. imgkap myimg.png -p KAP myheader.txt ....converts a png to a kap with header using KAP colours NOTE : Resulting colours order is changed, if you want to edit the final kap you must repeat all steps with the last file. If myimg.png is changed, the KAP colours will not match, then, use another option:-p MAP or -p NONE or make sure the colours of the image correspond to colours KAP >imgkap myimg.png -p KAP myheader.txt ....convert a png into a kap using header. colours in KAP are colours in myheader.txt >imgkap myimg.png -p MAP myheaderkap.txt ....convert png into kap using header colours in KAP are colours in myimg with calculated DSK and NGT colours for MAP >imgkap myimg.png -p IMG myheaderkap.txt ....convert png into kap using txt colours in KAP are colours in myimg witdh calculated DSK and NGT colours for photo or satellite image USING A KML file to make KAP file using header file >imgkap mykml.kml mykap.kap ....This makes a kap using a kml file (kml files are "associated" with an image and may include a path to the image,so don't move the image without editing the kml) >imgkap mykml.kml -f -p IMG ....as above,using name and directory of image and , KAP contain DSK and NGT calculated colours