<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://fpcamigawiki.alb42.de/index.php?action=history&amp;feed=atom&amp;title=Embedded_Images</id>
	<title>Embedded Images - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://fpcamigawiki.alb42.de/index.php?action=history&amp;feed=atom&amp;title=Embedded_Images"/>
	<link rel="alternate" type="text/html" href="http://fpcamigawiki.alb42.de/index.php?title=Embedded_Images&amp;action=history"/>
	<updated>2026-04-18T02:31:27Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.1</generator>
	<entry>
		<id>http://fpcamigawiki.alb42.de/index.php?title=Embedded_Images&amp;diff=1193&amp;oldid=prev</id>
		<title>Alb42: /* Data as object file */  Image for link name</title>
		<link rel="alternate" type="text/html" href="http://fpcamigawiki.alb42.de/index.php?title=Embedded_Images&amp;diff=1193&amp;oldid=prev"/>
		<updated>2023-01-07T21:24:20Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Data as object file: &lt;/span&gt;  Image for link name&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 21:24, 7 January 2023&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l114&quot; &gt;Line 114:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 114:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Choose &amp;quot;Project/Save Image&amp;quot; to save the image data as a link file, it will ask for a name for the external definition, which is the name you will use in the pascal to identify that image for example &amp;#039;MyImage&amp;#039; and the memory location for example &amp;#039;ANY&amp;#039;. Save that as object file e.g. MyImg.o&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Choose &amp;quot;Project/Save Image&amp;quot; to save the image data as a link file, it will ask for a name for the external definition, which is the name you will use in the pascal to identify that image for example &amp;#039;MyImage&amp;#039; and the memory location for example &amp;#039;ANY&amp;#039;. Save that as object file e.g. MyImg.o&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Choose &amp;quot;Project/Save palette&amp;quot; to save the palette data as a link file, it will ask for a name for the external definition, which is the name you will use in the pascal to identify this palette for example &amp;#039;MyPalette&amp;#039; and the memory location for example &amp;#039;ANY&amp;#039;. Save that as object file e.g. MyPal.o&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Choose &amp;quot;Project/Save palette&amp;quot; to save the palette data as a link file, it will ask for a name for the external definition, which is the name you will use in the pascal to identify this palette for example &amp;#039;MyPalette&amp;#039; and the memory location for example &amp;#039;ANY&amp;#039;. Save that as object file e.g. MyPal.o&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[File:Piccon-linkname.png]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Now you can include these two files to your code:&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Now you can include these two files to your code:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key db624220369-ntdbjym2gu:diff::1.12:old-1190:rev-1193 --&gt;
&lt;/table&gt;</summary>
		<author><name>Alb42</name></author>
	</entry>
	<entry>
		<id>http://fpcamigawiki.alb42.de/index.php?title=Embedded_Images&amp;diff=1190&amp;oldid=prev</id>
		<title>Alb42: First version of embedded image, nearly finished, only external binary is missing</title>
		<link rel="alternate" type="text/html" href="http://fpcamigawiki.alb42.de/index.php?title=Embedded_Images&amp;diff=1190&amp;oldid=prev"/>
		<updated>2023-01-02T21:38:04Z</updated>

		<summary type="html">&lt;p&gt;First version of embedded image, nearly finished, only external binary is missing&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This page describes how to use embedded bitmap images and palettes in Amiga Free Pascal.&lt;br /&gt;
&lt;br /&gt;
== Preparation ==&lt;br /&gt;
&lt;br /&gt;
We start with a PNG file created by Gimp for example and transferred to Amiga (I used Gimp already to scale the colors down to 256 colors). With [http://ppaint.com PPaint] the final color depth and palette ordering is done, the image can be also resized but cutting is also possible in the converter program. For the final conversation [https://aminet.net/package/gfx/conv/PicCon250 PicCon 2.5demo] is used.&lt;br /&gt;
&lt;br /&gt;
== Image to Program ==&lt;br /&gt;
&lt;br /&gt;
=== Prepare Image ===&lt;br /&gt;
&lt;br /&gt;
First you need to load the iff image created by PPaint to PicCon &amp;quot;Project/Open Picture&amp;quot; it will be shown on the screen.&lt;br /&gt;
If the image contains a lot of empty background area you might want to cut it. You can directly select the area on the screen or use the &amp;quot;Edit/Autocrop&amp;quot; function.&lt;br /&gt;
&lt;br /&gt;
[[File:Piccon-autocrop.png]]&lt;br /&gt;
&lt;br /&gt;
You will get a black border around the area that will be exported.&lt;br /&gt;
There are three ways to bring your image to you program (and finally to the screen) the first two options will embed the data to the executable (therefore you can just send a single file) and the last option will load the data from external files (which makes a smaller executable and makes it possible for smaller footprint because you can load the data later on demand)&lt;br /&gt;
&lt;br /&gt;
=== Prepare Settings ===&lt;br /&gt;
&lt;br /&gt;
We need to set the format for the data to be exported, usually we want to have plain bitplanes (which is the default, be better check)&lt;br /&gt;
&amp;quot;Settings/Imageformat&amp;quot;&lt;br /&gt;
&lt;br /&gt;
[[File:Piccon-dataformat.png]]&lt;br /&gt;
&lt;br /&gt;
We also need to set the palette format in &amp;quot;Settings/Paletteformat&amp;quot;&lt;br /&gt;
&lt;br /&gt;
[[File:Piccon-palformat.png]]&lt;br /&gt;
&lt;br /&gt;
If we use OS 3+ it is best to use the LoadRGB32 format (Free Pascal default).&lt;br /&gt;
OS 1.x does not know the LoadRGB32 functions, therefore one can use the LoadRGB4 format if the target is OS 1.x. But if you use the latest Free Pascal compiler for OS 1.x you can use LoadRGB32 for here as well (there is a wrapper for that in the pascal amiga units)&lt;br /&gt;
&lt;br /&gt;
=== Save Format ===&lt;br /&gt;
As Last you need to define which format you want to save, ultimately define which way you want to bring the data to your program (the aforementioned three options) &amp;quot;Project/Save Data as...&amp;quot;&lt;br /&gt;
&lt;br /&gt;
[[File:Piccon-saveformat.png]]&lt;br /&gt;
&lt;br /&gt;
==== Data as Include ====&lt;br /&gt;
&lt;br /&gt;
PicCon can directly create Pascal code which can be used as includes with only tiny changes (or you can copy paste the code to your program for single source file programs)&lt;br /&gt;
Select &amp;quot;Pascal src&amp;quot; as saveformat.&lt;br /&gt;
Choose &amp;quot;Project/Save Image&amp;quot; to save the image data as a pascal include file (for example MyImage.inc).&lt;br /&gt;
Choose &amp;quot;Project/Save palette&amp;quot; to save the palette data as an include file (for example MyPalette.inc).&lt;br /&gt;
Both files are text files, therefore you can open them with any text editor, 2 things you should notice.&lt;br /&gt;
&lt;br /&gt;
First both constants created are named &amp;#039;mydata&amp;#039; which is bad if you want to include them into the same file, so maybe rename one (or both) of these constants. For this Tutorial we assume the names where changed to MyImage and MyPalette (same as the files).&lt;br /&gt;
&lt;br /&gt;
Second at the end of the binary array you will notice an additional comma &amp;#039;,&amp;#039; after the last entry, which Free Pascal does not like there, you will have to remove it (I don&amp;#039;t know, but it seems other Pascal compilers can work with that).&lt;br /&gt;
&lt;br /&gt;
Now you can include these two files to your code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Pascal&amp;quot;&amp;gt;&lt;br /&gt;
{$include MyImage.inc}&lt;br /&gt;
{$include MyPalette.inc}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
after the screen is open one can set the palette&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Pascal&amp;quot;&amp;gt;&lt;br /&gt;
uses&lt;br /&gt;
  AGraphics;&lt;br /&gt;
&lt;br /&gt;
{$include MyPalette.inc}&lt;br /&gt;
&lt;br /&gt;
procedure SetPalette(Screen: PScreen);&lt;br /&gt;
begin&lt;br /&gt;
  LoadRGB32(@Screen^.ViewPort, @MyPalette[0]);&lt;br /&gt;
end;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When you want to draw the actual image to that screen you need a TImage structure to use the binary in the include for that you need the size (width and height) and number of bitplanes of the saved image, all 3 values are shown when the image is successfully saved.&lt;br /&gt;
&lt;br /&gt;
[[File:Piccon-saved1.png]]&lt;br /&gt;
&lt;br /&gt;
for this example it is 272 width, 75 height and 3 bitplanes = depth.&lt;br /&gt;
&lt;br /&gt;
To draw this Bitmap you need to set the TImage structure and draw to rastport like that:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Pascal&amp;quot;&amp;gt;&lt;br /&gt;
uses&lt;br /&gt;
  AGraphics;&lt;br /&gt;
&lt;br /&gt;
{$include MyImage.inc}&lt;br /&gt;
&lt;br /&gt;
// raw the image to rast port&lt;br /&gt;
procedure DrawImage(RP: PRastPort);&lt;br /&gt;
var&lt;br /&gt;
  MyImage: TImage;&lt;br /&gt;
begin&lt;br /&gt;
  MyImage.LeftEdge := 0;&lt;br /&gt;
  MyImage.TopEdge := 0;&lt;br /&gt;
  // this 3 values are shown on finishing&lt;br /&gt;
  MyImage.Width := 272; // width of image&lt;br /&gt;
  MyImage.Height := 75; // Height of image&lt;br /&gt;
  MyImage.Depth := 3; // number of bitplanes&lt;br /&gt;
  //&lt;br /&gt;
  MyImage.ImageData := @myData[0]; // pointer to the actual image data&lt;br /&gt;
  //&lt;br /&gt;
  MyImage.PlanePick := (1 shl MyImage.Depth) - 1;&lt;br /&gt;
  MyImage.PlaneOnOff := 0; // to no skip any Planes&lt;br /&gt;
  MyImage.NextImage := nil;&lt;br /&gt;
&lt;br /&gt;
  DrawImage(RP, @MyImage, 0,0); // draw the actual Image at 0,0 in the rastport &lt;br /&gt;
end;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Data as object file ====&lt;br /&gt;
&lt;br /&gt;
Choose saveformat &amp;quot;Linkobject&amp;quot;. (Project/Save data as.../Linkobject)&lt;br /&gt;
&lt;br /&gt;
Choose &amp;quot;Project/Save Image&amp;quot; to save the image data as a link file, it will ask for a name for the external definition, which is the name you will use in the pascal to identify that image for example &amp;#039;MyImage&amp;#039; and the memory location for example &amp;#039;ANY&amp;#039;. Save that as object file e.g. MyImg.o&lt;br /&gt;
Choose &amp;quot;Project/Save palette&amp;quot; to save the palette data as a link file, it will ask for a name for the external definition, which is the name you will use in the pascal to identify this palette for example &amp;#039;MyPalette&amp;#039; and the memory location for example &amp;#039;ANY&amp;#039;. Save that as object file e.g. MyPal.o&lt;br /&gt;
&lt;br /&gt;
Now you can include these two files to your code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Pascal&amp;quot;&amp;gt;&lt;br /&gt;
{$L MyImg.o}&lt;br /&gt;
var&lt;br /&gt;
  MyImg: Pointer; external name &amp;#039;MyImage&amp;#039;;&lt;br /&gt;
&lt;br /&gt;
{$L MyPal.o}&lt;br /&gt;
var&lt;br /&gt;
  MyPal: LongWord; external name &amp;#039;MyPalette&amp;#039;;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
after the screen is open one can set the palette&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Pascal&amp;quot;&amp;gt;&lt;br /&gt;
uses&lt;br /&gt;
  AGraphics;&lt;br /&gt;
&lt;br /&gt;
{$L MyPal.o}&lt;br /&gt;
var&lt;br /&gt;
  MyPal: LongWord; external name &amp;#039;MyPalette&amp;#039;;&lt;br /&gt;
&lt;br /&gt;
procedure SetPalette(Screen: PScreen);&lt;br /&gt;
begin&lt;br /&gt;
  LoadRGB32(@Screen^.ViewPort, @MyPal);&lt;br /&gt;
end;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you want to draw the actual image to that screen you need a TImage structure to use the binary in the include for that you need the size (width and height) and number of bitplanes of the saved image, all 3 values are shown when the image is successfully saved.&lt;br /&gt;
&lt;br /&gt;
[[File:Piccon-saved1.png]]&lt;br /&gt;
&lt;br /&gt;
for this example it is 272 width, 75 height and 3 bitplanes = depth.&lt;br /&gt;
&lt;br /&gt;
To draw this Bitmap you need to set the TImage structure and draw to rastport like that:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Pascal&amp;quot;&amp;gt;&lt;br /&gt;
uses&lt;br /&gt;
  AGraphics;&lt;br /&gt;
&lt;br /&gt;
{$L MyImg.o}&lt;br /&gt;
var&lt;br /&gt;
  MyImg: Pointer; external name &amp;#039;MyImage&amp;#039;;&lt;br /&gt;
&lt;br /&gt;
// raw the image to rast port&lt;br /&gt;
procedure DrawImage(RP: PRastPort);&lt;br /&gt;
var&lt;br /&gt;
  MyImage: TImage;&lt;br /&gt;
begin&lt;br /&gt;
  MyImage.LeftEdge := 0;&lt;br /&gt;
  MyImage.TopEdge := 0;&lt;br /&gt;
  // this 3 values are shown on finishing&lt;br /&gt;
  MyImage.Width := 272; // width of image&lt;br /&gt;
  MyImage.Height := 75; // Height of image&lt;br /&gt;
  MyImage.Depth := 3; // number of bitplanes&lt;br /&gt;
  //&lt;br /&gt;
  MyImage.ImageData := @MyImg; // pointer to the actual image data&lt;br /&gt;
  //&lt;br /&gt;
  MyImage.PlanePick := (1 shl MyImage.Depth) - 1;&lt;br /&gt;
  MyImage.PlaneOnOff := 0; // to no skip any Planes&lt;br /&gt;
  MyImage.NextImage := nil;&lt;br /&gt;
&lt;br /&gt;
  DrawImage(RP, @MyImage, 0,0); // draw the actual Image at 0,0 in the rastport &lt;br /&gt;
end;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Alb42</name></author>
	</entry>
</feed>