Copyright: Copyright © Media Architects, 1996


AccessDesignReadOnly
Access:

This chart shows whether a property's value may be accessed (Read), and whether a property's value may be set (Write).

The chart also shows whether the property value is available for reading or writing during a container's design mode and/or run-mode.


CallBackLines property eg.
Visual Basic

Delphi


Image Fromat property Delphi eg.
ImageFormat property Delphi example:

Picbuf1.ImageFormat:=3;


ASA
Media Architects

Annual Support Agreement

Maximize your investment and make sure that you always have the latest products and information! Sign up for our Annual Support Agreement (ASA) and you can be sure that you’ll have the earliest access to new information and products from Media Architects.  Not only does an ASA give you that, but you also get a 20% discount off all new  purchases.

Customers with an ASA are entitled to:

 Access a special area on our web page or BBS. This is the where we put all the latest information and tools first. This includes technical tips, updated demo source code, code examples from the documentation, and contributions from other Media Architects customers. For example, our Mosaic Array Editor is already available here so our ASA customers can create custom transition effects now. (After some polishing, it will be incorporated in our MediaKnife products, but why wait?)

         	Immediately download all maintenance upgrades from our BBS for any Media Architects’ development product licensed to the registered user. Plus beta test programs will be announced in the ASA area, so you can apply to test the latest updates and new products.

         	Get a 20% discount off list for new development products and options introduced by Media Architects during the term of the support agreement.

Free telephone support, as often as needed.

OCX product support also includes a hardcopy manual at no extra cost (for products that have a printed manual).

Note: An Annual Support Agreement is required for each copy of the product being upgraded.·

Get a 20% discount off list for enhancement releases.

Power Users - Save BIG! If you own multiple Media Architects products you’ll want to go for a Single User Blanket ASA.  For just $174 you can receive all of the support listed above for one copy of EVERY Media Architects product you own.

Yes, I want to sign up for Contract Support! (Click for the form).


ASA Order Form
Media Architects

Annual Support Agreement Order Form

To sign up for Contract Support please phone (503) 639-2505, fax (503) 620-5451 or e-mail (sales@mediarch.com) this form to:

Name ___________________________________________________

Company ________________________________________________

Address__________________________________________________

City _____________________________	State/Province __________________

Postal code ________________

Country ________________________	Phone _________________________

Email ___________________________

Support Package: (OCX pricing includes shipping of manual)

[] VBX Product (US$75)	[] OCX Product in USA ($99)

[] OCX outside USA (US$129)	[] Blanket ASA outside USA (US$204)

[] Single User Blanket ASA in USA ($174)

Product name _________________	Product name ____________________

Serial number _________________	Serial number ____________________

Product name _________________	Product name ____________________

Serial number _________________	Serial number ____________________

Payment method:

[] Visa	     [] MasterCard             	[] American Express

Order Amount: ______________

Card number ________________________________________

Expires ______/_______    Cardholder Name ______________________

[] Domestic purchase order (attach copy of purchase order)

[] Check (USA only ) _____________________


AautoSize Delphi eg.
AutoSize property Delphi example:

Picbuf1.AutoSize:=True;


AccessAll
Access:

This chart shows whether a property's value may be accessed (Read),

and whether a property's value may be set (Write).

The chart also shows whether the property value is available for reading

 or writing during a container's design mode and/or run-mode.


AccessRunTimeReadOnly
Access:

This chart shows whether a property's value may be accessed

(Read), and whether a property's value may be set (Write).

The chart also shows whether the property value is available for

reading or writing during a container's design mode and/or run-mode.


AccessRuntimeOnly
Access:

This chart shows whether a property's value may be accessed

(Read), and whether a property's value may be set (Write).

The chart also shows whether the property value is available for

 reading or writing during a container's design mode and/or run-mode.


AddSystemColors method Delphi eg.
AddSystemColors method Delphi example:

Picbuf1.AddSystemColors;


AddSystemColors method VB eg.
AddSystemColors method VB example:

Picbuf1.AddSystemColors


AddSytemColors method eg.
Visual Basic

Delphi


AppenTIFF method VB eg.
AppendTIFF method VB example:

Picbuf1.AppendTiff


AppendTIFF method Delphi eg.
AppendTIFF method Delphi example:

Picbuf1.AppendTiff;


AppendTIFF method eg.
Visual Basic

Delphi


Arc method Delphi eg.
Arc method Delphi example:

Picbuf1.OLEObject.Arc(1,1,4,4,1)


Arc method VB eg.
Arc method VB example:

Picbuf1.Arc 1, 1, 4, 4


Arc method eg.
Visual Basic

Delphi


Assign Method VB eg.
Assign method VB example:

‘There must be two picbuf controls named Picbuf1 and Picbuf2 with images loaded for this code to work correctly

Picbuf1.Assign False, Picbuf2, False


Assign method Delphi eg.
Assign method Delphi example:

{ There must be two picbuf controls named Picbuf1 and Picbuf2 with images loaded for this code to work correctly }

Picbuf1.Assign(False,Picbuf2.OLEObject,False);


Assign method eg.
Visual Basic

Delphi


AssignMode Delphi eg.
AssignMode Delphi example:

Picbuf1.Assignmode:=0;


AssignMode property eg.
Visual Basic

Delphi


AssignModeVB
AssignMode Visual Basic example:

Picbuf1.AssignMode = AMTotal


AutoScale Delphi eg.
AutoScale Delphi example:

Picbuf1.AutoScale:=True;


AutoScale property VB eg.
AutoScale property VB example:

Picbuf1.AutoScale = True


AutoScale property eg.
Visual Basic

Delphi


AutoSize VB eg.
AutoSize property VB example:

Picbuf1.AutoSize = True


AutoSize property eg.
Visual Basic

Delphi


Basic Structure
ImageKnife Help

Basic Structure of the PicBuf control

The PicBuf Control

PicBufs and the Form

Loading Images

Anatomy of the PicBuf

Bitdepths and the PicBuf

Deleting PicBuf Images

PicBuf Assignment Capabilities

Size Control in PicBuf Assignments

Assignment

Total Replacement (AssignMode 0)

Union Composite (AssignMode 1)

Intersection Composite (AssignMode 2)

Resize Composite (AssignMode 3, ResizeMode 0 or 2)

Resize Composite (AssignMode 3, ResizeMode 1 or 3)

Alignment Control in PicBuf Assignments

Summary of Assignment Capabilities


BitMapToDib method eg.
Visual Basic

Delphi


BitmapToDib method Delphi eg.
BitmapToDib method Delphi example:

//There must be a handle to a Bitmap named hBitmap for this code to work

Picbuf1.BitmapToDib(hBitmap);


BitmapToDib method VB eg.
BitmapToDib method VB example:

‘There must be a handle to a Bitmap named hBitmap present for this code to work

Picbuf1.BitmapToDib hBitmap


Blur method Delphi eg.
Blur method Delphi example:

Picbuf1.Blur;


Blur method VB eg.
Blur method VB example:

Picbuf1.Blur


Blur method eg.
Visual Basic

Delphi


BrightCont method Delphi eg.
BrightCont method Delphi example:

Picbuf1.BrightCont(.5,.5);


BrightCont method VB eg.
BrightCont method VB example:

Picbuf1.BrightCont .5, .5


BrightCont method eg.
Visual Basic

Delphi


CallBackLines Delphi eg.
CallBackLines Delphi example:

Picbuf1.CallbackLines:=8;


CallBackLines VB eg.
CallBackLines VB example:

Picbuf1.CallbackLines = 8


Callback event eg.
Visual Basic

Delphi


Chord method Delphi eg.
Chord method Delphi example:

Picbuf1.OLEObject.Chord(1,2,3,4,1)


Chord method VB eg.
Chord method VB example:

Picbuf1.Chord 1, 2, 3, 4


Chord method eg.
Visual Basic

Delphi


Clear method Delphi eg.
Clear method Delphi example:

Picbuf1.Clear;


Clear method VB eg.
Clear method VB example:

Picbuf1.Clear


Clear method eg.
Visual Basic

Delphi


ColorDepth VB eg.
ColorDepth VB example:

Dim intColDepth As Integer

intColDepth=Picbuf1.ColorDepth


ColorDepth pproperty eg.
Visual Basic

Delphi


ColorDepth property Delphi eg.
ColorDepth property Delphi example:

//An integer named intColDepth must be declare before this code will function properly.

intColDepth:=Picbuf1.ColorDepth;


ColorReplace method Delphi eg.
ColorReplace method Delphi example:

Picbuf1.ColorReplace(RGB(0,0,0),RGB(255,0,0);


ColorReplace method VB eg.
ColorReplace method VB example:

Picbuf1.ColorReplace RGB(0,0,0),RGB(255,0,0)


ColorReplace method eg.
Visual Basic

Delphi


Compatibility
ImageKnife Help

Compatability

Compatability

Compression Formats

Printing with ImageKnife

ImageKnife and Visual C++

Exchanging Images Directly with other Applications

Using DIBs Created in other Applications

Using ImageKnife DIBs in Other Applications

Verifying the Validity of DIBs


Contents
ImageKnife Help

Table of Contents

Introduction

License Agreement

Installation

Programming

Reference

Appendix

Technical Support

       Visit us on the World Wide Web:

http://www.mediarch.com


Contents property Delphi eg.
Contents property Delphi example:

//An integer named intContents must be declare before this code will function properly.

intContents:=Picbuf1.Contents;


Contents property VB eg.
Contents property VB example:

Dim intContents As String

intContents=Picbuf1.Contents


Contents property eg.
Visual Basic

Delphi


CopyClipboard method eg.
Visual Basic

Delphi


CopyToClibpard method Delphi eg.
CopyToClibpard method Delphi example:

Picbuf1.CopyClipboard(0);


CopyToClipboard method VB eg.
CopyToClipboard method VB example:

Picbuf1.CopyClipboard


CountImages method Delphi eg.
CountImages method Delphi example:

//The integer intCntImg must be declared for this code to function correctly.

intCntImg:=Picbuf1.CountImages;


CountImages method VB eg.
CountImages method VB example:

Dim intCntImg As Integer

intCntImg=Picbuf1.CountImages


CountImages method eg.
Visual Basic

Delphi


CountSystemColors method Delphi eg.
CountSystemColors method Delphi example:

//The integer intSysCol must be declared for this code to function properly.

intSysCol:=Picbuf1.CountSystemColors;


CountSystemColors method VB eg.
CountSystemColors method VB example:

Dim intSysCol As Integer

intSysCol=Picbuf1.CountSystemColors


CountSystemColors method eg.
Visual Basic

Delphi


CreatePalette method Delphi eg.
CreatePalette method Delphi example:

//The double hPal must be declared for this code to function properly.

hPal:=Picbuf1.CreatePalette(256,palColors,8);


CreatePalette method VB eg.
CreatePalette method VB example:

Dim hPal As Double

hPal=Picbuf1.CreatePalette 256, palColors,8


CreatePalette method eg.
Visual Basic

Delphi


Delphi Wrapper Conversion Utility
ImageKnife Help

Delphi Wrapper Conversion Utility

Introduction

When you use either a VBX or an OCX in Delphi, a Pascal wrapper for the control is automatically generated to allow the control to function within Delphi.  Why would someone ever want to modify this file?  Unfortunately, Delphi does not always generate the file exactly as it should, and there are often little additions that need to be made to the wrapper file to achieve optimal performance.  In the case of a VBX, custom methods do not exist, thus every function needs to be loaded and referenced through several API function calls before you can use them.  We originally distributed a separate "constant file" which would have to be placed in the uses section of every Delphi program, but we found that it was much more convenient to add  all of these definitions right to the wrapper file so that you never need to worry about them again.  Just place the control on your form and write your program!

Sadly, the wrappers are generated differently for every version of a control, and often for different versions of Delphi.  The main differences lie in some hard-coded binary control initialization within the wrapper.  Because of this Media Architects cannot distribute one wrapper file which will work for everyone, and thus we have created the Delphi wrapper conversion utility DELCONV to fix the above problems automatically.

Using the utility

To use the utility, DELCONV.EXE, follow these steps:

1) Locate the program.  If it was installed with your product it should have be placed in \MEDIARCH\TOOLS by default.

2) Execute the program with the following parameters:

delconv <wrapperfile.pas> <conversionfile.cnv> [resultfile.pas]

What is expected for each of the parameters?

wrapperfile: this is the name, including the full path, of the wrapper file generated by Delphi.  For example, \windows\system\ikdsp16.pas for ImageKnife/VBX, or \borland\"Delphi 2.0"\ImageKnife32.pas for ImageKnife/OCX. (Note: These are only standard defaults for the products)

conversionfile: this is the name of the appropriate conversion file for your product.  For example, ik16.cnv for ImageKnife/VBX, and ik32.cnv for ImageKnife/OCX. This should be located in the same directory as the conversion utility.  (Note: You can modify these files, or create your own if you wish to make other modifications)

resultfile: this is an optional parameter allowing you to write out the modified wrapper to a file instead of modifying the original wrapper.

3)  Now delete the .DCU file with the same name as your wrapper file, if it exists, and select rebuild your library from within Delphi.

The Conversion (.CNV) File

The conversion file contains all modifications for the appropriate wrapper file that Media Architects feels would best benefit you.  For the most part you should never need to modify this file, but if you should so desire to, the following commands are available: insert_before, insert_after, insert_between, and replace.

All commands are placed between square brackets [] and followed on successive lines by the text you wish to search for and the changes you wish to make.  each string following the commands must be preceded by double pound signs ##, this is used to determine the beginning of the next string.  The string you wish to search for should be one entire line of Delphi code such as a whole procedure declaration followed by a semi-colon, or a keyword, like implementation.  Even if a procedure spans multiple lines in the wrapper file, when it is read in and compared the entire declaration will be considered with all formatting, spaces, capitals, carriage returns, etc. ignored.  In the line containing the new text however, all formatting before and after the text will be considered.  If you put for example three carriage returns after the ## and before the new text, three carriage returns will be inserted in the final wrapper file.

Examples

Example 1:

We want to replace a specific uses section in a file, we have:

and want to replace it with:

uses SysUtils, Classes, Graphics, Forms, Controls, VBXCtrl, BIVBX,

     WinTypes, WinProcs, DBTables, Dialogs;

your .CNV file will contain the following:

[replace]

##uses SysUtils, Classes, Graphics, Forms, Controls, VBXCtrl, BIVBX;

##

uses SysUtils, Classes, Graphics, Forms, Controls, VBXCtrl, BIVBX,

     WinTypes, WinProcs, DBTables, Dialogs;

Note that the new text might look a bit misplaced, but all formatting used in the new text is placed in the final file, so if we want a few extra lines before it in the final file we put a few blank lines following the second ## in the .CNV file.

Example 2:

We want to insert a block of constants before the implementation section, the .CNV could contain:

[insert_before]

##implementation

##

{ ******* Constants ******* }

{ Image file formats }

const

IK_EXTENSION = 0;

IK_TIFF      = 1;

IK_TARGA     = 2;

IK_BITMAP    = 3;

IK_GIF       = 4;

IK_DIB       = 5;

IK_PCX       = 6;

IK_JPEG      = 7;

IK_OLEPBRUSH = 8;

IK_FIF       = 9;

Example 3:

We want to insert a new Destructor for TPicBuf after the comment { TPicBuf }and before procedure TPicBuf.HandleVBXEvent(var Message: TWMVBXFireEvent);  The .CNV file might look like:

[insert_between]

##{ TPicBuf }

##procedure TPicBuf.HandleVBXEvent(var Message: TWMVBXFireEvent);

##

destructor TPicBuf.Destroy;

begin

  if FhPalette <> 0 then

  begin

    DeleteObject(FhPalette);

    FhPalette := 0;

  end;

  inherited Destroy;

end;


DelphiWrappConversion
Getting started

Delphi Wrapper Conversion Utility


DesignTimeOnly
Access:

This chart shows whether a property's value may be accessed

(Read), and whether a property's value may be set (Write).

The chart also shows whether the property value is available for

reading or writing during a container's design mode and/or run-mode.


DibTiBitmap method VB eg.
DibTiBitmap method VB example:

Dim hDIB As Double

hDIB=Picbuf1.DibToBitmap


DibToBitmap method Delphi eg.
DibToBitmap method Delphi example:

//A double named hDIB must be declared before using this code.

hDIB:=Picbuf1.DibToBitmap;


DibToBitmap method eg.
Visual Basic

Delphi


DitherPal method Delphi eg.
DitherPal method Delphi example:

//There must be two picbuf controls with images loaded for this code to work correctly.

Picbuf1.DitherPal(Picbuf2.OLEObject)


DitherPal method VB eg.
DitherPal method VB example:

‘There must be two picbuf controls with images loaded for this code to work correctly.

Picbuf1.DitherPal Picbuf2


DitherPal method eg.
Visual Basic

Delphi


DrawAarrows property VB eg.
DrawAarrows property VB example:

Picbuf1.DrawArrows = DANone


DrawArrows Delphi eg.
DrawArrows Delphi example:

Picbuf1.DrawArrows:=0;


DrawArrows property eg.
Visual Basic

Delphi


DrawStyle Delphi eg.
DrawStyle Delphi example:

Picbuf1.DrawStyle:=0;


DrawStyle property VB eg.
DrawStyle property VB example:

Picbuf1.DrawStyle = DSSolid


DrawStyle property eg.
Visual Basic

Delphi


DrawWidth Delphi eg.
DrawWidth Delphi example:

Picbuf1.DrawWidth = 3:


DrawWidth VB eg.
DrawWidth VB example:

Picbuf1.DrawWidth = 3


DrawWidth property eg.
Visual Basic

Delphi


DumpControl method Delphi eg.
DumpControl method Delphi example:

Picbuf1.DumpControl(0);


DumpControl method VB eg.
DumpControl method VB example:

Picbuf1.DumpControl DOImagePalette


DumpControl method eg.
Visual Basic

Delphi


DuplicatDib method eg.
Visual Basic

Delphi


DuplicatPalette method eg.
Visual Basic

Delphi


DuplicateDib method Delphi eg.
DuplicateDib method Delphi example:

{A double named hDIB must be declared before using this code.}

hDIB:=Picbuf1.DuplicateDib(False);


DuplicateDib method VB eg.
DuplicateDib method VB example:

Dim hDIB As Double

hDIB=Picbuf1.DuplicateDib False


DuplicateDib method VB example:
DuplicatePalette method VB example:

Dim hPal As Double

hPal=Picbuf1.DuplicatePalette


DuplicatePalette method Delphi eg.
DuplicatePalette method Delphi example:

{A double named hPal must be declared before using this code.}

hPal := Picbuf1.DuplicatePalette;


Electronic Service Request Form
ImageKnife Help

Electronic Service Request Form

Please use this form if you are having problems or encountering errors using our tools.  Requests submitted in this form will receive a higher priority than those without.  Please modify this form if appropriate for your situation.  (Contact information required)  Forms may be e-mailed, faxed,  or mailed to Media Architects.  If e-mailing, please cut and paste.  Do not send the form attached to an e-mail as a separate file.

For duplication and debugging purposes, sometimes it helps to have a small sample program.  If you can get us a small example with source code that duplicates the problem on your system, it helps us greatly.  Please keep these samples as small as possible, since this reduces the number of possible causes of the problem.  Also, please include a completed copy of this page in the .ZIP file, as it will enable our support personnel to quickly link example code to its owner

When submitting this file to Media Architects via fax or e-mail, please delete this header text.

---

Media Architects Electronic Service Request rev 1.1

E-mail: support@mediarch.com   CompuServe: 74774,707   Fax: (503) 620-5451

Contact Information:

Name:

Company Name:

Serial #(required):

E-mail Address:

Fax:

Voice:

Product Information:

Product Name:

Version (from the version property):

16 or 32 bit version:

System Information:

Processor type (i.e. Pentium 90):

RAM (i.e. 16 megs):

Video card (i.e. #9 GXE):

Video mode (i.e. 640x480x16bit high color):

Operating System (i.e. Windows 95):

Programming environment (i.e. VB4.0 16-bit):

Misc (scanners, printers, etc. as relevant):

How would you like us to contact you (Fax or E-mail preferred):

What are you trying to do? (describe the goal):

What is happening? (Please include the exact wording and titles of any messages that appear on the screen.)

What steps are you taking which causes this? (if appropriate, a short 5-10 line sample should be adequate)  [Note: The more clearly this is documented, the easier it is for us to diagnose.]

How have you tried to solve the problem?


ErrorDump method Visual Basic Example:

Picbuf1.ErrorDump "(filename.ext)"


ErrorDump method Delphi Example:

Picbuf1.ErrorDump '(filename.ext)';


ErrorDump method eg.
Visual Basic

Delphi


ErrorNumber Delphi eg.
ErrorNumber property Delphi example :

{ this code will load an image selected in an Open Dialog Box }

  try {Set trap}

    {Protected Code}

    Picbuf1.Filename := OpenDialog.Filename;

    Picbuf1.Load;

    {end of protected Code}

  except

    on E:EOleError do {This will only Catch OleErrors[OCX]}

    begin

      Case Picbuf1.ErrorNumber of {Use Case statement to handle specific errors}

        0:     {put code here}; {Not generated by ImageKnife}

        20100: {put code here}; {The file doesn’t exist}

        20101: {put code here}; {The file was of the incorrect type or corrupted}

          .

          .

          .

      end; {Case}

      PicBuf1.ErrorNumber := 0; { reset the error property }

  end;


ErrorNumber VB example :
Error Number property VB Example:

picbuf1.ErrorNumber =  0


ErrorNumber eg.
Visual Basic

Delphi


ErrorNumber property eg.
Visual Basic

Delphi


ExportDib method Delphi eg.
ExportDib method Delphi example:

//A double named hDIB must be declared before using this code.

hDIB:=Picbuf1.ExportDib(True);


ExportDib method VB eg.
ExportDib method VB example:

Dim hDIB as Double

hDIB=Picbuf1.ExportDib True


ExportDib method eg.
Visual Basic

Delphi


ExtractEdges method Delphi eg.
ExtractEdges method Delphi example:

Picbuf1.ExtractEdges(5);


ExtractEdges method VB eg.
ExtractEdges method VB example:

Picbuf1.ExtractEdges


ExtractEdges method eg.
Visual Basic

Delphi


FileName property Delphi eg.
FileName property Delphi example:

Picbuf1.Filename:=’Mediarch.bmp’;


FileName property VB eg.
FileName property VB example:

Picbuf1.FileName="Mediarch.bmp"


Filename property eg.
Visual Basic

Delphi


FillColor Delphi eg.
FillColor Delphi example:

Picbuf1.FillColor:=RGB(255,0,0);


FillColor VB eg.
FillColor VB example:

Picbuf1.FillColor = RGB (255, 0, 0)


FillColor pproperty eg.
Visual Basic

Delphi


FillStyle property Delphi eg.
FillStyle property Delphi example:

Picbuf1.FillStyle:=0;


FillStyle property VB eg.
FillStyle property VB example:

Picbuf1.FillStyle = FSSolid


FillStyle property eg.
Visual Basic

Delphi


FillTransparent property Delphi eg.
FillTransparent property Delphi example:

Picbuf1.FillTransparent:=True;


FillTransparent property VB eg.
FillTransparent property VB example:

Picbuf1.FillTransparent = True


FillTransparent property eg.
Visual Basic

Delphi


Fonat property Delphi eg.
Font property Delphi example:

Picbuf1.Font.Bold := True  { Make the font Bold }

PicBuf1.Font.Size := 10 { Make the font 10 pt }


FonatTransparent property VB eg.
FontTransparent property VB example:

Picbuf1.FontTransparent = True


Font Property eg.
Visual Basic

Delphi


Font property VB eg.
Font property VB example:

Picbuf1.Font.Bold = True  ' Make the font Bold

PicBuf1.Font.Size = 10 ' Make the font 10 pt


FontTransparent Delphi eg.
FontTransparent property Delphi example:

Picbuf1.FontTransparent:=True;


FontTransparent property eg.
Visual Basic

Delphi


Gamma method Delphi eg.
Gamma method Delphi example:

Picbuf1.Gamma(5);


Gamma method Vb eg.
Gamma method VB example:

Picbuf1.Gamma 5


Gamma method eg.
Visual Basic

Delphi


GetColor method Delphi eg.
GetColor method Delphi example:

//The long nColor must be declared for this code to function properly.

nColor:=Picbuf1.GetColor(1,1);


GetColor method VB eg.
GetColor method VB example:

Dim nColor As Long

nColor=Picbuf1.GetColor 1, 1


GetColor method eg.
Visual Basic

Delphi


GetColorCount Array method eg.
GetColorCountArray method VB example:

‘There must be an array of long named ColorArray for this code to work properly.

Picbuf1.GetColorCountArray ColorArray


GetColorCount method Delphi eg.
GetColorCount method Delphi example:

Picbuf1.GetColorCount;


GetColorCount method VB eg.
GetColorCount method VB example:

Picbuf1.GetColorCount


GetColorCount method eg.
Visual Basic

Delphi


GetColorCountArray method Delphi eg.
GetColorCountArray method Delphi example:

//There must be an array of long named ColorAray for this code to work properly.

Picbuf1.GetColorCountArray(ColorArray);


GetColorCountaArray method eg.
Visual Basic

Delphi


GetHorzSBHeight method Delphi eg.
GetHorzSBHeight method Delphi example:

//The integer intScrollHeight must be declared before using this line of code.

intScrollHeight:=Picbuf1.GetHorzSBHeight


GetHorzSBHeight method VB eg.
GetHorzSBHeight method VB example:

Dim intScrollHeight As Integer

intScrollHeight = Picbuf1.GetHorzSBHeight


GetHorzSBHeight method eg.
Visual Basic

Delphi


GetPalCaolor method eg.
Visual Basic

Delphi


GetPalColor method Delphi eg.
GetPalColor method Delphi example:

//The long nPalCol must be declared for this code to function properly.

nPalCol:=Picbuf1.GetPalColor(255);


GetPalColor method VB eg.
GetPalColor method VB example:

Dim nPalCol As Long

nPalCol=Picbuf1.GetPalColor 255


GetPalIndex method Delphi eg.
GetPalIndex method Delphi example:

//The integer intPalInd must be declared for this code to function properly.

intPalInd:=Picbuf1.GetPalIndex(1,1);


GetPalIndex method VB eg.
GetPalIndex method VB example:

Dim intPalInd As Integer

intPalInd=Picbuf1.GetPalIndex 1, 1


GetPalIndex method eg.
Visual Basic

Delphi


GetPalette method Delphi eg.
GetPalette method Delphi example:

//There must be an array of long named ColorArray for this code to work properly.

Picbuf1.GetPalette(ColorArray);


GetPalette method eg.
Visual Basic

Delphi


GetPlaette method VB eg.
GetPalette method VB example:

‘There must be an array of long named ColorArray for this code to work properly.

Picbuf1.GetPalette ColorArray


GetScanLine method Delphi eg.
GetScanLine method Delphi example:

{An array of long named ColArray must be present for this code to function properly.}

{ GetScanLine expects a pointer to a one dimensional array of longint to fill }

Picbuf1.GetScanLine(1,@ColArray);


GetScanLine method VB eg.
GetScanLine method VB example:

‘An array of long named ColArray must be present for this code to function properly.

Picbuf1.GetScanLine 1,ColArray(1)


GetScanLine method eg.
Visual Basic

Delphi


GetVertSBWidth method Delphi eg.
GetVertSBWidth method Delphi example:

//The integer intScrollWidth must be declared before using this line of code.

intScrollWidth:=Picbuf1.GetVertSBWidth;


GetVertSBWidth method VB eg.
GetVertSBWidth method VB example:

Dim intScrollWidth As Integer

intScrollWidth = Picbuf1.GetVertSBWidth


GetVertSBWidth method eg.
Visual Basic

Delphi


GrayScale method Delphi eg.
GrayScale method Delphi example:

Picbuf1.GrayScale;


GrayScale method VB eg.
GrayScale method VB example:

Picbuf1.GrayScale


GraySclae method eg.
Visual Basic

Delphi


ImageFormat property VB eg.
ImageFormat property VB example:

Picbuf1.ImageFormat=IFBmp


ImageFormat property eg.
Visual Basic

Delphi


ImageKnife And FIFs
ImageKnife Help

ImageKnife And FIFs (Fractal Image Format)

What is a FIF?

A Fractal Image File (FIF) is a file compressed using a proprietary format from Iterated Systems Inc..  ImageKnife can decompress these files using a .dll supplied by Iterated Systems.  In order to create FIF files, it is necessary to acquire software directly from Iterated Systems.  This appendix explains the advantages of this fractal compression technology, tells you how to reach Iterated Systems, and explains in more detail how to use fractal decompression in ImageKnife.

Why Use FIFs?

Since 1987 Iterated Systems has led the way in developing software technologies for today’s and tomorrow’s image representation needs. Digital images can be compressed using Iterated’s Fractal Transform method to create Fractal Image Format (FIF) files. FIFs offer tremendous advantages over other image formats, such as:

• Resolution Independent - Similar to page description languages like PostScript, FIFs can be decompressed to resolutions and color depths both higher and lower than the original.

• Scaling - A single compressed image can serve as both a “thumbnail” and a full-screen image.

• Zooming - You can zoom it to reveal additional details unnoticeable in the original.

• High Compression Ratios - Since FIFs store codes rather than actual pixels, you can achieve very high compression ratios and high quality. At lower compression ratios, images are visually lossless.

Other digital technologies store images as pixels, resulting in blockiness when the images are blown up. The Fractal Transform locates similar and repeated patterns in an image and stores these patterns as fractal codes in the FIF file. Pixel-by-pixel intensity values become irrelevant. Because only the algorithms are stored, you get tighter compression, speedier transmission, and faster display and download.

Fractal Images vs. Pixel Images

The main disadvantages of the pixel model are caused by the limitations of image resolution. Each pixel is an averaged value, representing the intensity or color of an area of a continuous real-world image. The resolution of the file is the number of pixels used to represent a given area.

A low resolution pixel file uses fewer pixels to record an image, resulting in smaller files that contain less data. However, detail in the image is sacrificed.

A high resolution pixel file may record a more desirable level of detail, but, since more pixels must be recorded, these pixel files can be large, unmanageable, and costly to store and download.

FIFs represent an image entirely in terms of its fractal properties. Rather than a set of values for every pixel, a FIF file contains a record of repeated patterns that exist in the image.

These patterns can be expressed with substantially fewer numbers, making fractal image files much smaller. Nothing in the process of recording these patterns assumes a particular pixel grid.

Resolution Independence

Images may be viewed on a monitor with one resolution, printed on a printer with another resolution, and used in an application at still another resolution. Since pixel-based image formats are digitized to a specific resolution, these images have no native scaling properties that provide them this kind of flexibility. Methods such as linear scaling or cubic interpolation can be used to convert a pixel-based image to another resolution, but the converted image often looks artificially smoothed or washed out, resulting in a significant loss in image quality.

Since no pixel grid or resolution information is stored in a FIF file, fractal images are resolution independent. FIFs can be displayed and printed at almost any resolution. The same image can be viewed as a thumbnail, or at a size larger than its original pixel counterpart.

How are FIFs Created?

FIFs are created using the Fractal Transform process, in which the input image is systematically searched for matching patterns. First, the entire image is divided into regions called domain blocks. For each domain block, another region in the image is selected that closely matches the domain, called the range block. Range blocks are usually larger than domain blocks and can be rotated or reflected to more closely match the domain.

The location of the range block and the data needed to transform it to the domain block are the only information saved in the FIF file. Therefore, the image is stored in terms of itself and its fractal properties instead of containing data for each and every pixel. This method requires far fewer bytes than traditional image storage and compression schemes.

How are FIFs Decoded?

When a fractal image is decoded to a pixel file, display monitor, or printer, its resolution independence allows it to be displayed at a wide range of resolutions, both smaller and larger than the original pixel image.

Once displayed, the image can be zoomed and new detail is created from the fractal properties of the image. Fractal zooming provides high quality zoomed images that do not have the blocky appearance associated with the pixel replication and interpolation techniques used to zoom other data types.

When Should I Use FIF?

FIFs can be used for almost all image types. The amount of compression you can acheive depends on the type of image being compressed and the desired quality. For example, real-world images compress especially well. FIF is ideal for images that will be used in more than one medium, such as printed and online. Any images that will be zoomed are best compressed as FIFs to avoid the blockiness and jagged edges common in other formats. FIF files are extremely flexible and offer advantages that other file formats simply do not have.

How do I  Reach Iterated Systems?

Should you be interested in further exploring the benifits that fractal Image Compression can offer your application or content, you will want to get a copy of Fractal Imager (the complete Fractal Image Compression tool) from Iterated Systems.  They maintain a WWWeb site at http:/www.iterated.com..  You may also contact them directly at 1-800-437-2285 or 1-404-840-0310.


ImageKnife and Borland Delphi 2.0
ImageKnife Help

Using ImageKnife in Borland Delphi 2.0

Introduction

Delphi 2.0 is one of the latest and most powerful RAD (Rapid Application Development) programming tools, and ImageKnife/OCX can be used within Delphi 2.0 to produce powerful graphical applications.  Before proceeding with installation of the control into Delphi 2.0, you should pay close attention to the introduction and installation sections in the help file, making sure that everything else has been set up correctly.

Installation into Delphi 2.0

Delphi 2.0 enables you to import ‘OLE’ controls (or OCX’s) and treat them as Delphi components,  just as you could with VBX controls in Delphi 1.0.  After starting Delphi, follow these directions to import ImageKnife/OCX.

1) From the main menu choose Component | Install to open the Install Component dialogue box.

2) Choose OCX to open the ‘Import OLE control’ dialogue box.

3) OLE controls must be registered with Delphi before you can use them.  Your ImageKnife control should be automatically registered for you by the Imageknife installation program.  Look under the ‘Registered Controls’ list.  If you find the Media Architects ImageKnife Control select it and proceed to Step 6.  Otherwise choose Register  to open the ‘Register OLE Control’ dialogue box.

4) Use the Register OLE Control dialogue box to locate and open the OCX control. Navigate to the directory where you installed the control, select the ‘IK32.OCX’ file.  Select OK.

5) Delphi returns you to the ‘Import OLE Control’ dialogue box where the newly registered OCX control appears in the ‘Registered Controls’ list box.  Select the Media Architects ImageKnife control from the Registered control list,  then proceed to Step 6.

Notes:

When you import an OLE control, Delphi must generate a ‘component wrapper’ for that control. The Unit File Name and the Class Name edit boxes enable you to specify a file name and a class name for the OLE control.  However, when you select a control Delphi automatically enters names into these edit fields, and you should normally accept these defaults.  The ImageKnife/OCX default class name is ‘TPicbuf’ and will be referenced as a PicBuf in all of your code.  After this process is complete, the ImageKnife control becomes, in effect, a native ‘TObject’ like any other VCL component.  Full explanations  regarding TObjects can be found in your Delphi reference manuals.

The ‘component  wrapper’ files allows Delphi to communicate with the OLE control, and any project or form containing the ImageKnife control (Picbuf) must refer to this file in its Unit’s ‘Uses’ clause.  This isn’t normally a concern because whenever you place a Picbuf control on a form Delphi automatically adds the file to the uses clause for you.   When you install the ImageKnife control, the wrapper file created by Delphi is named ‘ImageKnife32.Pas’ by default and can be found in Delphi’s Lib directory, which is by default \Borland\Delphi 2.0\Lib\.  Consult the documentation below for more information regarding this wrapper file.

6) Click OK.  Delphi closes the Import OLE Control dialogue box, and returns you to the Install Component dialogue.  The new OCX control appears in the ‘Installed Units’ list.

7) On the Install Component dialogue box, click OK.  Delphi closes this dialogue box, rebuilds the component library,  and installs the OCX control on the ‘Component Palette’.

8) What you should now do to fix some of the parameters mistakenly generated by Delphi, and to ensure optimal performance of the control in Delphi is run the Media Architects DELCONV utility, which is distributed with the product, and should have been installed in your root ImageKnife directory, on the wrapper (‘ImageKnife32.Pas’).  (See help on using the Delphi Wrapper Conversion Utility for directions).  Now if you just rebuild your library, the installation is complete and you are ready to use the control.   Several Delphi 2.0 examples are supplied with the ImageKnife and are a great learning tool for new users.

Upgrading

If you already have a version of ImageKnife/OCX installed and are upgrading to new version, then there are certain things you need to be aware of, and may need to do to upgrade existing projects for use with the new control (Note: if you install a new version of Delphi, you may need to follow these same directions to ensure proper operation).  Unlike Borland’s VBX support in Delphi 1.0, the OCX support in Delphi 2.0 stores almost all of the property values for the control in one large “chunk” of numbers following the heading ControlData in the Form file.  The problem with this is that if a property is added, or changed, possibly even the version property which gets changed with every update, your old projects will not be able to load without some modification.  Currently our best solution to this problem is the following.  Before installing the new control note any design time property settings for the control you want to keep.  Next, re-install the new control in Delphi allowing it to re-generate a new wrapper for the control.  Then run the DELCONV utility (see help for instructions on using this utility) to ensure optimal performance of the wrapper, and finally rebuild the library (Note: that is essentially the same as installing a new control, so the above Installation instructions apply).  Now on a new project with blank form, place one PicBuf and set any properties you want to, then save the project.  Now open up the .FRM file created for the project you just saved from within Delphi.  Delphi will open the binary Form file as text.  Search through the file until you find the Control Data section, and copy it along with all the numbers between the {}’s (this is the initialization data) to the clipboard.  Now load up the .FRM files from your old projects and replace their Control Data section with the section you copied to the clipboard.  Finally, save everything and your project files will all open fine.  Because of the way this works, and if you ever plan on an upgrade, it may be in your best interests to set most of the properties of the control at runtime to simplify the upgrading process.

The ‘ImageKnife32.Pas’ wrapper file

The wrapper file controls the interface between ImageKnife/OCX and Delphi 2.0.  Delphi analyzes the control and automatically generates the wrapper file to fit the control as best it can.  Unfortunately, what it generates is not always exactly what you want, or what you are expecting.  This is often the case with the parameters to various functions and procedures.  Media Architects has developed a utility named DELCONV, and generated modification files which will modify the wrapper file generated by Delphi, automatically changing parameters, and fixing any other inconsistencies which should be changed in order for the control to run at an optimal level.  (See help on using the Delphi Wrapper Conversion Utility for directions)

If you wish to perform the alterations manually, or would like to modify Media Architects conversion file for the OCX to better suit your needs, the following examples indicate the general method for alterations.  With Delphi running you can open the file with the code editor - File | Open | ‘ImageKnife32.Pas’.

Within the file you will find definitions of all supported functions and properties. If you experience errors when using the controls functions, usually along the lines of the ‘Parameter Type Mismatch’, the problem can normally be traced to the definition within the wrapper file.  For a few of the functions Delphi expects a given format type, and the wrapper file must be adjusted to accept the required type.   Some examples of corrected procedure definitions are listed below.   Prior to making any alteration we recommend you make a backup copy of the original wrapper.

Original

procedure GetScanLine(nLine: Smallint; var pScanLine: TColor); stdcall;

procedure PutScanLine(nLine: Smallint; var pLine: TColor; nUpdate: Variant); stdcall;

Modified

procedure GetScanLine(nLine: Smallint; pScanLine: array of TColor); stdcall;

procedure PutScanLine(nLine: Smallint; pLine: array of TColor); stdcall;

Note that the changes in the above procedure parameters could have been made slightly differenty with successful results, but the changes made most closely resemble what Delphi automatically generates, and what you would expect to pass in.

Using the Control

Several Delphi examples are distributed with ImageKnife and are a great way to familiarize yourself with the control.  The basic process to be followed in using ImageKnife within Delphi is as follows (This assumes you have already successfully installed ImageKnife into Delphi 2.0).   To build a simple application first start a new project.  Next locate the ImageKnife control (a PicBuf) which can be found on the ‘OCX’ tab of the Delphi tool palette. Place an instance of the PicBuf on your form as you would any other VCL control.   You can adjust any of the control’s properties either using Delphi’s default Object inspector, or by right clicking (or double clicking ) the Picbuf  on the form and pulling up the Media Architects property editor.  Our ‘property page’ as it is called, organizes the properties in logical groups to make it easier for you to find.  This is something common among OCX’s, and is something you may or may not choose to use, it is up to you.  When you become more familiar with ImageKnife you will probably find it easier to use the Object Inspector and edit the properties in alphabetical order as you would with any other VCL control.

The following example presents an ‘File Open Dialogue’ to the user, allows them to select or enter a  file, and then loads that file into the PicBuf.  The following code will work as is as long as you have one PicBuf on the Form, and one ‘FileOpen’ dialogue box named ‘OpenDialogue1’.

If OpenDialogue1.Execute then

begin

  Picbuf1.Filename := OpenDialogue1.Filename; {Set the FileName}

  Picbuf1.Load;                               {Call the Load Method}

end;

In the above example the ‘FileOpen’ dialogue box is first called, then the PicBuf’s Filename property is set to the resulting filename of the Dialogue Box.  Finally you call the Picbufs ‘Load’  method to load the image into the control.

OleObjects

Any function that requires you to pass an actual Picbuf control requires special attention.  Consider the ‘Assign’ function.  Studying the Assign function you will see that it takes three parameters: two Booleans, and one Picbuf control.  For the Booleans, simply pass a Boolean (either ‘True’ or ‘False’).  For the actual Picbuf control you wish to pass you cannot just use the name of the control as you might expect.  ImageKnife expects a variant, for this parameter and so you must pass the controls OleObject property.  For example, a  valid call may look like:

Picbuf2.Assign(False, Picbuf1.OleObject, False);

Note that if you run into any arguments with any OLE controls expecting a variant type, you may need to insert the OleObject property before the actual property you want to pass.  See OleObject  and Variant  in the Delphi documentation for more information.

Passing Parameters

The majority of function calls within ImageKnife require a number of parameters to be passed. If you refer to the various methods in the help system you should be able to determine for the most part what these parameters are. If you run into parameter type conflicts you may need to take a look at the function definitions in your wrapper file.  If you are passing a parameter(s) to an ImageKnife function or method then you must place the parameters within parenthesis as you would with any other Delphi function.   Several examples are listed below.

Picbuf1.SetPalColor(255,rgb(250,250,250));

Picbuf1.ColorReplace(rgb(180,180,180),rgb(255,255,255),-1,rgb(255,0,0));

Picbuf1.Sharpen(10);

Picbuf1.Blur;

Picbuf1.Soften(10);

Picbuf1.SetPalColor(255,rgb(250,250,250));

Form1.Caption:= Picbuf1.InfoImage;

Picbuf1.ColorReplace(rgb(180,180,180),rgb(255,255,255),-1,rgb(255,0,0));

Picbuf1.Init(8,1000,1000,RGB(0,0,255));

Passing Pointers

A few functions for ImageKnife require you to pass a ‘pointer’ in Delphi, for example the MatrixFilter function. The code below contains a simple example for the function, showing its basic usage, along with the passing of pointers to ImageKnife in Delphi.  Note that there are many different ways that arrays can be created and handled, so for full details regarding arrays please refer to your Delphi documentation.

procedure TForm1.Button1Click(Sender: TObject);

Var

  Matrix33data : array[0..2, 0..2] of Integer; {3x3 array}

begin

  Matrix33data[0,0] := -2; {Fill in Values}

  Matrix33data[0,1] := -2;

  Matrix33data[0,2] := -2;

  Matrix33data[1,0] := -2;

  Matrix33data[1,1] := 8;

  Matrix33data[1,2] := 2;

  Matrix33data[2,0] := 2;

  Matrix33data[2,1] := 2;

  Matrix33data[2,2] := 2;

  Picbuf1.MatrixFilter(3,@Matrix33data,1,-5,1); {MatrixFilter call}

end;

You will notice that the ‘Array Parameter’ above is passed as a ‘Pointer’ by using the ‘@’ character.

Error Handling

In an ideal world no errors ever occur, but this is clearly not the case.  Delphi will handle the majority of errors without intervention, however you should, and normally will, trap specific errors so the program and end user can be notified of, and respond to the errors in an appropriate fashion.  If we consider our load example mentioned earlier, we will need to make sure we trap any non valid file types and any other I/O errors.

If Opendialogue.Execute then

begin

  Picbuf1.Filename := Opendialogue.Filename;

  Picbuf1.Load;

end;

In the above example if we leave the code as it stands, at runtime Delphi will produce an error message for you based on the error strings built into ImageKnife if one occurs in the Load method (refer the error codes in the online help for information on these codes and strings).  This is not ideal since the program execution will skip any further code, if it existed, within the above block.  In order to handle errors and therefore protects this block we can use a ‘Try......Except’ error handler.  The initial release of Delphi left out the ability to retrieve an error number from the OleError, it allowed the user to only get at the error string.  This is supposed to be fixed in a maintenance release of Delphi, but Media Architects has added the ErrorNumber property to the control so that users can get at and use the error number returned by the control regardless of the version of Delphi they are using.  The following is an example of error trapping in the above code:

If Opendialogue.Execute then

begin

  try {Set trap}

    {Protected Code}

    Picbuf1.Filename := Opendialogue.Filename;

    Picbuf1.Load;

    {end of protected Code}

  except

    on E:EOleError do {This will only Catch OleErrors[OCX]}

    begin

      Case Picbuf1.ErrorNumber of {Use Case statement to handle specific errors}

        0:     {put code here}; {Not generated by ImageKnife}

        20100: {put code here}; {The file doesn’t exist}

        20101: {put code here}; {The file was of the incorrect type or corrupted}

          .

          .

          .

      end; {Case}

    end;

    Picbuf1.ErrorNumber := 0; {Reset the ErrorNumber to 0 after handling error}

end;

You will notice that if the error code is zero then another object raised the exception, not the Picbuf control.  After you have handled the error you should reset the code to zero to make it ready for the next trap.  Remember to trap any errors not generated by ImageKnife as well as those that are.  Note that the declaration of the E variable is not always necessary, and often not used when trapping standard Delphi errors, but if you want to access properties of the error object, such as the error string for OleError, then it is necessary.

Note: Remember to add the OleAuto unit to the uses clause of any unit in which you wish to trap OLE Control errors like ImageKnife’s.

Enumerated Types (Constants vs. Integers)

Various properties of the PicBuf control are enumerated types which the initial release Delphi 2.0 handles as enumerated in the ‘Object Inspector’ but only allows to be set to integer values in the code, not recognizing the names of the enumerated types.  A maintenance release of Delphi 2.0 is supposed to fix this problem, allowing the enumerated types to be accessed by name rather than only allowing their corresponding integer values.  In order to allow people to use the names with the initial release of Delphi 2.0, Media Architects has created a .PAS file containing constants with the names of all the enumerated types and their corresponding values named IK32.PAS.  To use this file, make sure it is either in Delphi’s Lib directory or in your current project’s directory, then simply add ik32 to the uses section of any unit in which you want access to the constants.  This file was not initially distributed with the product but should now be installed along with other Delphi resources by the ImageKnife installation program. If you do not have this file see Media Architects web site to download the file, or you can also define your own constants (See Delphi help on constants for more information on defining constants).  Note that you should never redefine True or False since these are predefined by Delphi, and if you find a given ImageKnife function will not accept True or False where they should, you can either use (-1) for True and (0) for False, or you can modify the function definition in the wrapper file to accept a Boolean type.  See ‘The “ImageKnife32.Pas” wrapper file’ for more information.

Sometimes it may be more convenient or useful to use the integer representations in your program instead of the named constants.  A good example of this would be with a ‘Combo Box’ containing all the choices a user can have for the AssignMode property.  At design time you would fill in the Strings or Captions  for the list box in the following order:

0 - Total Replacement     	 [ Item Index = 0 ]

1 - Union Composite	 [ Item Index = 1 ]

2 - Intersection Composite 	 [ Item Index = 2 ]

3 - Resize Composite 	 [ Item Index = 3 ]

It is critical that you place them in the above order.  If you do then to set the Picbuf control to a given mode is very simply. Under the click event of the combo box simply place the following code:

procedure TMasterform.AssignBoxClick(Sender: TObject); {Combo Box named AssignBox}

begin

 {Refer to Sending Combobox - i.e. 'AssignBox'}

 with AssignBox do

   begin

     PicbufSrc.AssignMode:=ItemIndex; {Set Mode of Source Picbuf}

   end;

end;

In the above example we simply use the ItemIndex of the current option in the combo box to set the ‘AssignMode’ of the control. Since we placed the strings in the correct order based on ItemIndex we can simply refer one to the other.

Notice also the use of the with...Picbuf...do  Statement.  Refer to your Delphi documentation for more information on the ‘with…do’ statement.  Using this statement allows you to write your code a little faster, cutting down on code repetition.  If you use the ‘with...do’ statement with a PicBuf, then within that block you no longer need to explicitly reference the Picbuf control to gain access to the control’s methods or properties.

with PicBuf do

begin

  LoadHeight := 10;

  LoadWidth := 20;

  BackColor := clAqua;

  AssignMode: = 3;

end;

You can see how within the begin…end  block you no longer need to repeat the Picbuf name reference.

Device Contexts

Note: this information may change in the near future as Media Architects is planning on changing the way it handles the hDC property and related functions.

Every Picbuf can have an associated Device Context (DC) or Contexts. Basic access to a Picbuf’s DC can be achieved through the hDC property (i.e. Picbuf1.hDC).  When accessed, this property creates a Device Context for the PicBuf window, and provides a handle to it (Note: this is not a handle to the actual image data).  The device context can then be used in subsequent API GDI function calls to draw in the client area of the PicBuf window.

This property is commonly used for drawing a bounding rectangle, normally associated with defining a selection area.  Please note the following:  If you intend to use the hDC property for a number of calls, do not repeatedly call or reference the hDC.  Each time you reference the property it gets a new Device context to the PicBuf window without freeing the old.  If you do this enough, you will eventually run out of system resources. You can either assign a variable to the hDC property once and then use that variable in successive calls, or handle the retrieval of the device context yourself using the API call ‘GetDC’ to retrieve the device context.

Use either:

{Set up Variable}

Var

  MyhDC : THandle;

  {Get the DC }

  MyhDC := GetDC(Picbuf1.Handle);

or

  {Get the DC once only and Store it}

  MyhDC := Picbuf1.hDC;

Either of the above methods should work, but remember not to repeatedly call or use Picbuf1.hDC as it stands.  The following call to ‘DrawfocusRect’ would ultimately cause problems on some systems, if you called the function enough times.   If you replaced the Picbuf.hDC by the MyhDC obtained above you should experience no problems.

begin

  Drawfocusrect(Picbuf1.hDC,AreaSelection);

  Drawfocusrect(Picbuf1.hDC,AreaSelection);

  Drawfocusrect(Picbuf1.hDC,AreaSelection);

  .

  .

  .

end;

Note: If you obtain a DC using the GetDC function, you must remember to release when you are done with it using  it with ReleaseDC(Picbuf1.Handle,MyHDC);  The best way to do all of this may change in the near future with ImageKnife.

‘Rubber Band’ Boxes

Another common use of the hDC property is in the creation of ‘rubber band’ boxes around selection areas.  The following example code segment shows how to use the Windows API call ‘DrawFocusRect’ to create ‘rubber band’ boxes on a PicBuf.  The only used events are the MouseDown, MouseMove, and MouseUp events for a PicBuf.

{Interface Section}

Var

  MouseDownX, MouseDownY:Integer;

  Areaselection:Trect;

  MyhDC : Thandle;

{Implementation Section}

procedure TTE_Display.ChildPicbufMouseDown(Sender: TObject; Button: TMouseButton;

                                           Shift:TShiftState; X, Y: Integer);

begin

  {Store into Globals where the user clicks the Mouse}

  MousedownX := X;

  MousedownY := Y;

  if Button = mbLeft then                {If the user is holding the left button}

    MyHDC := GetDC(ChildPicbuf.Handle);  {Get a DC and store it in a Global variable}

end;

procedure TTE_Display.ChildPicbufMouseMove(Sender: TObject; Shift: TShiftState;

                                           X, Y: Integer);

begin

  if ssLeft in Shift then {Left Button only}

  begin

    Drawfocusrect(MyHDC,Areaselection); {Draw Once}

    Areaselection.Top := MousedownY;    {Use Global MouseDown}

    Areaselection.Left := MousedownX;   {Use Global MouseDown}

    Areaselection.Right := X;           {Use Current Mouse Location passed by Delphi}

    Areaselection.Bottom := Y;          {Use Current Mouse Location passed by Delphi}

    Drawfocusrect(MyHDC,AreaSelection); {Erase Last}

  end;{End ssLeft}

end;

procedure TTE_Display.ChildPicbufMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);

begin

  if Button = mbRight then Exit;             {Do Not Cancel DC on right Button Click}

  Drawfocusrect(MyHDC,Areaselection);        {Erase Last Area}

  ReleaseDC(ChildPicbuf.Handle,MyHDC);       {Destroy Device context}

  AreaSelection := ResetRect(AreaSelection); {Reset Area to Zero}

end;

In the above example MouseDownX, MouseDownY, are integers defined as globals in the ‘interface’ section within the unit the Picbuf resides.  ‘Areaselection’ is a TRect structure (Left, Top, Right, Bottom) again defined in the ‘interface’ Section of the unit and the ‘ResetRect’ is a function call to set all the ‘Areaselections’ properties to zero.  If ‘ResetRect’ does not exist you can create the function with the following code :

with Areaselection do

begin

  Left:=0;

  Top:=0;

  Right:=0;

  Bottom:=0;

end;

Additional Tips

To transfer an image from a PicBuf to an Image control (TPicBuf-->Timage) do the following:

Image1.Picture.Bitmap.handle := Picbuf1.DibtoBitmap;

To updates a Label with mouse location and Pixel color do something similar to the following:

begin

  If Picbuf1.Contents <> 1 then exit;

  with Picbuf1 do

    Label1.Caption := 'X: ' + inttostr(ScreenToImageX(X)) +' Y: '

                            + inttostr(ScreenToImageY(Y)) +' Color : '

                            + inttostr(GetColor(X,Y));

end;


ImageKnife and JPEG
ImageKnife Help

ImageKnife and JPEG

What is JPEG?

Why Use JPEG?

When Should I Use JPEG?

How Well Does JPEG Compress Images?

What Are Good "Quality" Settings for JPEG?

Advanced Issues..........

Color Quantization

File Formats

How Do I Recognize Which File Format I Have?

Does Loss Accumulate with Repeated Compression?

What Are the Rules of Thumb for Converting to JPEG?

Performance Issues


ImageNumber Delphi eg.
ImageNumber property Delphi example:

Picbuf1.ImageNumber:=2;


ImageNumber property VB eg.
ImageNumber property VB example:

Picbuf1.ImageNumber = 2


ImageNumber property eg.
Visual Basic

Delphi


ImportDIB method eg.
Visual Basic

Delphi


ImportDib method Delphi eg.
ImportDib method Delphi example:

//There must be a handle to a hDIB before this code will work correctly

Picbuf1.ImportDib(hDIB,True);


ImportDib method VB eg.
ImportDib method VB example:

‘There must be a handle to a DIB named hDIB before this code will function correctly

Picbuf1.ImportDib hDIB, True


IncreaseColors method Delphi eg.
IncreaseColors method Delphi example:

Picbuf1.IncreaseColors(24);


IncreaseColors method VB eg.
IncreaseColors method VB example:

Picbuf1.IncreaseColors 24


IncreaseColors method eg.
Visual Basic

Delphi


InfoIO property Delphi eg.
InfoIO property Delphi example:

{Display information about the image I/O in a pop-up dialog box}

MessageBox(Picbuf1.InfoIO);


InfoIO property VB eg.
InfoIO property VB example:

Dim strIIO As String

strIIO=Picbuf1.InfoIO


InfoIO property eg.
Visual Basic

Delphi


InfoImage property Delphi eg.
InfoImage property Delphi example:

{Display information about the image in a pop up dialog box }

ShowMessage(Picbuf1.InfoImage);


InfoImage property VB eg.
InfoImage property VB example:

Dim strIO As String

strIO=Picbuf1.InfoImage


InfoText property Delphi eg.
InfoText property Delphi example:

{Display information about the image text in a pop-up dialog box}

MessageBox(Picbuf1.InfoText);


InfoText property VB eg.
InfoText property VB example:

Dim strIT As String

strIT=Picbuf1.InfoText


InfoText property eg.
Visual Basic

Delphi


InfoView property VB eg.
InfoView property VB example:

Dim strIO As String

strIO=Picbuf1.InfoView


InfoView property eg.
Visual Basic

Delphi


Infolmage property eg.
Visual Basic

Delphi


Infoview property Delphi example:

{Display information about the image view in a pop-up dialog box}

MessageBox(Picbuf1.InfoView);


Init method Delphi eg.
Init method Delphi example:

Picbuf1.Init(24,100,100,RGB(255,255,));


Init method VB eg.
Init method VB example:

Picbuf1.Init 24,100,100,RGB(255,255,0)


Init method eg.
Visual Basic

Delphi


LaodPal method Delphi eg.
LoadPal method Delphi example:

Picbuf1.LoadPal;


LoaadCropLeft property eg.
Visual Basic

Delphi


LoaadFastest property VB eg.
LoadFastest property VB example:

Picbuf1.LoadFastest = True


Load Height, Load Width eg.
Visual Basic

Delphi


Load method Delphi eg.
Load method Delphi example:

Picbuf1.Load;


Load method Vb eg.
Load method VB example:

Picbuf1.Load


Load method eg.
Visual Basic

Delphi


LoadCallback method Delphi eg.
LoadCallback method Delphi example:

Picbuf1.LoadCallback(Form1);


LoadCallback method VB eg.
LoadCallback method VB example:

Picbuf1.LoadCallback Form1


LoadCallback method eg.
Visual Basic

Delphi


LoadCropLeft Delphi eg.
LoadCropLeft etc., property Delphi examples:

Picbuf1.LoadCropLeft:=30;

Picbuf1.LoadCropTop:=30;

Picbuf1.LoadCropWidth:=30;

Picbuf1.LoadCropHeight:=30;


LoadCropLeft property VB eg.
LoadCropLeft etc., property VB examples:

Picbuf1.LoadCropLeft = 30

Picbuf1.LoadCropTop = 30

Picbuf1.LoadCropWidth = 30

Picbuf1.LoadCropHeight = 30


LoadFastest
LoadFastest property

Overview	Allows the user to optionally have the .FIF decompressor define the optimal width and height at which to decompress to.

Data Type	Boolean

Syntax	Picbuf.LoadFastest = True

Remarks	Finds the best size to decompress to using the LoadWidth and LoadHeigth properties as starting points.  This property is only operational for FIF files.


LoadFastest property Delphi eg.
LoadFastest property Delphi example:

Picbuf1.LoadFastest:=True;


LoadFastest property eg.
Visual Basic

Delphi


Load Height,LoadWidth properties

Overview	This property determines the width scale (in pixels) for FIF decompression if LoadScale property = 3 (IgnoreScale).

Data Type	Integer

Syntax	PicBuf.LoadWidth[ = width]

Remarks	Defaults to 0


LoadHeight, LoadWidth properties Delphi example:

Picbuf1.LoadHeight:=5;

Picbuf1.LoadWidth:=5;


LoadHeight, LoadWidth properties example:

Picbuf1.LoadHeight = 5

Picbuf1.LoadWidth = 5


LoadOptions
LoadOptions property

Description	Defines the bit depth and dither for the .FIF -image with the Load or LoadCallBack methods.

Data Type	short enum

Syntax	picbuf1.LoadOption = option

Part	Description
Option	The option to use for loading the file.
Setting	Constant	Description
0	L024	Decompress to 24-bit true color.
1	L08 Dithered	Decompress to 8-bit
2	L08	Decompress to 8-bit


LoadOptions property Delphi eg.
LoadOptions property Delphi example:

Picbuf1.LoadOptions:=0;


LoadOptions property VB eg.
LoadOptions property VB example:

Picbuf1.LoadOptions = LO24


LoadOptions property eg.
Visual Basic

Delphi


LoadPal method Vb eg.
LoadPal method VB example:

Picbuf1.LoadPal


LoadPal method eg.
Visual Basic

Delphi


LoadPalette
LoadPalette property

Overview	Defines a handle to a palette to use for .FIF decompression with Load or ikLoadCallback.  The client is responsible for the memory associated with the handle.

Data Type	short

Syntax	picbuf1.LoadPalette = hPalette

Part	Description
hPalette	The handle to a palette.

Remarks	This property specifies the windows palette to be used to decompress  to when loading a FIF file.  Allows the user to control the palette used when decompressing a FIF file.


LoadPalette property Delphi eg.
LoadPalette property Delphi example:

//There must be a handle to a Palette named hPal present for this code to function correctly.

Picbuf1.LoadPalette:=hPal;


LoadPalette property See Also
See Also

LoadOptions


LoadPalette property VB eg.
LoadPalette property VB example:

‘There must be a handle to a Palette named hPal present for this code to function correctly.

Picbuf1.LoadPalette = hPal


LoadPalette property eg.
Visual Basic

Delphi


LoadScale
LoadScale property

Overview	Indicates the .FIF  decompression scale mode to use for Load or LoadCallback.

Data Type	short enum

Syntax	picbuf1.LoadScale = scale

Part	Description
Scale	Denotes the scale option to use.
Setting	Constant	Description
0	LSFullScale	Loads the original resolution of image before compression
1	LSHalfScale	Loads Half the original resolution
2	LSDoubleScale	Loads twice the original resolution (limited to images with an original area less than or equal to 64,000 pixels)
3	LSIgnoreScale	The scale is set by LoadHeight and LoadWidth properties.
Note : For values 0, 1, 2, LoadHeight and LoadWidth are ignored.


LoadScale property Delphi eg.
LoadScale property Delphi example:

Picbuf1.LoadScale:=0;


LoadScale property VB eg.
LoadScale property VB example:

Picbuf1.LoadScale = LSFullScale


LoadScale property eg.
Visual Basic

Delphi


MapIndex method Delphi eg.
MapIndex method Delphi example:

Picbuf1.MapIndex(1,2);


MapIndex method Vb eg.
MapIndex method Vb example:

Picbuf1.MapIndex 1, 2


MapIndex method eg.
Visual Basic

Delphi


MaskCopy method Delphi eg.
MaskCopy method Delphi example:

//Three picbuf controls must be present, and have images loaded for this code to function properly.

Picbuf1.MaskCopy(Picbuf2,Picbuf3);


MaskCopy method VB eg.
MaskCopy method VB example:

‘Three picbuf controls must be present, and have images loaded for this code to function properly.

Picbuf1.MaskCopy Picbuf2, Picbuf3


MaskCopy method eg.
Visual Basic

Delphi


MatrixFilter method Delphi eg.
MatrixFilter method Delphi example:

//An array of integers for the MatrixFilter must be present for this code to function properly.

Picbuf1.MatrixFilter(5,Matrix,1,1,1);


MatrixFilter method VB eg.
MatrixFilter method VB example:

‘An array of integers for the MatrixFilter must be present for this code to function properly.

Picbuf1.MatrixFilter 5, Matrix,1,1,1


MatrixFilter method eg.
Visual Basic

Delphi


Methods
Color

Drawing

File I/O

Image Processing

Utilities


Mirror method Delphi eg.
Mirror method Delphi example:

Picbuf1.Mirror(True,False);


Mirror method VB eg.
Mirror method VB example:

Picbuf1.Mirror True, False


Mirror method eg.
Visual Basic

Delphi


MousePOinter property VB eg.
MousePointer property VB example:

Picbuf1.MousePointer = MPArrow


MousePointer property Delphi eg.
MousePointer property Delphi example:

Picbuf1.MousePointer:=1;


MousePointer property eg.
Visual Basic

Delphi


Neagate method Delphi eg.
Negate method Delphi example:

Picbuf1.Negate;


Negate method VB eg.
Negate method VB example:

Picbuf1.Negate


Negate method eg.
Visual Basic

Delphi


OptimizePal method Delphi eg.
OptimizePal method Delphi example:

//There must be an array of picbuf controls all with images loaded for this code to work properly.

Picbuf1.OptimizePal(ctrlArray,3,255);


OptimizePal method VB eg.
OptimizePal method VB example:

‘There must be an array of picbuf controls all with images loaded for this code to work properly.

Picbuf1.OptimizePal ctrlArray, 3, 255


OptimizePal method eg.
Visual Basic

Delphi


OptimizePalFiles method Delphi eg.
OptimizePalFiles method Delphi example:

//There must be an array of picbuf controls all with images loaded, and an array of palette files for this code to work properly.


OptimizePalFiles method Vb eg.
OptimizePalFiles method VB example:

‘There must be an array of picbuf controls all with images loaded, and an array of palette files for this code to work properly.


OptimizePalFiles method eg.
Visual Basic

Delphi


PasteClipboard method Delphi eg.
PasteClipboard method Delphi example:

Picbuf1.PasteClipboard(0);


PasteClipboard method VB eg.
PasteClipboard method VB example:

Picbuf1.PasteClipboard


PasteClipboard method eg.
Visual Basic

Delphi


Picture property Delphi eg.
Picture property Delphi example:

The Picture property is compatible only with Visual Basic's Picture Box.  You may assign the Picture properties of two PicBuf's to each other, but if you wish to move between a Delphi TImage component and a PicBuf, use ImportBitmap instead.  (See the Delphi reference section under Programming for more information)


Picture property VB eg.
Picture property VB example:

‘There must be two picbuf contols with images loaded for this code to work

Picbuf1.Picture=Picbuf2.Picture


Picture property eg.
Visual Basic

Delphi


Pie Method VisBas eg.
Pie Method VB example:

Picbuf1.Pie 1, 2, 3, 4


Pie method Delphi eg.
Pie method Delphi example:

Picbuf1.OLEObject.Pie(1,2,3,4,True)


Pie method VB eg.
Visual Basic

Delphi


PolyLine method Delphi eg.
PolyLine method Delphi example:

{ PntArray is a two dimensional array of longint }

Picbuf1.OLEObject.PolyLine(PntArray,5,1)


PolyLine method VB eg.
PolyLine method VB example:

Picbuf1.PolyLine PntArray, 5, 1


PolyLine method eg.
Visual Basic

Delphi


Polygon method Delphi eg.
Visual Basic

Delphi


Polygon method Delphi egs.
Polygon method Delphi example:

Picbuf1.Polygon(PntArray,5,1,1,1)


Polygon method VB eg.
Polygon method VB example:

Picbuf1.Polygon PntArray, 5, 1, 1


PrintHeight, PrintWidth properties Delphi eg.
PrintHeight, PrintWidth properties Delphi examples:

Picbuf1.PrintHeight:=1;

Picbuf1.PrintWidth:=1;


PrintHeight, PrintWidth properties VB eg.
PrintHeight, PrintWidth properties VB examples:

Picbuf1.PrintHeight = 1

Picbuf1.PrintWidth = 1


PrintHeight, Width properties eg.
Visual Basic

Delphi


PrintLeff, Top properties eg.
Visual Basic

Delphi


PrintLeft, PrintTop props. Delphi eg.
PrintLeft, PrintTop properties Delphi examples:

Picbuf1.PrintLeft:=1;

Picbuf1.PrintTop:=1;


PrintLeft,Top props. VB eg.
PrintLeft, Print Top properties VB examples:

Picbuf1.PrintLeft = 1

Picbuf1.PrintTop = 1


PrinterhDC property Delphi eg.
PrinterhDC property Delphi example:

// hDC must reference a handle to a Printer's Device Context for this to function correctly.

Picbuf1.PrinterhDC := hDC;


PrinterhDC property VB eg.
PrinterhDC property VB example:

Dim hDC As Double

Picbuf1.PrinterhDC=hDC


PrinterhDC property eg.
Visual Basic

Delphi


PutColor
PutColor Method

Overview	Stores the specified color at a specific pixel location within the image.

Return Type	void

Syntax	PicBuf.PutColor pixelX, pixelY, color

Part	Data Type	Description
PixelX	Short	the x-coordinate of the pixel to obtain the color value from
PixelY	Short	the y-coordinate of the pixel to obtain the color value from
color	OLE color	The color to be placed at pixelX, pixelY.  This is a windows COLORREF value.
Remarks	If the image is a twenty-four bit image the color (parameter color) value is inserted directly into the image.  If the image has a palette (an eight or four bit image), the  color should reference an existing palette entry.  If the color does not exist in the palette, the closest palette index will be used.


PutColor Method VB example:

Dim nColor As Long

nColor=Picbuf1.PutColor 1, 1


PutColor Method eg.
Visual Basic

Delphi


PutColor method Delphi example:

//The long nColor must be declared for this code to function properly.

nColor:=Picbuf1.PutColor(1,1);


PutScanLine method VB eg.
PutScanLine method VB example:

‘The array of long ColArray must be present and filled with color values for this code to function properly.

Picbuf1.PutScanLine 1, ColArray(1), True


PutScanLine method eg.
Visual Basic

Delphi


PutScanlLine method Delphi eg.
PutScanLine method Delphi example:

{ The array of long ColArray must be present and filled with color values for this code to function properly.}

Picbuf1.PutScanLine(1, @ColArray,True);


RasterOp Property eg.
Visual Basic

Delphi


RasterOp property

Overview	This mode determines how drawing objects are displayed.

Return Type	short (Enumerated)

Syntax	Picbuf1.RasterOp = option

Part	Description
Option	Sets the mode to use when drawing objects are displayed.
Setting	Constant	Description
0	ROBlack	Pixel = Black
1	RONotMergePen	Pixel = ~(BC | screen)
2	ROMaskNotPen	Pixel = ~BC & screen
3	RONotCopyPen	Pixel = BC & screen
4	ROMaskPenNot	Pixel = ~(BC & screen)
5	RONot	Pixel = BC ^ screen
6	ROXORPen	Pixel = ~ Screen
7	RONotMaskPen	Pixel = ~screen | BC
8	ROMaskPen	Pixel = ~ BC
9	RONotXORPen	Pixel = ~(BC ^ screen)
10	RONOP	Pixel = No Change
11	ROMergeNotPen	Pixel = ~BC | screen
12	ROCopyPen	Pixel = BC
13	ROMergePenNot	Pixel = ~screen & pen
14	ROMergePen	Pixel = BC | screen
15	ROWhite	Pixel = White
Remarks	FC is an acronym for ForeColor.  Pixel is what will be displayed as a result of the operation.  For a detailed description, see the SetROP2 function in the Windows help file.


RasterOp property Delphi example:

Picbuf1.RasterOp:=RO_Black;


RasterOp property VB example
RasterOp property VB example:

Picbuf1.RasterOp = RO_Black


RePas method eg.
Visual Basic

Delphi


RePos Method Delphi eg.
RePos Method Delphi example:

Picbuf1.Repos(50,50,100,100);


RePos method VB eg.
RePos method VB example:

Picbuf1.RePos 50, 50, 100, 100


Rect method Delphi eg.
Rect method Delphi example:

Picbuf1.OLEObject.Rect(1);


Rect method VB eg.
Rect method VB example:

Picbuf1.Rect


Rect method eg.
Visual Basic

Delphi


ReduceColors method Delphi eg.
ReduceColors method Delphi example:

Picbuf1.ReduceColors(24,1,1,1);


ReduceColors method VB eg.
ReduceColors method VB example:

Picbuf1.ReduceColors 24, 1, 1, 1


ReduceColors method eg.
Visual Basic

Delphi


ReduceColorsCallback method Delphi eg.
ReduceColorsCallback method Delphi example:

Picbuf1.ReduceColorsCallback(24,1,1,1,Form1);


ReduceColorsCallback method VB eg.
ReduceColorsCallback method VB example:

Picbuf1.ReduceColors 24, 1, 1, 1


ReduceColorsCallback method eg.
Visual Basic

Delphi


RegionRb Delphi example :

Picbuf1.RegionRb (RTSelect);


RegionRb method

Overview	 This method dynamically creates a rubber band box by capturing mouse events input from the user.

Return Type	Short

Syntax	PicBuf1.RegionRb nType,[reserved1 (optional), reserved2(optional)]

Part	Description
nType	Type of Region to build
Setting	Constant	Description
0	RTSelect	Update the following properties: SelectLeft, SelectTop, SelectWidth, SelectHeight
1	RTPrint	update the following properties:  PrintLeft, PrintTop, PrintWidth, PrintHeight

Remarks	Typically this would be used in the MouseDown event to dynamically set properties.  The drawing of the box is defined by the DrawWidth, ForeColor and RasterOp properties.


RegionRb method VB eg.
RegionRb method VB example:

Picbuf1.RegionRb RTSelect


RegionRb method eg.
Visual Basic

Delphi


RemapPaL Method VB eg.
RemapPal Method VB example:

‘There must be two picbuf controls with images loaded for this code to function properly.

Picbuf1.RemapPal Picbuf2


RemapPal method Delphi eg.
RemapPal method Delphi example:

//There must be two picbuf controls with images loaded for this code to function properly.

Picbuf1.RemapPal(Picbuf2.OLEObject);


RemapPal method eg.
Visual Basic

Delphi


ResizeMode property Delphi eg.
ResizeMode property Delphi example:

Picbuf1.ResizeMode:=0;


ResizeMode property VB eg.
ResizeMode property VB example:

Picbuf1.ResizeMode = RMDeletedFixed


ResizeMode property eg.
Visual Basic

Delphi


Rotate method Delphi eg.
Rotate method Delphi example:

Picbuf1.Rotate(45,0);


Rotate method VB eg.
Rotate method VB example:

Picbuf1.Rotate 45, 0


Rotate method eg.
Visual Basic

Delphi


RoundRect method Delphi eg.
RoundRect method Delphi example:

Picbuf1.OLEObject.RoundRect(1,1,1);


RoundRect method VB eg.
RoundRect method VB example:

Picbuf1.RoundRect 1,1


RoundRect method eg.
Visual Basic

Delphi


RuntimeWriteOnly
Access:

This chart shows whether a property's value may be accessed

(Read), and whether a property's value may be set (Write).

The chart also shows whether the property value is available for

reading or writing during a container's design mode and/or run-mode.


Scale
SetScale method

Overview	Sets properties ScaleImage and ScaleScreen at the same time.

Return Type	Void

Syntax	picbuf.SetScale ScaleImage, ScaleScreen

Part	Description
ScaleImage, ScaleScreen	Determines the scaling of theimage pixels to screen pixels

Remarks	Loading images with AutoScale true sets the properties ScaleImage  and ScaleScreen to correct values.  Settings for ScaleImage and ScaleScreen depend upon settings for each other.  The user can be prevented from setting these individually at times.  This method allows the user to set these properties at the same time.


Scale method Delphi eg.
Scale method Delphi example:

Picbuf1.SetScale(2,2);


Scale method VB eg.
Scale method VB example:

Picbuf1.SetScale 2, 2


Scale method eg.
Visual Basic

Delphi


ScaleImage, ScaleScreen properties Delphi eg.
ScaleImage, ScaleScreen properties Delphi examples:

Picbuf1.ScaleImage:=5;

Picbuf1.ScaleScreen:=5;


ScaleImage, ScaleScreen properties VB eg.
ScaleImage, ScaleScreen properties VB examples:

Picbuf1.ScaleImage = 5

Picbuf1.ScaleScreen = 5


ScaleImage, ScaleScreen property eg.
Visual Basic

Delphi


ScreenToImage method Delphi eg.
ScreenToImageX method Delphi example:

//There must be an integer named intSToIX declared before using this line of code.

intSToIX:=Picbuf1.ScreenToImageX(25);


ScreenToImage method VB eg.
ScreenToImageX method VB example:

Dim intSToIX As Integer

intSToI=Picbuf1.ScreenToImageX 25


ScreenToImage method VB example:
ScreenToImageY method VB example:

Dim intStoIY As Integer

intStoIY=Picbuf1.ScreenToImageY 25


ScreenToImageX method eg.
Visual Basic

Delphi


ScreenToImageY method eg.
Visual Basic

Delphi


ScreenToImageY method example:
ScreenToImageY method Delphi example:

//There must be an integer named intSToIY declared before using this line of code.

intSToIY:=Picbuf1.ScreenToImageY(25);


ScrollBars property Delphi eg.
ScrollBars property Delphi example:

Picbuf1.ScrollBars:=3;


ScrollBars property VB eg.
ScrollBars property VB example:

Picbuf1.ScrollBars = SBBoth


ScrollBars property eg.
Visual Basic

Delphi


ScrollBarsLargeChange property Delphi eg.
ScrollBarsLargeChange property Delphi example:

Picbuf1.ScrollBarsLargeChange:=1;


ScrollBarsLargeChange property VB eg.
ScrollBarsLargeChange property VB example:

Picbuf1.ScrollBarsLargeChange=1


ScrollBarsLargeChange property eg.
Visual Basic

Delphi


ScrollBarsSmallChange property Delphi eg.
ScrollBarsSmallChange property Delphi example:

Picbuf1.ScrollBarsSmallChange:=1;


ScrollBarsSmallChange property VB eg.
ScrollBarsSmallChange property VB example:

Picbuf1.ScrollBarsSmallChange:=1


ScrollBarsSmallChange property eg/
Visual Basic

Delphi


ScrollbarsLargeChangeSee Also
See Also

ScrollBarsSmallChange

ScrollBars


ScrollbarsSmallChangeSee Also
See Also

ScrollBarsLargeChange

ScrollBars


See Also

GetColor method


SelectTop etc properties Delphi eg.
SelectTop, etc., properties Delphi examples:

Picbuf1.SelectTop:=5;


SelectTop etc, properties VB eg.
SelectTop etc, properties VB examples:

Picbuf1.SelectTop = 5


SelectTop etc, properties eg.
Visual Basic

Delphi


SetPalColor method Delphi eg.
SetPalColor method Delphi example:

Picbuf1.SetPalColor(255,RGB(200,250,200));


SetPalColor method eg.
Visual Basic

Delphi


SetPalColors method VB eg.
SetPalColors method VB example:

Picbuf1.SetPalColor 255, RGB(200,250,200)


SetScreenPal method Delphi eg.
SetScreenPal method Delphi example:

Picbuf1.SetScreenPal;


SetScreenPal method VB eg.
SetScreenPal method VB example:

Picbuf1.SetScreenPal


SetScreenPal method eg.
Visual Basic

Delphi


Sharpen method Delphi eg.
Sharpen method Delphi example:

Picbuf1.Sharpen(5);


Sharpen method VB eg.
Sharpen method VB example:

Picbuf1.Sharpen 5


Sharpen method eg.
Visual Basic

Delphi


Soften method Delphi eg.
Soften method Delphi example:

Picbuf1.Soften(5);


Soften method VB eg.
Soften method VB example:

Picbuf1.Soften 5


Soften method eg.
Visual Basic

Delphi


Store method Delphi eg.
Store method Delphi example:

Picbuf1.Store


Store method Vb eg.
Store method Vb example:

Picbuf1.Store


Store method eg.
Visual Basic

Delphi


StorePal  method eg.
Visual Basic

Delphi


StorePal method Delphi eg.
StorePal method Delphi example:

Picbuf1.StorePal;


StorePal method VB eg.
StorePal method VB example:

Picbuf1.StorePal


TExtAlignment property eg.
Visual Basic

Delphi


Technical Support
ImageKnife Help

Technical Support

We hope you’ll find all the information you need to effectively use ImageKnife in the online documentation. If you can’t find the answer to your question, take a look at our Web Page or drop us an e-mail.  In order to verify your support privileges, we'll ask you to provide your serial number form your installation disk #1.  Product suggestions and problem reports are also welcome.

Our first and fastest line of support to you is through our list of Frequently Asked Questions (FAQ).  This list is always available on our Web Page, CompuServe and BBS.  This list contains not only the questions we hear but also tips and tricks from other users.  If you have a tip or trick that you would like to share, please submit it with the form included in the FAQ.

Telephone technical support for ImageKnife is complimentary for thirty days from the date of your initial call so that you get technical support when you need it most.  After this period, telephone support will be charged at US $20 per issue.

To maximize your value, look into our Annual Support Agreement (ASA). Among the benefits of an ASA are a free hard copy manual, a special area on the internet and BBS with all the latest tips and information, discounts on additional purchases, and free priority phone for an entire year. If you own several of our products it is even possible to purchase an Annual Support Agreement that covers all Media Architects products.  Please call the sales department and ask for details.

Priority Technical Support Telephone: 503-620-5372 (8:00am to 5:00pm Pacific Time)

The way to receive the quickest response to electronic requests is to submit issues using our Electronic Service Request Form.  You must be registered to receive support.

Non-priority technical support is always available via fax, Internet, CompuServe

or BBS. The latest patches, help files, examples, and FAQ can always be found here.

Fax:	503-620-5451

Internet:	support@mediarch.com

BBS:	503-598-1165

(14.4kbps US Robotics V .32bis modem on line.  Supports Xmodem, true Ymodem, and Zmodem file transfers.)

CompuServe:	GO MEDARCH or 74774,707

(This is an extended service of CompuServe, so connect time charges may apply. Media Architects does not receive any money from this section; we provide it as a service to our customers.)

Have you serial number handy when you call the first time. ASA holders will be able to download the latest version of ImageKnife at no charge.


Text property Delphi eg.
Text property Delphi example:

PicBuf1.Text: = 'Hello World!';


Text property VB eg.
Text property VB example:

PicBuf1.Text = "Hello World!"


Text property eg.
Visual Basic

Delphi


TextAlignment property Delphi eg.
TextAlignment property Delphi example:

Picbuf1.TextAlignment:=0;


TextAlignment property VB eg.
TextAlignment property VB example:

Picbuf1.TextAlignment = TALeft


TextAutoSize property Delhi eg.
TextAutoSize property Delphi example:

Picbuf1.TextAutoSize:=True;


TextAutoSize property VB eg.
TextAutoSize property VB example:

Picbuf1.TextAutoSize = True


TextAutoSize property eg.
Visual Basic

Delphi


TextDraw method Delphi eg.
TextDraw method Delphi example:

Picbuf1.OLEObject.TextDraw(1);


TextDraw method VB eg.
TextDraw method VB example:

Picbuf1.TextDraw


TextDraw method eg.
Visual Basic

Delphi


TextEstLeading Delphi eg.
TextExtLeading property Delphi example:

Picbuf1.TextExtLeading:=True;


TextExtLeading property eg.
TextExtLeading property VB example:

Picbuf1.TextExtLeading = True


TextExtLeading property eg.
Visual Basic

Delphi


TextMultiline property  Delphi eg.
TextMultiline property  Delphi example:

Picbuf1.TextMultiLine:=True;


TextMultiline property VB eg.
TextMultiline property example:

Picbuf1.TextMultiLine = True


TextMultiline property eg.
Visual Basic

Delphi


Verify method Delphi eg.
Verify method Delphi example:

//There must be a handle to a DIB named hDIB present for this code to function correctly.

Picbuf1.Verify(hDIB);


Verify method VBeg.
Verify method VB example:

‘There must be a handle to a DIB named hDIB present for this code to function correctly.

Picbuf1.Verify hDIB


Verify method eg.
Visual Basic

Delphi


Version property Delphi eg.
Version property Delphi example:

//An integer named intVer must be declare before this code will function properly.

intVer:=Picbuf1.Version;


Version property VB eg.
Version property VB example:

Dim intVer As Integer

intVer = Picbuf1.Version


Version property eg.
Visual Basic

Delphi


Visual Basic


Write Option Delphi eg.
WriteOption property Delphi example:

Picbuf1.WriteOption:=0;


WriteCompression property

Overview	An integer that specifies the compression type to use for AppendTiff, or Store.

DataType	Short

Syntax	PicBuf.WriteCompression  = option

Remarks	For AppendTiff, 0=uncompressed, 1=LZW compression.

For Store, use 0 for none (all formats except GIF, PCX, and JPEG ) or default compression (GIF and  PCX only). Use 1 for LZW compression (TIF and GIF only), or a number in the set [5..100] (JPEG only, see below).

For JPEG file compression, use a number in the set [5..100] for quality.  Higher numbers indicate higher quality, but lower compression ratios. Note that there is no way for ImageKnife to tell what compression was used to store an image, so reading this property will only tell you what it is currently set to, not what compression was used to store the image currently contained in the PicBuf. It is suggested that, if you are using JPEG compression in a database, you add a separate field to track what JPEG compression was used.


WriteOption property VB eg.
WriteOption property VB example:

Picbuf1.WriteOption = WONone


WriteOption property eg.
Visual Basic

Delphi


X,Y Origin properties VB eg.
X,Y Origin properties VB examples:

Dim intXOr As Integer

intXOr=Picbuf1.XOrigin=0

Dim intYOr As Integer

intYOr=Picbuf1.YOrigin


X,Y Origin properties eg.
Visual Basic

Delphi


X,Y Origin property Delphi eg.
X,Y Origin property Delphi examples:

//An integer named intXOr must be declared before this code will function properly.

intXOr:=Picbuf1.XOrigin;

//An integer named intYRes must be declared before this code will function properly.

intYRes:=Picbuf1.YResolution;


X,YOrigin Eg.
Visual Basic

Delphi


XOrigin,YOrigin Properties eg.


XResolution property Delphi eg.
X, Y Resolution property Delphi examples:

//An integer named intXRes must be declared before this code will function properly.

intXRes:=Picbuf1.XResolution;

//An integer named intYRes must be declared before this code will function properly.

intYRes:=Picbuf1.YResolution;


XResolution property VB eg.
X, Y Resolution property VB examples:

Dim intXRes As Integer

intXRes=Picbuf1.XResolution

Dim intYRes As Integer

intYRes=Picbuf1.YResolution


XResolution property eg.
Visual Basic

Delphi


contents, appendix
ImageKnife Help

Appendix Contents

ImageKnife and JPEG

ImageKnife and PNG

ImageKnife And FIFs (Fractal Image Format)

A Palette Primer

Visual Basic 4.0  Object Browser

ImageKnife Error Codes


contents, installation
ImageKnife Help

Installation Contents

Before Installation

Installation/Uninstallation

Registration


contents, introduction
ImageKnife Help

Introduction Contents

What is ImageKnife?

How Does OCX differ from VBX?

About Media Architects


contents, programming
ImageKnife Help

Programming Contents

The PicBuf Control

Using ImageKnife in Borland Delphi 2.0

Files You Need to Distribute

Compatibility Issues


display, Larger control image or selection area to smaller selection area
AssignMode 0 - Total Replacement

Larger image or selection area to smaller selection area

PicBufDest.AssignMode = 0

' this puts the upper left corner of the selected

' area in the upper left corner of the destination

PicBufDest.SelectLeft = 0

PicBufDest.SelectTop = 0

PicBufDest.SelectWidth = 50 ' note that the source is 105 x 97 pixels

PicBufDest.SelectHeight = 50

' full source image to destination selection

PicBufDest.Assign True,PicBufSource,False

 + [image] =

Source	Destination	Result

The source image’s center and the destination selection area's center are the common points of origin. In this case, the source image is larger than the destination selection area, so the selection area is made larger to allow the source image to fit. Note that the actual source and destination images are not resized.

Note	Before you use Assign to make an assignment, make sure that the destination PicBuf already contains an image.  To do this, use Init, Load, or any other method that fills a PicBuf image.


display, Larger image or selection area  to smaller image
AssignMode 2 - Intersection Composite

Larger image or selection area to smaller image

PicBufDest.AssignMode = 2

' full source image to full destination image

PicBufDest.Assign False,PicBufSource,False

 + [image] =

Source	Destination	Result

The larger source is composited onto the smaller destination. Note, however, that where the two images do not intersect, the source image is cropped. In this case, the entire destination image is overlaid by the source, but if, for example, the source was taller than the destination, only the portion of the source that intersected the destination would be composited. Regardless, no resizing of the images occurs, only composition.

This AssignMode setting is most useful when the XOrigin and YOrigin properties are non-zero, when it can be used to composite and crop images simultaneously, like this.

See the section later in this chapter about alignment capabilities of ImageKnife.

Note	Before you use Assign to make an assignment, make sure that the destination PicBuf already contains an image.  To do this, use Init, Load, or any other method that fills a PicBuf image.


display, Larger image or selection area to smaller image
AssignMode 1 - Union Composite

 Larger image or selection area to smaller image

PicBufDest.AssignMode = 1

' full source image to full destination image

PicBufDest.Assign False,PicBufSource,False

 + [image] =

Source	Destination	Result

The larger source image is composited onto the smaller destination area. In this case, the destination is made larger to accommodate the source image and the destination image is completely overlaid.

This AssignMode setting is most useful when the XOrigin and YOrigin properties are non-zero, when it can be used to create a montage like this.

See the section later in this chapter about alignment capabilities of ImageKnife.

Note	Before you use Assign to make an assignment, make sure that the destination PicBuf already contains an image.  To do this, use Init, Load, or any other method that fills a PicBuf image.


display, Larger image or selection area to smaller image (2)
AssignMode 3, ResizeMode 0 or 2 - Resize Composite

Larger image or selection area to smaller image

PicBufDest.AssignMode = 3

PicBufDest.ResizeMode = 0 ' or 2

PicBufDest.Assign False,PicBufSource,False

 + [image] =

Source	Destination	Result

The larger source image is composited onto the smaller destination, but unlike all the other AssignMode settings, the source is actually resized to fit within a fixed size destination.

Note	Before you use Assign to make an assignment, make sure that the destination PicBuf already contains an image.  To do this, use Init, Load, or any other method that fills a PicBuf image.


display, Larger image or selection area to smaller image (3)
AssignMode 3, ResizeMode 1 or 3 -- Resize Composite

Larger image or selection area to smaller image

PicBufDest.AssignMode = 3

PicBufDest.ResizeMode = 1 ' or 3

PicBufDest.Assign False,PicBufSource,False

 + [image] =

Source	Destination	Result

The larger source is composited onto the smaller destination, but unlike the other AssignMode 3 examples, this example uses a ResizeMode that allows the aspect ratio to change, causing the source image to be the same size as the destination in both dimensions, rather than just one dimension. This creates a "stretch" effect.

Result (enlarged for comparison to Source)

Note	Before you use Assign to make an assignment, make sure that the destination PicBuf already contains an image.  To do this, use Init, Load, or any other method that fills a PicBuf image.


display, Larger image or selection area to smaller image (4)
AssignMode 3, ResizeMode 0 or 2 -- Resize Composite

Larger image or selection area to smaller image

PicBufDest.AssignMode = 3

PicBufDest.ResizeMode = 0 ' or 2

PicBufDest.Assign False,PicBufSource,False

 + [image] =

Source	Destination	Result

The larger source image is composited onto the smaller destination, but unlike all the other AssignMode settings, the source is actually resized to fit within a fixed size destination.

Note	Before you use Assign to make an assignment, make sure that the destination PicBuf already contains an image.  To do this, use Init, Load, or any other method that fills a PicBuf image.


display, Larger image or selection area to smaller image (5
AssignMode 3, ResizeMode 1 or 3 -- Resize Composite

Larger image or selection area to smaller image

PicBufDest.AssignMode = 3

PicBufDest.ResizeMode = 1 ' or 3

PicBufDest.Assign False,PicBufSource,False

 + [image] =

Source	Destination	Result

The larger source is composited onto the smaller destination, but unlike the other AssignMode 3 examples, this example uses a ResizeMode that allows the aspect ratio to change, causing the source image to be the same size as the destination in both dimensions, rather than just one dimension. This creates a "stretch" effect.

Result (enlarged for comparison to Source)

Note	Before you use Assign to make an assignment, make sure that the destination PicBuf already contains an image.  To do this, use Init, Load, or any other method that fills a PicBuf image.


display, Larger image or selection area to smaller selection area
AssignMode 1 - Union Composite

Larger image or selection area to smaller selection area

PicBufDest.AssignMode = 1

PicBufDest.SelectLeft = 30

PicBufDest.SelectTop = 30

' the selected area is smaller than the source image

PicBufDest.SelectWidth = 50

PicBufDest.SelectHeight = 45

' full source image to destination selection

PicBufDest.Assign True,PicBufSource,False

 + [image] =

Source	Destination	Result

The larger source image was composited onto the smaller destination selection area. The destination was expanded in order to accommodate that source, but no resizing occurred.

Note	Before you use Assign to make an assignment, make sure that the destination PicBuf already contains an image.  To do this, use Init, Load, or any other method that fills a PicBuf image.


display, Smaller control image or selection area to larger control image
AssignMode 0 - Total Replacement

Smaller control image or selection area to larger control image

PicBufDest.AssignMode = 0

PicBufDest.Assign False,PicBufSource,False

 + [image] =

Source	Destination	Result

The destination control's image was completely replaced with the source control's image. The source image was not resized.


display, Smaller control image or selection area to larger selection area
AssignMode 0 - Total Replacement

Smaller picture or selection area to larger selection area

PicBufDest.AssignMode = 0

' locates the upper left corner of the selected area

PicBufDest.SelectLeft = 20

PicBufDest.SelectTop = 20

PicBufDest.SelectWidth = 120 ' note that the source is 105 x 97 pixels

PicBufDest.SelectHeight = 120

' full source image to destination selection

PicBufDest.Assign True,PicBufSource,False

 + [image] =

Source	Destination	Result

The source image’s center and the destination selection area's center are the common points of origin. In this case, the source image is smaller than the destination selection area, so the selection area is made smaller to allow the source image to fit. Note that the actual source and destination images are not resized.

Note	Before you use Assign to make an assignment to a selection area, make sure that the destination PicBuf already contains an image.  To do this, use Init, Load, or any other method that fills a PicBuf image.


display, Smaller image or selection area  to larger image
AssignMode 2 - Intersection Composite

Smaller image or selection area to larger image

PicBufDest.AssignMode = 2

' full source image to full destination image

PicBufDest.Assign False,PicBufSource,False

 + [image] =

Source	Destination	Result

The smaller source is simply composited onto the larger destination.

Note	Before you use Assign to make an assignment to a selection area, make sure that the destination PicBuf already contains an image.  To do this, use Init, Load, or any other method that fills a PicBuf image.


display, Smaller image or selection area to larger image
AssignMode 3, ResizeMode 0 or 2 -- Resize Composite

Smaller image or selection area to larger image

PicBufDest.AssignMode = 3

PicBufDest.ResizeMode = 0 ' or 2

PicBufDest.Assign False,PicBufSource,False

 + [image] =

Source	Destination	Result

The smaller source image is composited onto the larger destination, but unlike all the other AssignMode settings, the source is actually resized to fit within a fixed size destination.

Note	Before you use Assign to make an assignment, make sure that the destination PicBuf already contains an image.  To do this, use Init, Load, or any other method that fills a PicBuf image.

Options on how to perform this scaling are offered in the ResizeMode property.

ResizeMode	Resize Method

0	Use simple, fast pixel deletion/replication; source aspect ratio is maintained.

1	Use simple, fast pixel deletion/replication; source aspect ratio is modified to fit that of destination.

2	Use high quality Resampling; source aspect ratio is maintained.

3	Use high quality Resampling; source aspect ratio is modified to fit that of destination.

Note	ResizeMode is only considered during assignment methods where AssignMode is set to 3. The choice of method in an assignment is based on (1) whether speed or quality is the predominant concern, and (2) whether filling the destination space completely or maintaining integrity of the source image is desired.


display, Smaller image or selection area to larger image
AssignMode 1 - Union Composite

Smaller image or selection area to larger image

PicBufDest.AssignMode = 1

' full source image to full destination image

PicBufDest.Assign False,PicBufSource,False

 + [image] =

Source	Destination	Result

The smaller source image is simply composited onto the larger destination.

Note	Before you use Assign to make an assignment, make sure that the destination PicBuf already contains an image.  To do this, use Init, Load, or any other method that fills a PicBuf image.


display, Smaller image or selection area to larger image (2)
AssignMode 3, ResizeMode 0 or 2 -- Resize Composite

Smaller image or selection area to larger image

PicBufDest.AssignMode = 3

PicBufDest.ResizeMode = 0 ' or 2

PicBufDest.Assign False,PicBufSource,False

 + [image] =

Source	Destination	Result

The smaller source image is composited onto the larger destination, but unlike all the other AssignMode settings, the source is actually resized to fit within a fixed size destination.

Note	Before you use Assign to make an assignment, make sure that the destination PicBuf already contains an image.  To do this, use Init, Load, or any other method that fills a PicBuf image.

Options on how to perform this scaling are offered in the ResizeMode property.

ResizeMode	Resize Method

0	Use simple, fast pixel deletion/replication; source aspect ratio is maintained.

1	Use simple, fast pixel deletion/replication; source aspect ratio is modified to fit that of destination.

2	Use high quality Resampling; source aspect ratio is maintained.

3	Use high quality Resampling; source aspect ratio is modified to fit that of destination.

Note	ResizeMode is only considered during assignment methods where AssignMode is set to 3. The choice of method in an assignment is based on (1) whether speed or quality is the predominant concern, and (2) whether filling the destination space completely or maintaining integrity of the source image is desired.


display, Smaller image or selection area to larger selection area
AssignMode 1 - Union Composite

Smaller image or selection area to larger selection area

PicBufDest.AssignMode = 1

PicBufDest.SelectLeft = 10

PicBufDest.SelectTop = 10

' the selected area is larger than the source image

PicBufDest.SelectWidth = 150

PicBufDest.SelectHeight = 125

' full source image to destination selection

PicBufDest.Assign True,PicBufSource,False

 + [image] =

Source	Destination	Result

The smaller source image was composited onto the larger destination selection area.  Neither image was resized.

Note	Before you use Assign to make an assignment, make sure that the destination PicBuf already contains an image.  To do this, use Init, Load, or any other method that fills a PicBuf image.


event, Pan, see also
See Also

Paint event


event, callback
Callback event

Overview	If enabled, this event occurs at specified intervals during the processor-intensive operations LoadCallback and ReduceColorsCallback.

Syntax	Sub PicBuf_Callback (Lines)

Part	Data Type	Description
Lines	Integer (By Reference)	Current line being operated upon.  If set to 0 during an operation, then the operation is aborted and the affected PicBufs are returned to the condition they were in immediately before the operation began.
Remarks	This event is enabled by the LoadCallback or ReduceColorsCallback methods.


event, callback, see also
See Also

LoadCallback method

ReduceColorsCallback method


event, change
Change event

Overview	Indicates that the image contained in a PicBuf has changed.

Syntax	Sub PicBuf_Change ()

Remarks	Methods that change the contents of the control cause this event to be generated (i.e. Blur).  Operarions which cause the view of the control to cahnge do not generate this event (i.e. Panning or Scaling this image).


event, change, see also
See Also

Paint event


event, paint
Paint event

Overview	Occurs whenever the window of the control has been painted.

Syntax	Sub PicBuf_Paint ()

Remarks	This can occur when a PicBuf is exposed after it has been loaded, moved or enlarged, or after a window that was covering the PicBuf has been moved.  This can also occur when the image has been altered (for example, by the Soften or Sharpen methods).


event, palette
Palette event

Overview	occurs when the palette of a control has been changed

Syntax	Sub PicBuf_Palette ()

Remarks	This event only occurs for controls that contian palettized images (less than 24 bits).  Methods that modify the palette of the control generate this event (i.e. SetPalColor).


event, pan
Pan event

Overview	Occurs when the image in the control is panned.  This event is generated when the image is moved around at a fixed magnification setting (for example, by using the scrollbars).

Syntax	Sub PicBuf_Pan ()

Remarks	This event allows the user to move an object that is over a PicBuf (e.g. another control) to a new location before the PicBuf is painted.  This occurs immediately before the PicBuf is painted.


hDC property Delphi eg.
hDC property Delphi example:

{ Copies the source image from an already defined hDC to the device context of the PicBuf }

var

  RasterOp :  Longint;

  PichDC : Shortint;

begin

  RasterOp := 10;

  PichDC := PicBuf1.hDC;

  BitBlt(PichDC, 0, 0, PicBuf1.Width, PicBuf1.Height, hDC, 0, 0);

  ReleaseDC(PichDC);

end;


hDC property VB eg.
hDC property VB example:

' Copies the source image from an already defined hDC to the device context of the PicBuf

Dim RasterOp as Long

Dim PichDC as Short

RasterOp = SRCCOPY

PichDC = PicBuf1.hDC

BitBlt PichDC, 0, 0, PicBuf1.Width/TwipsPerPixelX, PicBuf1.Height/TwipsPerPixelY, hDC, 0, 0

ReleaseDC PichDC


hDC property eg.
Visual Basic

Delphi


hDib property  Delphi eg.
hDib property  Delphi example:

//There must be a handle to a DIB named hDIB present for this code to function properly.

Picbuf1.hDIB:=hDIB;


hDib property VB eg.
hDib property VB example:

‘There must be a handle to a DIB named hDIB present for this code to function properly.

Picbuf1.hDIB=hDIB


hDib property eg.]
Visual Basic

Delphi


hPalette property Delphi eg.
hPalette property Delphi example:

//There must be a handle to a Palette named hPal present for this code to function properly.

Picbuf1.hPalette:=hPal;


hPalette property VB eg.
hPalette property VB example:

‘There must be a handle to a Palette named hPal present for this code to function properly.

Picbuf1.hPalette=hPal


hPalette property eg.
Visual Basic

Delphi


list, reference
ImageKnife Help

Reference

Events

Callback

Change

Palette

Paint

Pan

Methods

 Color

AddSystemColors

ColorReplace

CountSystemColors

CreatePalette

DitherPal

GetColor

GetColorCount

GetColorCountArray

GetPalColor

GetPalette

GetPalIndex

GrayScale

IncreaseColors

OptimizePal

OptimizePalFiles

PutColor

ReduceColors

ReduceColorsCallback

RemapPal

SetPalColor

SetScreenPal

 Drawing

Arc

Chord

Pie

Polygon

PolyLine

Rect

RoundRect

TextDraw

TextHigh

TextWide

File I/O

AppendTIFF

CountImages

DumpControl

Load

LoadCallback

LoadPal

Store

StorePal

Image Processing

Blur

BrightCont

ExtractEdges

Gamma

GetScanLine

Init

MapIndex

MatrixFilter

MaskCopy

Mirror

Negate

PutScanLine

Rotate

Sharpen

Soften

Utilities

Assign

BitmapToDib

Clear

CopyClipboard

DibToBitmap

DuplicateDib

DuplicatePalette

ErrorDump

ExportDib

GetHorzSBHeight

GetVertSBWidth

ImportDib

PasteClipboard

RegionRb

RePos

SetScale

ScreenToImageX

ScreenToImageY

Verify

Properties

About

AssignMode

AutoLoad

AutoScale

AutoSize

CallbackLines

ColorDepth

Contents

DrawArrows

DrawStyle

DrawWidth

ErrorNumber

Filename

FillColor

FillStyle

FillTransparent

Font

FontTransparent

hDC

hDib

hPalette

ImageFormat

ImageNumber

InfoImage

InfoIO

InfoText

InfoView

LoadCropLeft

LoadCropTop

LoadCropWidth

LoadCropHeight

LoadOptions

LoadScale

LoadPalette

LoadFastest

LoadHeight

LoadWidth

LZW

MouseIcon

MousePointer

Picture

PrintHeight

PrintLeft

PrintTop

PrintWidth

PrinterhDC

RasterOp

ResizeMode

ScaleImage

ScaleScreen

ScrollBars

ScrollBarsLargeChange

ScrollBarsSmallChange

SelectHeight

SelectLeft

SelectTop

SelectWidth

Text

TextAlignment

TextAutoSize

TextExtLeading

TextMultiline

Version

WriteCompression

WriteOption

XOrigin

XResolution

YOrigin

YResolution


message, Advanced Issues
As JPEG is a complex technology, these issues have been set aside for easy access by advanced users.


message, Assignment
This section contains example code and diagrams portraying the AssignMode and ResizeMode combinations.


message, Common Questions
Commonly asked palette question.


message, Compatibility
This section gives vital details on the subject of ImageKnife compatibility with other products, controls, and environments.


message, ImageKnife and JPEG
This section discusses the workings of the JPEG image format.


message, ImageKnife and PNG
This topic discusses the workings of the PNG image format.


message, Problems with Palettes
Palettes can be a pain.  This section discusses why.


message, basic structure
The fundamentals of ImageKnife.


method, AddSystemColors
AddSystemColors method

Overview	This method adds the Windows system-colors to the palette of a control.

Return Type	Void

Syntax	PicBuf.AddSystemColors

Remarks	The Windows system colors consist of ten entries from 0-9 at the beginning and ten entries at the end from 246-255.  These are fixed entries that always occur in every palette.  Make sure that there are enough empty palette entries to accommodate the system colors.


method, AppendTIFF
AppendTIFF method

Overview	Adds a PicBuf image to the end of an existing multiple-image TIFF file.

Return Type	void

Syntax	PicBuf.AppendTiff

Remarks	Uses the Filename and WriteCompression properties.


method, AppendTIFF, see also
See Also

CountImages method

WriteCompression property

Filename property

Load method

Store method


method, Arc
Arc method

Overview	Draws an arc counterclockwise from start to end lines into a PicBuf image.

Return Type	void

Syntax	PicBuf.Arc xStart, yStart, xEnd, yEnd, [nDestination, this is optional]

Part	Data Type	Description
xStart,yStart	Short	The starting point of the arc (in pixels);  the point does not have to fall on the arc
xEnd, yEnd	Short	The ending point of the arc (in pixels); the point does not have to fall on the arc
nDestination	Short[optional]	Determines where the arc is drawn to the window 0 = to the DIB (default) 1 = to the window

Remarks	The SelectHeight, SelectWidth, SelectLeft, and SelectTop properties define the bounding rectangle of the ellipse.  The DrawStyle, DrawWidth, ForeColor, BackColor, and FillTransparent properties define how the border line will be drawn.  See the following figure.

Note	The color selected to draw into the image should be contained in the image’s palette.  If it is not, then the closest color found in the image’s palette is used.


method, Assign
Assign method

Overview	Assigns the source PicBuf's image into the image of the destination PicBuf.

Return Type	void

Syntax	PicBuf.Assign DestSelection, SrcPicBuf, SrcSelection

Part	Data Type	Description
DstSelection	Short	If false, then the entire image of the destination PicBuf is replaced by the source image, and the destination selection area (specified by the Select properties) is ignored.  If true, then only the select area of the destination PicBuf is replaced, based on the AssignMode and ResizeMode properties of the destination PicBuf.  (If either the SelectWidth or SelectHeight of the destination PicBuf is zero, an error is generated.)
SrcPicbUF	Object	The PicBuf control sending the image.
SrcSelection	Short	If false, then the entire source image is assigned to the destination, and the source selection area (specified by the Select properties) is ignored.   If true, then the source selection area is assigned to the destination.  (If either the SelectWidth or SelectHeight of the source PicBuf is zero, an error is generated.)

Remarks	This method uses the SelectTop, SelectLeft, SelectWidth, SelectHeight, AssignMode, and ResizeMode properties.  The parameters destSelection and srcSelection are Boolean.

Note:	Before you use this method to make an assignment to a selection area or when AssignMode=1, 2, or 3, make sure that the destination PicBuf already contains an image.  To do this, use Init, Load, or any other method that fills a PicBuf image.


method, BitmapToDIB
BitmapToDib method

Overview	This method changes the internal image of a PicBuf, using the input bitmap.

Return Type	void

Syntax	PicBuf.BitmapToDib Hbitmap

Part	Data Type	Description
Hbitmap	Unsigned short	Handle to an in memory butmap

Remarks	The colors are determined by the current video driver in use. The colors default to the Windows system colors.


method, Blur
Blur method

Overview	Blurs the input PicBuf image a fixed amount.

Return Type	void

Syntax	PicBuf.Blur

Remarks	Blurring literally blurs the image. Compare this with softening, which softens the edges of an image (i.e. the opposite of sharpening).  More blurring may be achieved through successive calls to Blur.


method, Blur, see also
See Also

BrightCont method

Sharpen method

Soften method


method, BrightCont
BrightCont method

Overview	Adjusts the brightness and contrast of the input PicBuf image.

Return Type	void

Syntax	PicBuf.BrightCont Brightness, Contrast

Part	Data Type	Description
Brightness	Double	The factor by which to increase or decrease the brightness of the image; use 0.0 to turn the image black, 1.0 to turn the image white, 0.5 to cause no change, and so on
Contrast	Double	The factor by which to increase or decrease the contrast of the image; use 0.0 for no contrast, 1.0 to turn the image to pure black and white, 0.5 to cause no change, and so on

Remarks	If the image has a palette(i.e. ColorDepth property is 8 or less), the palette is adjusted. Thus, to adjust the brightness or contrast of a selected area of a palettized image, you would need to increase the color depth of the image to 24 bits, perform the adjustment, then reduce the color depth back to their previous setting. If no palette exists, the image data is directly affected.

Note	Remember that this method changes the brightness and contrast of an image based on its current brightness and contrast, not its original brightness and contrast. Thus, setting brightness to 0 and then setting brightness to 0.5 will not return the original image.


method, BrightCont, see also
See Also

Gamma  method


method, Chord
Chord method

Overview	Draws a chord segment counterclockwise from start to end lines into a PicBuf image.

Return Type	void

Syntax	PicBuf.Chord xStart, yStart, xEnd, yEnd, [nDestiantion, this is optional]

Part	Data Type	Description
xStart, yStart	Short	The starting point of the line through the chord (in pixels);  the point can be outside the bounds of the chord
xEnd, yEnd	Short	The ending point of the line through the chord (in pixels);  the point can be outside the bounds of the chord
nDestination	Short[optional]	Determines where the arc is drawn to the window 0 = to the DIB (default) 1 = to the window

Remarks	The SelectHeight, SelectWidth, SelectLeft, and SelectTop properties define the bounding rectangle of the ellipse.  The DrawStyle, DrawWidth, ForeColor, BackColor, and FillTransparent properties define the line.  The BackColor, FillStyle, FillColor, and FillTransparent properties define the inside fill. See the following figure.

Note	The color selected to draw into the image should be contained in the image’s palette.  If it is not, then the closest color found in the image’s palette is used.


method, Clear
Clear method

Overview	Clears any image and/or palette contained in the PicBuf.

Return Type	void

Syntax	PicBuf.Clear

Remarks	This method is useful for flushing a control of its image or palette.


method, ColorReplace
ColorReplace method

Overview	Modifies the input PicBuf image such that pixels falling within a range of RGB values are set to a specified color.

Return Type	Void

Syntax	PicBuf.ColorReplace rgb1, rgb2, flag, rgpreplace

Part	Data Type	Description
Rgb1	Long	The first RGB value in the range
Rgb2	Long	The last RGB value in the range
Flag	Short	Determines what constitutes a match, use 0 to replace only pixels within the set [rgb1..rgb2], inclusively, use 1 to replace only pixels not within the set [rgb1..rgb2], exclusively, non-criteria-matching pixels in the image remain unchanged
Rgbreplace	Long	The RGB value to use as a replacement for pixels that satisfy the match criteria.

Remarks	The RGB values referenced above are COLORREF data values in the Windows 32 application programmers interface.


method, ColorReplace, see also
See Also

DitherPal method

RemapPal method

SetPalColor method


method, CopyClipboard
CopyClipboard method

Overview	This method copies an image in the picbuf control to the clipboard.

Return Type	void

Syntax	PicBuf.CopyClipboard [nSelection]

Part	Data Type	Description
nSelection	Short[optional]	Determines how the image is copied. 0 = copy from current selection area 1 = copy the entire image

Remarks	The picbuf must contain a DIB to be writable to the clipboard.


method, CopyClipboard, see also
See Also

PasteClipboard method


method, CountImages
CountImages method

Overview	Returns the number of images in a multi-image file.

Return Type	short

Syntax	PicBuf.CountImages

Remarks	The CountImages method uses the Filename and ImageFormat properties.  TIFF and GIF are the only multi-image formats.  For all other file formats, this method returns 1.


method, CountImages, see also
See Also

AppendTIFF method


method, CountSystemColors
CountSystemColors method

Description	Returns the number of system colors that are contained within the PicBuf image.

Return Type	Long

Syntax	PicBuf.CountSystemColors

Remarks	If this method is zero, then the image does not contain any of the standard windows system colors.


method, CreatePalette
CreatePalette method

Description	Creates a palette with a background color that optionally has system colors added to it.

Return Type	Void

Syntax	PicBuf.CreatePalette count, buffer, systemcolors

Part	Data Type	Description
Count	Integer	The number of entries in the array of palette entries
Buffer	Long Array	The palette entries
Systemcolors	Integer	true if the user wants system colors, false otherwise

Remarks	If system colors are added, then count must be greater than or equal to 236.


method, DIBToBitmap
DibToBitmap method

Overview	Returns a handle to a device-dependent bitmap of the PicBuf's image.

Return Type	unsigned short; handle to a device-dependent bitmap

Syntax	PicBuf.DibToBitmap

Remarks	The client is responsible for memory associated with the handle that is returned.


method, DitherPal
DitherPal method

Overview	Replaces the image of the destination PicBuf with an image that has been dithered to the palette of the source PicBuf.

Return Type	Void

Syntax	PicBuf.DitherPal srcPicBuf

Part	Data Type	Description
SrcPicBuf	Control	Set which control's palette to use

Remarks	The resulting image (in the destination PicBuf) is converted to the minimum bit depth needed to accommodate the number of palette entries in the source PicBuf.  This applies to 24-bit images as well. This method may have somewhat unpredictable results when the source PicBuf's palette contains only two colors.


method, DitherPal, see also
See Also

OptimizePal method

RemapPal method

SetScreenPal method

hPalette property


method, DumpControl
DumpControl method

Overview	This method dumps the contents of the control to a file on the disk.

Return Type	void

Syntax	PicBuf.DumpControl DumpOptions

Part	Data Type	Description
DumpOptions	Short	Determines what to paint into the file
Setting	Constant	Description
0	DOIamgePalette	Dumps the image and the palette
1	DOIamge	Dumps just the image
2	DOPalette	Dumps just the palette

Remarks	This method is useful for debugging purposes.  This method uses the FileName property to determine the location.


method, DuplicateDIB
DuplicateDib method

Overview	Returns a copy of the internal PicBuf image (or of the selected area of the image) as a handle to a DIB.

Return Type	unsigned short; copy of the internal PicBuf image

Syntax	PicBuf.DuplicateDib Selection

Part	Data Type	Description
Part	Boolean	If selection=false, then the entire source image is duplicated. If selection=true, then only the select area of the PicBuf image is duplicated. If either the SelectWidth or SelectHeight of the PicBuf is zero, an error is generated.

Remarks	The client is responsible for all memory associated with the returned handle.


method, DuplicateDIB, see also
See Also

DuplicatePalette method

SelectHeight property

SelectLeft property

SelectTop property

SelectWidth property


method, DuplicatePalette
DuplicatePalette method

Overview	Returns a copy of a control’s palette as a handle to a palette (hPalette).

Return Type	Unsigned Short

Syntax	PicBuf.DuplicatePalette

Remarks	The client is responsible for all memory associated with the returned handle.


method, DuplicatePalette, see also
See Also

DuplicateDib method


method, ErrorDump
ErrorDump method

Overview	Generates a file containing all error messages.

Return Type	void

Syntax	PicBuf.ErrorDump Filename

Part	Data Type	Description
Filename	String	Fully qualified File in which to write dumped error strings (i.e. c:\temp\.

Remarks	This would be useful for example to print a hard copy version of trappable error messages.


method, ExportDIB
ExportDib method

Overview	The internal DIB contained within the control is returned.

Return Type	Unsigned Short

Syntax	PicBuf.ExportDib Transfer

Part	Data Type	Description
Transfer	Boolean	true: giving the ownership of the DIB to the client. false: retaining ownership of the DIB.

Remarks	This method gives the client access to the internal DIB of the control.  Ownership of the DIB is controlled by the Transfer property.  If transfer is true, the DIB contained with the control will NOT be deleted by actions (Clear method, unloading the control, ...) that would normally cause the control to delete its memory.


method, ExtractEdges
ExtractEdges method

Overview	Extracts the edges of the input PicBuf image.

Return Type	void

Syntax	PicBuf.ExtractEdges Magnitude

Part	Data Type	Description
Magnitude	Integer	Specifies the amount of image processing to apply to the input PicBuf image;  must be in the range (1..10).

Remarks	Enables the image to show distinct edges.  This is a useful operation in image-processing applications where edge detection is critical.


method, Gamma
Gamma method

Overview	Adjusts the gamma of the input PicBuf image.

Return Type	void

Syntax	PicBuf.Gamma Magnitude

Part	Data Type	Description
Magnitude	Double	Specifies the gamma correction;  must be in the set of reals (1..10).

Remarks	A gamma that is too large results in intensities brighter than usual, while a gamma that is too small will map the image less intense than normal.  Gamma only affects the intensities of the mid-range colors in the image.  Black and white intensities always map correctly.


method, GetColor
GetColor method

Overview	Returns the RGB color value at the specified coordinates of an image.

Return Type	long; color value at the specified coordinates of an image

Syntax	PicBuf.GetColor pixelX, pixelY

Part	Data Type	Description
PixelX	Short	the x-coordinate of the pixel to obtain the color value from
PixelY	Short	the y-coordinate of the pixel to obtain the color value from
Remarks	Returned color value is a windows COLORREF value.  See the Windows 32 bit applications programmer interface for details on how to get the red, green and blue values.


method, GetColor, see also
See Also

GetPalColor method

GetScanLine method

PutColor Method


method, GetColorCount
GetColorCount method

Overview	Returns the total number of colors used in the source PicBuf's image.

Return Type	long; total number of colors used in the source PicBuf's image

Syntax	PicBuf.GetColorCount

Remarks	For a palettized image, the number returned will be the number of unique palette indices contained in the bitmap. Thus, an 8-bit image might contain 100 unique RGB values in its palette, but might have the same RGB value defined in more than one palette entry. The GetColorCount method will return the number of unique palette entries referenced in the bitmap. So, if there happen to be three different palette entries that contain the same RGB value, and there is a pixel in the image that refers to each one of those palette entries, that will be counted as three different "colors," even though they are all the same RGB value.


method, GetColorCount, see also
See Also

ColorDepth property

IncreaseColors method

ReduceColors method


method, GetColorCountArray
GetColorCountArray method

Description	Counts the number of times a color is used in the image of the PicBuf.

Return Type	Void

Syntax	PicBuf.GetColorCountArray buffer

Part	Data Type	Description
Buffer	Long array	the buffer must be as long as the number of colors in the PicBuf image’s palette

Remarks	Does not work on 24-bit images.  Returned array values are the count of the number of times the palette index occurs in the image.


method, GetHorzSBHeight
GetHorzSBHeight method

Overview	Returns the height of a horizontal scrollbar in pixels.

Return Type	short; height of a horizontal scrollbar in pixels

Syntax	PicBuf.GetHorzSBHeight

Remarks	This is a constant value for all scrollbars.


method, GetHorzSBHeight, see also
See Also

GetVertSBWidth method


method, GetPalColor
GetPalColor method

Overview	Returns the RGB color value at a specific location within the palette of the PicBuf's image..

Return Type	long; RGB color value at a specific location

Syntax	PicBuf.GetPalColor Position

Part	Data Type	Description
Position	Integer	Specifies the position in the palette to obtain the color value from;  must be in the range 0-255

Remarks	Does not work on 24-bit images.  Returned color value is a windows COLORREF value.  See the Windows 32 bit applications programmer interface for details on how to get the red, green and blue values.


method, GetPalColor, see also
See Also

SetPalColor method


method, GetPalIndex
GetPalIndex method

Overview	Returns the palette index at a given x,y location in the PicBuf's image.

Return Type	short

Syntax	PicBuf.GetPalIndex  X, Y

Part	Data Type	Description
X,Y	Short	the X,Y location (in pixels) within the image boundaries

Remarks	This method returns the index into the palette, not the RGB value that is being displayed.  A run-time error will occur if this method is used on a high color or true color image.


method, GetPalIndex, see also
See Also

GetColor method

GetPalColor method


method, GetPalette
GetPalette method

Overview	Obtains the palette information from the PicBuf's image and places it into an array.

Return Type	void

Syntax	PicBuf.GetPalette Palettearray

Part	Data Type	Description
Palettearray	Long array	The array to put the PicBuf image’s current palette into; each element of the array will contain one palette entry in RGB format.  The array must be as large as the number of the palette entries in the control's palette.

Remarks	Does not work on 24-bit images.  The data contained within the array is represented by the COLORREF data structure for each entry.  This is a 32 bit value as a color value.

Note	If the array is not large enough to hold the palette (e.g. 256 elements for an 8-bit image), a run-time error will occur.


method, GetPalette, see also
See Also

LoadPal method


method, GetScanLine
GetScanLine method

Overview	This method obtains a single scan line from a PicBuf's image and places it into an array.

Return Type	void

Syntax	PicBuf.GetScanLine Linenum, Scanline

Part	Data Type	Description
Linenum	Short	Indicates which row of the image to obtain;  must be in the set [0..PicBuf.YResolution - 1]
Scanline	Long array	Contains the scan line’s pixel data; the number of elements needed for the array is equal to PicBuf.XResolution. Each element will contain the RGB color of one pixel in the scan line, unless PicBuf’s color depth <= 8, in which case it will contain the pixel’s palette index.

Remarks	Use this method to capture a line of pixel data from the image within a control.

Note	You must Dim or ReDim the array to be large enough to hold the result, otherwise a Windows GPF may occur.


method, GetScanLine, see also
See Also

GetColor method

PutScanLine method


method, GetVertSBWidth
GetVertSBWidth method

Overview	Returns the width of a vertical scrollbar in pixels.

Return Type	short; width of a vertical scrollbar in pixels

Syntax	PicBuf.GetVertSBWidth

Remarks	All vertical scrollbars in every control have the same width.


method, GetVertSBWidth, see also
See Also

GetHorzSBHeight method


method, GrayScale
GrayScale method

Overview	Converts the input PicBuf image to a grayscale image.

Return Type	void

Syntax	PicBuf.GrayScale

Remarks	If the PicBuf image is 24 bits deep, then this method converts the bit depth to 8 bits deep.  In all other cases, the bit depth of the PicBuf image is unchanged.


method, GrayScale, see also
See Also

IncreaseColors method

ReduceColors method


method, ImportDIB
ImportDIB method

Overview	transfers a DIB memory handle to the control.

Return Type	void

Syntax	PicBuf.ImportDib Handle, Transfer

Part	Data Type	Description
Handle	Unsigned short	Handle to DIB
Transter	Boolean	true: assume ownership of the handle false: do NOT assume ownership

Remarks	This is the mechanism for assigning a DIB to the control.  If transfer is true, the when the control is unloaded it will delete the DIB memory.


method, IncreaseColors
IncreaseColors method

Overview	Increases the color depth of the input PicBuf image.

Return Type	void

Syntax	PicBuf.IncreaseColors Depth

Part	Data Type	Description
Depth	Short	Sets the new color depth. Must be in the set [4, 8, 24]

Remarks	The depth must be greater than the color depth of the input PicBuf image.


method, IncreaseColors, see also
See Also

ReduceColors method


method, Init
Init method

Overview	This method initializes a PicBuf image.

Return Type	Void

Syntax	PicBuf.Init  Bitdepth, Width, Height, Color

Part	Data Type	Description
Bitdepth	Short	The bit depth to use in creating the image.  Must be in the set [1, 4, 8, 24].
Width	Short	The width in pixels of the image to be created.
Heigth	Short	The height in pixels of the image to be created.
Color	Long	The RGB value to set all pixels of the image to. If bitdepth <= 8, then the initial palette will contain black (0) at all palette entries other than the last entry, which will be set to color. All pixels within the image will be mapped to the last palette entry. The resultant solid color image is useful as a base for image transfer, such as in compositing and resizing.

Remarks	Use this method to initialize an empty cotrol or to reset an existing cotrol's image.


method, Load
Load method

Overview	Loads a PicBuf with a chosen image.

Return Type	void

Syntax	PicBuf.Load

Remarks	This method uses the following properties:

Filename, ImageFormat, ImageNumber


method, Load, see also
See Also

LoadPal method


method, LoadCallback
LoadCallback method

Overview	Loads an image like Load, but with callback events enabled.

Return Type	void

Syntax	PicBuf.LoadCallback PeekControl

Part	Data Type	Description
PeekControl	Object	The control that will have messages processed (allows events in the control) before a callback event is fired to the PicBuf.

Remarks	If the ImageFormat value is 0 (IFUnused), the Filename value must have a .GIF, PNG, FIF or .JPG extension. All other extensions will generate a run time error.

This method uses the following properties:  CallbackLines, Filename, ImageFormat, ImageNumber


method, LoadPal
LoadPal method

Overview	Loads the palette of the PicBuf with a palette loaded from a file specified by the Filename property.

Return Type	void

Syntax	PicBuf.LoadPal

Remarks	Only files containing a Windows logical palette (LOGPALETTE) will be valid.  The StorePal method writes files of this type.  Uses the FileName property.


method, LoadPal, see also
See Also

Store method


method, MapIndex
MapIndex method

Overview	Maps a reference to a palette entry within the image of a control to another palette entry.

Return Type	void

Syntax	PicBuf.MapIndex SrcEntry, DestEntry

Part	Data Type	Description
SrcEntry	Short	Palette entry within the image to change.
DestEntry	Short	New palette entry to reference.

Remarks	This statement only operates on controls containing palettized images.


method, MaskCopy
MaskCopy method

Overview	Changes the control's image by combining three PicBuf images,  consisting of two source images (this control's image and an input source image and ) and a mask image.

 Return Type	void

Syntax	PicBuf.MaskCopy SrcPicBuf, MaskPicBuf

Part	Data Type	Description
SrcPicBuf	Object	The PicBuf containing the source image; must be 24-bit.  The source PicBuf's image is not modified by this method.
MaskPicBuf	Object	The PicBuf containing the mask image; can be any bit depth.  The mask PicBuf's image is not modified by this method.

Remarks	"Destination" refers to this control's image.  The mask image logically controls the color ratio of "source" pixels to "destination" pixels used in the result. This is done by treating the mask’s R, G, and B pixel values as percentages (0 to 255 is scaled to 0% to 100%). The overall effect of this method is that of a variable opacity mask.

The MaskCopy method provides the ability to composite one image over another with the opacity of the composite operation controlled via a third image that acts as a mask. It can be thought of as creating a new image by copying a "source" image onto a "destination" image "through" a mask image.

Alignment of the three images is determined using the XOrigin and YOrigin properties. The XOrigin and YOrigin properties of this control can be used to offset the srcPicBuf image before it is composited, just as in Assign. However, you can also use the XOrigin and YOrigin properties to achieve more complex compositing effects.  See the illustration below.

The key point to realize is that all three images are composited by overlaying the points defined by each image’s XOrigin and YOrigin properties (see Common Point of Origin above). Also remember that XOrigin and YOrigin always define the offset relative to each image’s upper left corner.

Where "source" or "mask" image areas do not cover the "destination" image (because of offsets or image size differences), the "destination" pixels are used in the result. This allows the use of partial masks to restrict compositing only to limited areas of the destination (see illustration above).

Note	This method only accepts 24-bit "source" and "destination" images. If you need to work with palettized images, first increase their color depths to 24 bits using IncreaseColors, then reduce their colors back to the desired bit depth using ReduceColors after using MaskCopy.

Consider a pixel at image location (200, 200). If the maskPicBuf image at that location has an R component of 255, it implies total replacement of the "destination" image’s R component at that pixel by the "source" image’s R component at that pixel. So, if the "source" pixel’s R component was 125, the R component would be 125 after the operation regardless of the R value of the "destination" pixel. If the "mask" R component were 127, it implies a 50% replacement, which means that the resulting R component is adjusted to halfway between the "source" and "destination" R components. In a 50% replacement, if the "source" R was 125 and the "destination" R was 225, the R would be 175 after the operation.  If, in the same case, the "mask" R was 0, the resulting R would equal the "destination" R regardless of the "source" R.


method, MatrixFilter
MatrixFilter method

Overview	Filters the input PicBuf image, using an n-by-n filter matrix.

Return Type	void

Syntax	PicBuf.MatrixFilter  Matrixsize, Matrix, Scale, Norm, Offset

Part	Data Type	Description
Matrixsize	Short	The matrix size to use:  3 (for a 3 x 3 matrix) or 5 (for a 5 x 5 matrix).  All other numbers are invalid.
Matrix	Short array	Array of integers of size matrixsize * matrixsize (i.e. either 9 or 25) that contains the filter matrix. Filter matrix values are multiplied by the value of the pixel under the matrix. 0 values indicate that matrix location is ignored. Be sure to pass the first element of the array (see example below).
Scale	Short	Factor to multiply normalized pixel value by.
Norm	Short	Indicates how the matrix elements should be normalized. If norm is greater than 1, then its value is used to divide each matrix element; if norm is -1, the matrix is "auto-normalized" by changing its values (while retaining their proportionality) such that their sum is 1. If norm is set to 0, no normalization is done.
Offset	Short	Added to the normalized and scaled pixel value to offset the value either positively or negatively.
Note	The MatrixFilter method is slower than ImageKnife’s edging, smoothing or softening methods because we have hand-coded these specialized methods in assembly language and optimized the code.

Remarks	The argument matrix consists of a kernel of values that are multiplied by surrounding pixels of an image to create certain visual effects. Kernels are square matrices of values that sweep across an image row by row.

Let’s take, for example, a 3 x 3 matrix. This algorithm is used to perform all edge detection, smoothing and softening within ImageKnife. With a 3 x 3 matrix the first and last row, first and last column of each image are copies of their neighbors (i.e. the outer edge of the images remains unchanged).

For our example, the kernel contains:

-1 -1 -1
-1  8 -1
-1 -1 -1

The MatrixFilter method starts the kernel within an image beginning at the origin. Thus, the upper left corner of the kernel will be positioned over the pixel that is at 0,0 and the lower right corner of the kernel will be positioned over the pixel that is at 2,2.

The values in the kernel are multiplied by the pixel values they are on top of for each color component (red, green, blue). As they are multiplied they are summed into a single value for each color component. Thus:

summed_value_red =
(k1 * 0,0red) + (k2 * 0,1red) + (k3 * 0,2red) +
(k4 * 1,0red) + (k5 * 1,1red) + (k6 * 1,2red) +
(k7 * 2,0red) + (k8 * 2,1red) + (k9 * 2,2red)

and so on for green and blue values. These summed values are then modified by the input values as follows:

If norm <> zero then
  summed_value = summed_value / norm
  summed_value = (scale * summed_value) + offset
end if

This value is then bounds checked to be certain to fit within the range 0-255:

If summed_value < 0 then
  summed_value = 0
end if
If summed_value > 255 then
  summed_value = 255
end if

These summed values then become the new color component values at 1,1. The kernel is then shifted to the right one column and a value for 1,2 is calculated and so on until the end of the row. Then the kernel is shifted down one row and the process continues to the last row of pixels in the image.

As each row is calculated it is buffered so as not to affect the calculation of other values. In the case of a 3 x 3 matrix, two rows are buffered. Thus now it is obvious that for a 3 x 3 matrix filter the first and last row and the first and last column of each row are not changed because they cannot be calculated.

The effect of this example matrix filter is to cause any edges within the image to be highlighted because the negative values on the edge of the kernel cause the summed value in consistently valued areas to converge to 0 thus setting the image to the background. Conversely where there exist sharp changes in values these differences will be heightened thus generating edges. The use of scale and offset just allow the user to tweak the algorithm to his own tastes.

The following table shows which matrices are used for the ImageKnife methods that involve matrix filter operations. For ImageKnife methods, scale is always 1 and offset is always 0. You can use these matrices as known values to compare with your own matrix values. In this table, magnitude represents the argument given to the ImageKnife method.

method	Matrix	Magnitude	Norm

Blur	1  1  1	any	9

1  1  1

1  1  1

ExtractEdges	-1 -1 -1	1	8

-1  8 -1	2	16

-1 -1 -1	3	24
4	32
5	40
6	48
7	56
8	64
9	72
10	80

Sharpen	-2 -3 -2	1	50

-3 21 -3	2	45

-2 -3 -2	3	40
4	35
5	30
6	25
7	24
8	23
9	22
10	21

Soften	1  2  1	1	21

2  4  2	2	18

1  2  1	3	15
4	12
5	10
6	8
7	7
8	6
9	5
10	4


method, Mirror
Mirror method

Overview	Flips the PicBuf image horizontally and/or vertically.

Return Type	void

Syntax	PicBuf.Mirror Horizontal, Vertical

Part	Data Type	Description
Horizontal	Short	TRUE:  the image will be mirrored about the horizontal axis.
Vertical	Short	TRUE:  the image will be mirrored about the vertical axis.

Remarks	This method is useful as an alternative to rotation.


method, Negate
Negate method

Overview	This method negates a PicBuf image.

Return Type	void

Syntax	PicBuf.Negate

Remarks	This method changes all colors to their opposites in RGB color space.  Black becomes white, white becomes black, yellow becomes blue, blue becomes yellow, etc.


method, OptimizePal
OptimizePal method

Overview	Replaces the palette of the destination PicBuf with the "best fit" palette among multiple PicBuf(s).

Return Type	void

Syntax	PicBuf.OptimizePal destPicBuf, PicBufArray, number, colors

Part	Data Type	Description
PicBufArray	Control array	Array of PicBufs containing images for which you want to find a common palette; Always pass in the first element of the array (e.g. PicBufArray(0))
Number	Short	The number of elements to process in PicBufArray
Colors	Short	The number of colors to limit the palette of the returned image to; Must be 256 or less

Remarks	Use this mehtod to combine the palette of a number of controls into the best possible fit.  Input PicBuf controls can contain either an image or a palette.

Note	While the OptimizePal method will give you the highest quality results, it is also the slowest method for getting several palettized images to have matching palettes. Experiment with using the methods referenced in the example to map images to a common palette, such as a generic VGA palette or a 3-3-2 palette.


method, OptimizePal, see also
See Also

DitherPal method

RemapPal method

SetScreenPal method


method, OptimizePalFiles
OptimizePalFiles method

Overview	Replaces the control’s palette with the "best fit" palette among multiple PicBuf images and files.

Return Type	void

Syntax	PicBuf.OptimizePalFiles  PicBufArray, nControls, FileArray, nFiles, Colors

Part	Data Type	Description
PicBufArray	Control array	Array of PicBufs containing images for which you want to find a common palette. Always pass in the first element of the array (e.g. PicBufArray(0)).
nControl	Short	The number of elements to process in PicBufArray.
FileArray	String array	Array of strings containing full pathnames to images for which you want to find a common palette.
nControls	Short	The number of elements to process in fileArray.
Colors	Short	The number of colors to limit the palette of the returned image to. Must be 256 or less.

Remarks	While the OptimizePalFiles statement will give you the highest quality results, it is also the slowest method for getting several palettized images to have matching palettes.


method, OptimizePalFiles, see also
See Also

DitherPal method

OptimizePal method

RemapPal method

SetScreenPal method


method, PasteClipboard
PasteClipboard method

Overview	Pastes an image from the clipboard to the ImageKnife control.

Return Type	void

Syntax	PicBuf.PasteClipboard [nSelection]

Part	Data Type	Description
nSelection	Short[optional]	Determines where the image is pasted. 0 = into current selection 1 = replace the entire image

Remarks	Use this method to copy images from other controls.


method, PasteClipboard, see also
See Also

CopyClipboard method


method, Pie
Pie method

Overview	Draws a pie shape counterclockwise from start to end lines into a PicBuf image.

Return Type	void

Syntax	PicBuf.Pie  xStart, yStart, xEnd, yEnd,

Part	Data Type	Description
xStart, yStart	Short	Defines the starting point of the line to the center of the bounding region that determine the start pie slice; the pie slice is drawn counterclockwise to the end pie slice
xEnd, yEnd	Short	Defines the ending point of the line to the center of the bounding region that determine the end pie slice
nDestination	Short[optional]	Determines where the arc is drawn to the window 0 = to the DIB (default) 1 = to the window

Remarks	The SelectHeight, SelectWidth, SelectLeft, and SelectTop properties define the bounding rectangle of the ellipse.  The DrawStyle, DrawWidth, ForeColor, BackColor, and FillTransparent properties define the line.  The BackColor, FillStyle, FillColor, and FillTransparent properties define the inside fill.  See the figure below.

Note	The color selected to draw into the image must be contained in the image’s palette.  If it is not, then the closest color found in the image’s palette is used.


method, PolyLine
PolyLine method

Overview	Draws a set of line segments specified by an array of points into a PicBuf image.  The first point in the array is considered the start of the line.

Return Type	Void

Syntax	PicBuf.PolyLine  Points, Number, [nDestination, optional]

Part	Data Type	Description
Points	Short array	Points that define the location of the line.  An array of short x, y line locations
Number	Integer	The number of points.  If this number is incorrect, a GPF (general protection fault) may occur.
nDestination	Short[optional]	Determines where the arc is drawn to the window 0 = to the DIB (default) 1 = to the window
Remarks	The DrawStyle, DrawWidth, and FillTransparent properties define the line. If the DrawArrows property is set, then arrowheads will be drawn on each line segment.

Note	The color selected to draw into the image should be contained in the image’s palette.  If it is not, then the closest color found in the image’s palette is used.


method, Polygon
Polygon method

Overview	Draws a polygon into a PicBuf image.

Return Type	void

Syntax	PicBuf.Polygon Points, Number, Winding, [nDestination, this is optional]

Part	Data Type	Description
Points	POINTAPI Array	Points that define the location of the polygon;  if the first and last points do not coincide, this method will draw a line between them to close the polygon
Number	Short	Elements;  if this number is incorrect, a GPF (general protection fault) may occur
Winding	Short	The polygon filling mode; see the following figure
nDestination	Short[optional]	Determines where the arc is drawn to the window 0 = to the DIB (default) 1 = to the window

Remarks	The DrawStyle, DrawWidth, ForeColor, BackColor, and FillTransparent properties define the line.  The BackColor, FillStyle, FillColor, and FillTransparent properties define the inside fill. See figure below.

Note	The color selected to draw into the image should be contained in the image’s palette.  If it is not, then the closest color found in the image’s palette is used.


method, PutScanLine
PutScanLine method

Overview	Transfers aline of raw pixel data into a PicBuf image.

Return Type	void

Syntax	PicBuf.PutScanLine Linenum, Scanline

Part	Data Type	Description
Linenum	Short	The line number of the PicBuf image to place scanline into. Must be in the set [0..PicBuf.YResolution - 1].
Scanline	Long Array	Array that contains the scan line’s pixel data. The number of elements needed for the array is equal to PicBuf.XResolution. Each element should contain the RGB color of one pixel in the scan line, unless image's color depth <= 8, in which case it should contain the pixel’s palette index.  The RGB values are defined as Windows COLORREF values.

Remarks	Use this method to change an entire line of an image.


method, PutScanLine, see also
See Also

GetScanLine method


method, RePos
RePos method

Overview	Repositions an image at x,y to window position x,y.

Return Type	void

Syntax	PicBuf.RePos ImageX, ImageY, WindowX, WindowY

Part	Data Type	Description
ImageX, imageY	Short	The image X,Y-coordinates
WindowsX,WindowsY	Short	The window X,Y coordinates.

Remarks	The image will be repositioned if the PicBuf window is smaller than the image.  The image will only be repositioned to the point where the image meets the edge of the PicBuf window.  If the X,Y coordinates are such that the image would move beyond the edge of the window, then the image is moved to the edge of the window only.  RePos can be used with or without scrollbars and with any image scaling.


method, Rect
Rect method

Overview	Draws a rectangle into a PicBuf image.

Return Type	void

Syntax	PicBuf.Rect, [nDestination, this is optional]

Part	Description
nDestination	Determines where the arc is drawn to the window 0 = to the DIB (default) 1 = to the window

Remarks	The SelectHeight, SelectWidth, SelectLeft, and SelectTop properties define the rectangle.  The DrawStyle, DrawWidth, and FillTransparent properties define the line.  The FillStyle, and FillTransparent properties define the inside fill.

Note	The color selected to draw into the image should be contained in the image’s palette.  If it is not, then the closest color found in the image’s palette is used.


method, ReduceColors
ReduceColors method

Overview	Reduces the number of colors in the input PicBuf image.

Return Type	void

Syntax	PicBuf.ReduceColors Colors, Optimize, Dither, Nobleed

Part	Data Type	Description
Colors	Short	The number of colors to reduce to.  Valid values are in the range [2..256].  If colors is <= 16, then optimize should be True, or the image’s palette will consist only of the system palette colors, which may or may not have anything to do with your image.
Optimize	Short	Indicates whether the PicBuf image uses a color palette that is optimized.  If True, the system palette colors are not included in the image’s palette, allowing all palette entries to be used for the image.  (BOOLEAN)
Nobleed	Short	Indicates whether to reduce color bleeding in the PicBuf image.  This determines whether the error calculation for setting a color at a pixel location is allowed to propagate to other pixel locations.  (BOOLEAN)
Dither	Short	If True, dither the colors in the PicBuf image.  If False, get the closest color without dithering.  (BOOLEAN)

Remarks	The bit depth of the resulting image is set to the minimum that will accommodate the specified number of colors (either 1, 4, 8, or 24 bit).


method, ReduceColors, see also
See Also

IncreaseColors method


method, ReduceColorsCallback
ReduceColorsCallback method

Overview	Reduces the number of colors in the input PicBuf image, but with callback events enabled.

Reurn Type	void

Syntax	PicBuf.ReduceColorsCallback Colors, Optimize, Dither, Nobleed, PeekControl

Part	Data Type	Description
Colors	Short	The number of colors to reduce to;  valid values are in the range [2..256];  if colors is <= 16, then optimize should be true, or the image’s palette will consist only of the system palette colors, which may or may not have anything to do with your image
Optimize	Short	Indicates whether the PicBuf image uses a color palette that is optimized;  if true, the system palette colors are not included in the image’s palette, allowing all palette entries to be used for the image.
Dither	Short	Indicates whether to dither the colors in the PicBuf image
Nobleed	Short	Indicates whether to reduce color bleeding in the PicBuf image
PeekControl	Control	The control that will have messages processed (allows events in the control) before a callback event is fired to the PicBuf

Remarks	The bit depth of the resulting image is set to the minimum that will accommodate the specified number of colors (either 1, 4, 8, or 24 bit).

This method uses the CallbackLines property.


method, RemapPal
RemapPal method

Overview	Replaces the image of the destination PicBuf with an image whose colors have been remapped to the palette of the source PicBuf.

Return Type	void

Syntax	PicBuf.RemapPal DestPicBuf, SrcPicBuf

Part	Data Type	Description
DestPicBuf	Control	Sets the destination PicBuf
SrcPicBuf	Control	Sets the source PicBuf

Remarks	Depending on the colors available in the specified palette, the processed image may look similar or change radically after this operation. It provides a fast, simple way of forcing images to specific palettes.

For your convenience, there are several useful palettes included with ImageKnife in the \palettes directory, which can be found under your ImageKnife directory. See A Palette Primer in the appendix for more information about palettes.


method, RemapPal, see also
See Also

DitherPal method

LoadPal method

OptimizePal method

SetScreenPal method


method, Rotate
Rotate method

Overview	Rotates the input PicBuf image a specified amount.

Return Type	void

Syntax	PicBuf.Rotate Angle, Colorvalue

Part	Data Type	Description
Angle	Short	The angle to rotate in degrees. Negative values are counterclockwise; positive values are clockwise.
Colorvalue	Long	The RGB color to use to fill area that doesn’t contain image data from the rotated image (occurs when the rotation is not a multiple of 90 degrees). If the image to rotate is palettized, the RGB value chosen is the closest fit from the image’s palette.  The RGB value is represented as a Windows COLORREF value.

Remarks	The PicBuf image is resized if necessary in order to contain the rotated image in its entirety.

Note	Calls to Rotate with angle set to an increment of 90 are significantly faster than other angle settings due to optimization.


method, RoundRect
RoundRect method

Overview	Draws a rectangle with rounded corners into a PicBuf image.

Return Type	void

Syntax	PicBuf.RoundRect  Ellipsewidth, Ellipseheight, [nDestination, this is optional]

Part	Data Type	Description
Ellipsewidth, Ellipseheigth	Short	Defines the size of the ellipse used to round the corners
nDestiantion	Short[optional]	Determines where the arc is drawn to the window 0 = to the DIB (default) 1 = to the window

Remarks	The SelectHeight, SelectWidth, SelectLeft, and SelectTop properties define the rectangle.  The DrawStyle, DrawWidth, and FillTransparent properties define the line.  The FillStyle, FillColor, and FillTransparent properties define the inside fill. See figure below.

Note	The color selected to draw into the image should be contained in the image’s palette.  If it is not, then the closest color found in the image’s palette is used.


method, ScreenToImageX
ScreenToImageX method

Overview	Returns the X location of a screen X location within an image.

Return Type	short; X location within an image

Syntax	PicBuf.ScreenToImageX Xlocation

Part	Data Type	Description
Xlocation	Short	The screen X value in pixels

Remarks	This method is useful in determining where in the image a mouse location's x value is within the MouseDown event of the PicBuf.


method, ScreenToImageY
ScreenToImageY method

Description	Returns the Y location of a screen Y location within an image.

Return Type	short

Syntax	PicBuf.ScreenToImageY Ylocation

Part	Data Type	Description
Ylocation	Short	The screen Y value in pixels.

Remarks	This method is useful in determining where in the image a mouse loacation's Y value is within the MouseDown event of the PicBuf.


method, SetPalColor
SetPalColor method

Overview	This method modifies a PicBuf palette entry at a specific location in the PicBuf's palette..

Return Type	void

Syntax	PciBuf.SetPalColor Position, Colorvalue

Part	Data Type	Description
Position	Short	Specifies the index position in the PicBuf palette to set. Must be in the set [0..255].
Colorvalue	Long	Contains the RGB value of the color to set.  RGB value is a Windows COLORREF value.

Remarks	Use this method to change the the color value stored at a position in the PicBuf's palette.  This method only works on 8-bit palettized images.


method, SetPalColor, see also
See Also

GetPalColor method


method, SetScreenPal
SetScreenPal method

Overview	This method forces the realization of the palette of the PicBuf.

Return Type	void

Syntax	PicBuf.SetScreenPal

Remarks	This method is particularly useful in situations where the palette of the PicBuf needs to have the focus.


method, Sharpen
Sharpen method

Overview	Sharpens the input PicBuf image, using the sharpness value.

Return Type	void

Syntax	PicBuf.Sharpen Sharpness

Part	Data Type	Description
Sharpness	Short	Indicates the amount of sharpening to apply. Must be in the set [1..10].

Remarks	Use this method to make edges within the image sharper.


method, Sharpen, see also
See Also

Blur method

MatrixFilter method

Soften method


method, Soften
Soften method

Overview	Softens the input PicBuf image, using the softness value.

Return Type	void

Syntax	PicBuf.Soften Softness

Part	Data Type	Description
Softness	Short	Indicates the amount of softening to apply. Must be in the set [1..10].

Remarks	Use this method to make edges within the image softer.

Softening affects the areas of an image with the greatest contrast. Compare this with blurring, which literally blurs the entire image. Softening is the opposite of sharpening (also see Sharpen method).


method, Soften, see also
See Also

Blur method

MatrixFilter method

Sharpen method


method, Store
Store method

Overview	Writes an image file to disk.

Return Type	void

Syntax	PicBuf.Store

Remarks	This method uses the Filename, WriteCompression, ImageFormat properties, and WriteOption properties.


method, Store, see also
See Also

AppendTIFF method

Load method


method, StorePal
StorePal method

Overview	Writes the palette of the PicBuf into a file

Return Type	void

Syntax	PicBuf.StorePal

Remarks	This method writes the palette of the PicBuf as a Windows LOGPALETTE to the file specified by the FileName property.


method, StorePal, see also
See Also

LoadPal method

WriteOption property


method, TextDraw
TextDraw method

Overview	Draws the text in the Text property into a PicBuf image.

Return Type	void

Syntax	PicBuf.TextDraw [nDestination,this is optional]

Part	Data Type	Description
nDestination	Short[optional]	Determines where the text is drawn. 0 = to the DIB (default) 1 = to the window

Remarks	The PicBuf must contain a DIB. Nothing is drawn outside of the select area. Everything is clipped or wrapped or auto sized into the select area.

The SelectHeight, SelectWidth, SelectLeft, and SelectTop properties define the bounding rectangle.

The Font, FontTransparent, Text, TextAlignment, TextAutoSize, and TextExtLeading properties determine how the text is drawn.

An advantage to using a select area for the text is that some of the draw tool methods use the select area also. The draw tools can be used to draw a frame around the text with an interesting fill pattern and then center the text within the same select area.

Note B	The text color, as selected by ForeColor, must be contained in the image’s palette.  If it is not, then the closest matching color in the image’s palette is used.


method, TextHigh
TextHigh method

Overview	Returns the height (in pixels) of text in the Text property, based on the settings of other text properties.

Return Type	Short

Syntax	PicBuf.TextHigh

Remarks	Based on the settings of the TextMultiLine and TextAutosize properites

TextMultiLine	TextAutoSize	Return Value
True	False	Height of the lines with Chr(10) line breaks as well as auto breaks inserted based on SelectWidth.  External leading taken into account if TextExtLeading is true.
False	True	Height of the lines with Chr(10) line breaks or the height of entire line if no Chr(10) line breaks.
Either	True	Height of the lines, with or without Chr(10) line breaks, after font size adjusted up to either SelectHeight or SelectWidth dimensions.


method, TextHigh, see also
See Also

TextWide method


method, TextWide
TextWide method

Overview	Returns the width (in pixels) of text in the Text property.

Return Type	Short

Syntax	PicBuf.TextWide

Remarks	Based on the settings of the TextMultiline and TextAutosize properties:

TextMultiline	TextAutoSize	Return Value
True	False	Width of longest string, in Text property, delimited by space or Chr(10) line breaks.  The value of TextWide is the minimum width that Select Width could be and still fit the longest unbroken string within the Text property without being clipped.  Typical use would be to determine and set SelectWidth greater than or equal to Text Wide.
True	False	Width of the longest line with Chr(10) line breaks or the width of entire the line if no Chr(10) line breaks.
Either	True	Width of the lines, with or without Chr(10) line breaks, after font size adjusted up to either SelectHeight or SelectWidth dimensions.


method, TextWide, see also
See Also

TextHigh method


method, Verify
Verify method

Overview	Checks the validity of a DIB.

Return Type	short

Syntax	PicBuf.Verify hDib

Part	Data Type	Description
hDib	Unsigned short	Handle to a DIB to verify

Remarks	This method is useful when passing a DIB to the PicBuf

A return value of zero indicates that ImageKnife can operate on this DIB.

Trappable runtime errors are generated to indicate problems

ImageKinfe operates on DIBs that are stored in a certain format.  This method will verify that the DIB being assigned to the PicBuf is in a valid format.

Error Message	Error Number
IMKBadDibGlobalEntryHandle	20110
IMKBadDibInvalidBIH	20111
IMKBadDibInvalidBIHLock	20112
IMKBadDibInvalidBIHSize	20113
IMKBadDibInvalidBIHPlanes	20114
IMKBadDibInvalidBIHCompression	20115
IMKBadDibInvalidBIHBitDepthAll	20116
IMKBadDibInvalidBIHBitDepth8or24	20117
IMKBadDibInvalidBIHColorTable	20118
IMKBadDibInvalidBIHSizeMismatch	20119


property LoadCropLeft LoadCropTop LoadCropWidth LoadCropHeight
LoadCropLeft, LoadCropTop,

LoadCropWidth, LoadCropHeight properties

Overview	These properties allow the user to define that part of a desired image to be loaded.

Data Type	short

Syntax	Picbuf1.LoadCropLeft

Picbuf1.LoadCropTop

Picbuf1.LoadCropWidth

Picbuf1.LoadCropHeight

Remarks	These properties currently only work for FIF files.  They allow the user to define a sub portion of an image to load/  In FIF image handling, which is image resolution independent, the user defines a LoadWidth and LoadHeight.  Within these settings the user could define a smaller portion of teh LoadWidth andLoadHeight to load.


property, About
About property

Overview	This method displays copyright and version information about ImageKnife.


property, About,  see also
See Also

Version property


property, AssignMode
AssignMode property

Overview	Controls how PicBuf image assignments occur. PicBuf image assignments are used in compositing and resizing operations, as well as for transferring entire images.

The destination’s XOrigin and YOrigin are used to compute how the upper left of the two images are offset for operations that involve compositing.

Data Type	short (Enumerated)

Syntax	PicBuf.AssignMode = mode

Part	Description
Mode	Type of assignment to use.
Setting	Constant	Description
0	AMTotal	(Default) Total replacement of the destination image by the source image occurs, along with any indicated resizing of the destination image. If the destination is a selection of a PicBuf image, it (and the image it is a part of, if necessary) are resized. Only the selected area is enlarged; the original bitmap is never enlarged. In any event, the resized selection area is centered on top of the original destination’s selection area. XOrigin and YOrigin have no effect when AssignMode = 0.
1	AMUnion	Union composite of source control's image or selection area over destination control’s image or selection area. Depending on the XOrigin and YOrigin values in the destination, the destination may be increased in size to accommodate the results.
2	AMIntersection	Intersection composite of source control's image or selection area over destination control’s image or selection area. No resizing occurs in either source or destination. XOrigin and YOrigin apply to relative placement of source on destination.
3	AMResize	Resize composite of source control's image or selection area over destination control’s image or selection area. Destination control's image or selection area is held to a constant size, and source image is resized according to the ResizeMode property to fit the size of the destination. Before the resized source image is placed, however, XOrigin and YOrigin are applied. This allows the source to be offset before the composition occurs. Any overlap is handled like Intersection Composite--trimmed away.
Note A	The AssignMode property is only relevant in destination PicBuf controls (the AssignMode property is ignored in source PicBuf controls during assignments).

Note B	Before you use AssignMode 1, 2, or 3 to make an assignment, make sure that the destination PicBuf already contains an image.  To do this, use Init, Load, or any other method that fills a PicBuf image.

Note C	The palette of the destination image is always replaced with the palette of the source image. When compositing images with different palettes, you should either increase the color depth to 24 bits or make use of ImageKnife’s palette methods.


property, AssignMode, see also
See Also

ResizeMode property

X, Y Origin properties


property, AutoLoad
AutoLoad property

Overview	Determines whether the control will automatically display an image.

Data Type	short (enumerated type)

Syntax	PicBuf.AutoLoad  = option

Part	Description
Option	Specifies the load option to use
Setting	Constant	Description
0	ALNone	(default) nothing is loaded at run time
1	ALFile	The image pointed at by the Filename property is loaded into the control at run time.
2	ALEmbed	The image pointed at by the Filename property is embedded into the executable and is loaded into the control at run time.

Remarks	This property effected at the instance the PicBuf is created at runtime.


property, AutoLoad, see also
See Also

Filename property


property, AutoScale
AutoScale property

Overview	Determines whether the image is automatically scaled to fit in the display window.

Data Type	short (Boolean)

Syntax	PicBuf.AutoScale = value

Setting	Description
Value not equal to zero	Sets the ScaleImage and ScaleScreen properties such that the image fits in the display window.
Value equal to zero	(Default) The ScaleImage and ScaleScreen properties are used to determine how the image is displayed within the control and may be set under program control.  The aspect ratio is kept constant in either event.
Remarks	Use this property and the AutoSize property to control how an image is displayed.

Note	When AutoScale is true, the ScaleImage and ScaleScreen properties become read-only at run time. Writing to them will not cause an error, but the values will not change.


property, AutoScale, see also
See Also

AssignMode property

AutoSize property

ResizeMode property

ScaleImage property


property, AutoSize
AutoSize property

Overview	Determines if the PicBuf control is automatically resized to fit the image size.

Data Type	short (Boolean)

Syntax	PicBuf.AutoSize = value

Setting	Description
Value not equal to zero	Automatically changes the Width and Height properties so that the PicBuf control fits the image it contains. The Left and Top properties remain unchanged.
Value equal to zero	(Default) Keeps the size of the PicBuf constant. Images contained within the PicBuf are clipped when they exceed the area of the PicBuf.

Remarks	Use this property and the AutoScale property to control how an image is displayed.

Note	If the AutoScale and AutoSize properties are both set to true, the AutoSize property takes precedence in the display of the image.


property, AutoSize, see also
See Also

AutoScale property


property, CallbackLines
CallbackLines property

Overview	The number of image scanlines to process before a callback event is fired.

Data Type	Short

Syntax	PicBuf.CallbackLines

Remarks	If this property is set to 0 (the default value), then LoadCallback and ReduceColorsCallback act just like Load and ReduceColors, respectively.

For FIF images, if the property is set to 1, callbacks will occur at a high frequency.  If set to a number greater than 1, callbacks will occur at a lower frequency.  Note : because of the nature of a FIF image, callbacks cannot occur after a specified number of lines.


property, ColorDepth
ColorDepth property

Overview	This property contains the color depth of the PicBuf image.

Data Type	Short

Syntax	PicBuf.ColorDepth

Remarks	This value will always be 1,4,8, or 24-bit.


property, ColorDepth, see also
See Also

IncreaseColors method

ReduceColors method

X,Y Resolution properties

InfoImage property


property, Contents
Contents property

Overview	This property indicates the contents of the PicBuf.

Data Type	Short (Enumerated)

Syntax	PicBuf.Contents

Setting	Constant	Description
0	CNTEmpty	Empty
1	CNTDibPal	DIB and palette.  (palettes for 8-bit depth or less)
2	CNTPal	Palette only.

Remarks	Use this method to determine the contents of a PicBuf.


property, DrawArrows
DrawArrows property

Description	Determines the arrowhead style used in Drawing methods.

Data Type	Short (Enumerated)

Syntax	PicBuf.DrawArrows = setting

Part	Description
Setting	Determines the type of arrows to use
Setting	Consant	Description
0	DANone	No arrows(DEFAULT)
1	DAStart	Arrows on start of line.
2	DAEnd	Arrow on end of line.
3	DABoth	Arrows on both ends of line.


property, DrawArrows, see also
See Also

InfoDraw property


property, DrawStyle
DrawStyle property

Overview	Determines the line style used in the drawing methods.

Data Type	Short (Enumerated)

Syntax	PicBuf.DrawStyle = width

Part	Description
width	Determines the style of line to use
Setting	Constant	Description
0	DSSolid	Solid (DEFAULT).
1	DSDash	Dash
2	DSDot	Dot
3	DSDash_Dot	Dash-Dot
4	DSDash_Dot_Dot	Dash-Dot-Dot
5	DSTransparent	Transparent Line Do not use DrawStyle 5 (transparent) with methods Arc or PolyLine.  If you use DrawStyle 5 with Chord, Pie, Polygon, Rect, or RoundRect, the FillStyle must be set to 0 or 2-7.
6	DSInside_Fill	Inside Fill Line

Remarks	If DrawWidth > 1 then DrawStyle 0 is used even though it may be set to a different value.


property, DrawStyle, see also
See Also

InfoDraw property


property, DrawWidth
DrawWidth property

Overview	Determines the line width (in pixels) used for output of the drawing methods.

Data Type	Short

Syntax	PicBuf.DrawWidth = Width

Part	Description
Width	Width of line to draw (default to one pixel)

Remarks	If DrawWidth > 1 then DrawStyle 0 is used even though it may be set to a different value.


property, DrawWidth, see also
See Also

InfoDraw property


property, Easter egg, see also
See Also

InfoImage property


property, ErrorNumber
ErrorNumber property

Overview	The Error Number associated with any run-time trappable error message.

Data Type	Short

Syntax	PicBuf.ErrorNumber = Number

Part	Description
Number	The Error number of the trappable error message.

Remarks	When the container generates a run-time trappable error message generated by ImageKnife the error number of the message is set to this property.  This is usable by containers that do  not provide access to the error number associated with an error message.

The user must set the value to zero after cheking its value so that on the next error the container can determine if this is an ImageKnife error.


property, Filename
Filename property

Overview	A string that specifies the path and filename of a file.

Data Type	String

Syntax	PicBuf.Filename = filename

Remarks	Used by AppendTiff, CountImages, DumpControl, Load, LoadCallback, LoadPal, Store, and StorePal.


property, Filename, see also
See Also

AppendTiff method

CountImages method

DumpControl method

InfoIO property

Load method

LoadCallback method

LoadPal method

Store method

StorePal method


property, FillColor
FillColor property

Overview	Determines the color applied to the fill styles used to fill in shapes created with the drawing methods.

Data Type	Long (RGB color)

Syntax	PicBuf.FillColor = color

Remarks	Defaults to 0 (black).  If the image’s palette does not contain the color, then the closest color found in the image’s palette is used.  Ignored when FillStyle = 1.


property, FillColor, see also
See Also

InfoDraw property


property, FillStyle
FillStyle property

Overview	Determines the pattern used to fill in shapes created with the drawing methods.

Data Type	Short (Enumerated)

Syntax	PicBuf.FillStyle = style

Part	Description
Style	Sets the pattern used to fill a drawing abject
Setting	Constant	Description
0	FSSolid	Solid
1	FSTransparent	Transparent(DEFAULT)
2	FSHorizontal	Horizontal Line
3	FSVertical	Vertical Line
4	FSUpward	Upward Diagonal
5	FSDownward	Downward Diagonal
6	FSCross	Cross
7	FSDiagonal	Diagonal Cross

Remarks	Used by drawing methods Chord, Pie, Polygon, Rect, RoundRect.


property, FillStyle, see also
See Also

Chord

InfoDraw property

Pie

Polygon

Rect

RoundRect


property, FillTransparent
FillTransparent property

Overview	Determines whether the drawing methods fill their interiors.

Data Type	Short (Boolean)

Syntax	PicBuf.FillTransparent  = Boolean

Part	Description
Boolean	Sets the drawing method used to be either filled or not filled
Setting	Description
False	(Default)  Use BackColor to fill spaces in lines when DrawStyle = 1-4 or 6, and to fill in space in pattern when FillStyle = 2-7.
True	Transparent fill to fill spaces in lines when DrawStyle = 1-4 or 6, and to fill in space in pattern when FillStyle = 2-7.

Remarks	Used by the Polygon method


property, FillTransparent, see also
See Also

InfoDraw property


property, Font
Font property

Overview	Determines the appearance of the text as a combination of a number of attributes.

Syntax	PicBuf.Font.[bold|italic|name|size|strikethrough|underline] = [argument]

Remarks	The Font property can be used to augment the font with the following attributes: bold, italic, underline, strikethrough, size, and name.


property, Font, see also
See Also

TextDraw method

FontTransparent property

InfoDraw property


property, FontTransparent
FontTransparent property

Description	 This property determines whether text is placed transparently on a background.

Data Type	Short (Boolean)

Syntax	PicBuf.FontTransparent [ = Boolean]

Part	Description
Boolean	Determines how the background of the text is drawn
Setting	Description
False	Fills the selected area with BackColor behind the text
True	Draws the text transparently

Remarks	Used by the TextDraw method.


property, FontTransparent, see also
See Also

Font property

InfoDraw property

TextDraw method


property, ImageFormat
ImageFormat property

Overview	Indicates the file format to use for CountImages, Load, LoadCallback., or Store.  For a list of formats available with each method, refer to the discussion of that method.

Data Type	Short (enumerated)

Syntax	PicBuf.ImageFormat [ = format]

Part	Description
format	Specifies the file format to use
Setting	Constant	Extension	Description

0	IFUnused	any listed	derive file type automatically from extension

1	IFTif	TIF 	Tagged Image File Format

2	IFTarga	TGA 	TrueVision Targa format

3	IFBMP	BMP 	Windows Bitmap format

4	IFGif	GIF 	CompuServe Graphics Interchange format

5	IFDib	DIB 	Windows Device Independent Bitmap format

6	IFPcx	PCX 	ZSOFT bitmap format

7	IFJPEG	JPG	Joint Photographic Experts Group format (JFIF standard as defined by the Independent JPEG Group)

8	IFPaintbrush	OLE paintbrush (used by Microsoft Access)

9	IFFif	FIF, FTT	FIF (fractal image) format

10 (See Note)	IFPng	PNG	PNG portable network graphics

Note :  Not available in 16-bit OCX version.

Formats	Color Depths 	Compression	Notes

TIFF	1, 2, 4, 8, 24	LZW, Packbits, 	No CCITT G3 & G4

none	No multi-page TIFF

Targa	8, 16, 24, 32	RLE, none

Bitmap	1, 4, 8, 24	RLE, none	Windows or OS/2

GIF	2, 4, 8	LZW	supports multi-image

DIB	1, 4, 8, 24	RLE, none	Windows or OS/2

PCX	1, 2, 4, 8, 24	RLE	older flavors are not supported

JPEG	24	JFIF formatted files only

FIF	4, 8, 24	may need FTT file

PNG	8, 24

Note	JPEG compressed files are by definition 24-bit images. You will need to take this into account if you are using JPEG files and your target users are using 256-or-fewer color displays.  The JPEG compressor can, however, accept 256-or-fewer color images. The resulting JPEG file will be a 24-bit image, though. See Appendix A, "ImageKnife and JPEG" for more details.


property, ImageNumber
ImageNumber property

Overview	Selects the image to get in a multi-image file (e.g., TIFF).   Used with Load and AppendTiff.

Data Type	Short

Syntax	PicBuf.ImageNumber  = options

Remarks	If the value is 0, the default (format-specific) or first available image is selected. If the value is non-zero, the image at that position is returned, and if there is no image at that position, an error occurs. If the value is -1, the thumbnail image of an InFocus Systems LiteShow II TIFF file is loaded.


property, ImageNumber, see also
See Also

AppendTiff method

InfoIO property

Load method


property, InfoDraw
InfoDraw property

Description	Builds a string that contains information about the following properties:  BackColor,DrawArrows, DrawStyle, DrawWidth, FillColor, FillStyle, and FillTransparent.

Data Type	String

Remarks	Useful at design time to display the property to the Debug window of the container.


property, InfoDraw, see also
See Also

InfoImage property

InfoIO property

InfoText property

InfoView property


property, InfoIO
InfoIO property

Overview	Builds a string that contains information about the following properties:  WriteCompression, WriteOption, ImageFormat, ImageNumber, and FileName.

Data Type	String

Remarks	Useful at design time to display the property to the Debug window of the container.


property, InfoImage
InfoImage property

Description	Builds a string that contains information about the following properties:  Contents, ColorDepth, XResolution, and YResolution SelectHeight, SelectWidth, SelectLeft, SelectTop, PrintHeight, PrintWidth, PrintLeft, and PrintTop.

Data Type	String

Remarks	Useful at design time to display information about the image in the Debug window of the container.


property, InfoImage, see also
See Also

InfoDraw property

InfoIO property

InfoText property

InfoView property


property, InfoText
InfoText property

Description	Builds a string that contains information about the following properties:  FontTransparent, TextAlignment, and TextAutoSize.

Data Type	String

Remarks	Useful at design time to display the property to the Debug window of the container.


property, InfoText, see also
See Also

InfoImage property

InfoIO property

InfoView property

InfoDraw property


property, InfoView
InfoView property

Description	Builds a string that contains information about the following properties:  AutoLoad, AutoScale, AutoSize, ScaleImage, ScaleScreen, ScrollBars, ScrollBarsLargeChange, and ScrollBarsSmallChange.

Data Type	String

Remarks	Useful at design time to display the property to the Debug window of the container.


property, InfoView, see also
See Also

InfoDraw property

InfoImage property

InfoIO property

InfoText property


property, LZW
LZW property

Overview	Unlocks the use of Unisys's patented LZW compression algorithm for GIF, or for both GIF and TIFF.

Data Type	String

Syntax	PicBuf.LZW = string

Part	Description
String	String to unlock use of the LZW compression algorithm

Remarks	To obtain the correct string assignment for this methodality, the user must call Media Architects and provide proof of licensing with Unisys.

This property is available at design time only.

WARNING

Use of this software for developing any software providing LZW capability for any purpose is not authorized unless user first enters into a license agreement with Unisys under U.S. Patent No. 4,558,302 and foreign counterparts.  For information concerning licensing, please contact:

Unisys Corporation

Welch Licensing Department - C1SW19

Township Line and Union Meeting Roads

P.O. Box 500

Blue Bell, PA 19424


property, MouseIcon
MouseIcon property

Description	Allows the cursor to be attached to a graphic object.

Data Type	String

Syntax	PicBuf.MouseIcon = icon file

Part	Description
Icon File	Fully qualified pathname to a graphic object file

Remarks	The string points to a graphic object file ( BMP, ICO, CUR, ...) that will be displayed if the MousePointer property is set to 99.


property, MousePointer
MousePointer property

Description	Determines the type of mouse pointer displayed when the mouse is over a PicBuf.

Data Type	Short

Syntax	PicBuf.MousePointer = Setting

Part	Description
Setting	Determines the type of pointer to utilize when the mouse traverses a PicBuf image
Setting	Constant	Description
0	MPDefault	Pointing Hand
1	MPArrow	Arrow (Default)
2	MPCross	Cross
3	MPIBeam	I Beam
4	MPIcon	Icon
5	MPSize	Size
6	MPSizeNESW	Size NE SW
7	MPSizeNS	Size NS
8	MPSizeNWSE	Size NW SE
9	MPSizeWE	Size WE
10	MPUpArrow	Up Arrow
11	MPHourglass	Hourglass
12	MPNoDrop	No Drop
13	MPArrowHour	Arrow and Hourglass
14	MPArrowQuestion	Arrow and Question
15	MPSizeAll	Size All
99	MPCustom	Custom

Remarks	This property can be set at design time and at run time.  The mouse cursor will only change when it is in a control window at run time.

The standard cursors can be used by assigning MousePointer property to one of the following settings (in the range 0-12).

The custom cursors must be loaded with LoadCursor before assigning MousePointer to the loaded cursor index (in the range 13- 31).


property, Picture
Picture property

Overview	Determines a device dependent bitmap compatible with the Visual Basic Picture Box control Picture Property. Not available at design time.

Data Type	Short (hPicture)

Syntax	PicBuf.Picture  = hBitmap

Part	Description
hBitmap	Handle to a Windows Device Dependant Bitmap (DDB).

Remarks	This property allows you to transfer images between an ImageKnife PicBuf control and a standard Visual Basic Picture Box control. It is compatible with either the Picture property or the Image property. If you are attempting to transfer the persistent bitmap of a Picture Box or Image control, use the Image property (see the entry for Image Property in the Visual Basic Language Reference). The Picture property is limited to the color depth of the current Windows video mode.


property, PrintHeight
PrintHeight, PrintWidth properties

Description	Determine the dimensions of the area to print on the destination device (e.g. a printer).

Data Type	Short; must be zero or positive.

Syntax	PicBuf.PrintHeight = numericExpression

PicBuf.PrintWidth = numericExpression

Part	Description
numericExpression	Sets either the width or the height of the Printer area to print to

Remarks	Measurements are specified in printer pixels.


property, PrintHeight, see also
See Also

PrintLeft property

PrintTop property

PrinterhDC property


property, PrintLeft
PrintLeft, PrintTop properties

Description	PrintLeft determines X-coordinate of the print origin in pixels on the destination device.

PrintTop determines Y-coordinate of the print origin in pixels on the destination device.

Data Type	Short

Syntax	PicBuf.PrintLeft = x
PicBuf.PrintTop = y

Part	Description
X or Y	The X or Y location of the Printer Area at which to start printing


property, PrintLeft, see also
See Also

PrintHeight property

PrintWidth property

PrinterhDC Property


property, PrintTop
PrintLeft, PrintTop properties

Overview	PrintLeft determines X-coordinate of the print origin in pixels on the printer destination device.

PrintTop determines Y-coordinate of the print origin in pixels on the printer destination device.

Data Type	Short; must be positive.

Syntax	PicBuf.PrintLeft = x

PicBuf.PrintTop = y

Part	Description
X or Y	Location within the printer destination device that defines the left  (X) and top (Y) edges to print to


property, PrintWidth
PrintHeight, PrintWidth properties

Description	Determine the dimensions of the rectangular area to print on the printer destination device

Data Type	Short

Syntax	PicBuf.PrintHeight = numericExpression
PicBuf.PrintWidth = numericExpression

Part	Description
numericExpression	Location within the printer device that defines the rectangular area to print

Remarks	These measurements are specified in printer pixels.


property, PrinterhDC
PrinterhDC property

Overview	Prints a PicBuf image to a printer device context.

Data Type	Short (hDC)

Syntax	PicBuf.PrinterhDC = hDC

Part	Description
hDC	Handle to a printer Device Context

Remarks	This property is the key to ImageKnife’s easy printing capability. Typically, you will be assigning Printer.hDC to  this property, which actually prints the image in a PicBuf control.


property, PrinterhDC, see also
See Also

PrintLeft property

PrintTop property

PrintHeight property

PrintWidth property


property, ResizeMode
ResizeMode property

Overview	Determines how image assignment is done between PicBufs when the AssignMode property implies that resizing of the image is to occur.

Data Type	Short (Enumerated)

Syntax	PicBuf.ResizeMode = Mode

Part	Description
Mode	Specifies what resize mode to use
Setting	Constant	Description
0	RMDeletedFixed	Use pixel deletion/replication during resizing, but do not allow the image aspect ratio to change.
1	RMDeletedVariable	Use pixel deletion/replication during resizing, but allow the image aspect ratio to change (stretching/squeezing may occur).
2	RMResampleFixed	Use resampling during resizing with aspect ratio fixed.
3	RMResampleVariable	Use resampling with source ratio allowed to change.

Remarks	This property is used by the Assign method.

Note	Resampling typically results in a clearer image, but requires more processing time.


property, ResizeMode, see also
See Also

AssignMode property


property, ScaleImage
ScaleImage, ScaleScreen properties

Overview	Determines the scaling of image pixels to screen pixels.  Used to zoom in or out on images.

Data Type	Short

Syntax	PicBuf.ScaleImage = value

PicBuf.ScaleScreen = value

Part	Description
Value	Defines what scale to use.

Remarks	The scaling is determined by the ratio of ScaleScreen:ScaleImage (that is, by the number of screen pixels to the number of image pixels).  The default values of both ScaleImage and ScaleScreen are 1.

A ratio of 1:1 means a one-to-one mapping between screen pixels and image pixels.  A ratio of 2:1 means to zoom in (two screen pixels for every image pixel).  Similarly, 1:2 means to zoom out (two image pixels for every screen pixel).

The values of ScaleScreen and ScaleImage must both be in the range 1..32767 and the ScaleScreen:ScaleImage ratio must be between 1:200 and 200:1.  For example, 3:599 is a valid ratio, while 3:601 would cause an error condition.  The error will occur on the next attempt to paint the control with an invalid ScaleScreen:ScaleImage ratio.


property, ScrollBars
ScrollBars property

Overview	Displays scrollbars on a PicBuf if the image in the PicBuf cannot be completely shown within the boundaries of the control.

Data Type	Short (Enumerated)

Syntax	PicBuf.ScrollBars = Style

Part	Description
Style	Defines the type of scrollbar to create
Setting	Constant	Description
0	SBNone	No scrollbars will be displayed on the PicBuf.
1	SBHorizontal	A horizontal scrollbar will be displayed on the bottom edge of the PicBuf.
2	SBVertical	A vertical scrollbar will be displayed on the right edge of the PicBuf.
3	SBBoth	Both horizontal and vertical scrollbars will be displayed on the PicBuf. The scrollbars are of a fixed size and automatically cause the PicBuf image to pan left, right, up, or down and needed. Scrollbars will not appear unless the image cannot be completely displayed in the PicBuf. The scrollbars appear within the client area of the PicBuf.

Remarks	Even if the scrollbar is turned on for either horizontal or vertical, it will not be displayed if the image fits within the window.

Note	When setting this property to any value other than NONE, a run time error will
occur if the AutoScale and AutoSize properties are not both set to false.


property, ScrollBars, see also
See Also

ScrollBarsLargeChange property

ScrollBarsSmallChange property


property, ScrollBarsLargeChange
ScrollBarsLargeChange property

Overview	Sets the scroll amount when the scrollbar's page area (between the thumb and arrow) is clicked.

Data Type	Short

Syntax	PicBuf.ScrollBarsLargeChange = scrollAmount

Part	Description
scrollAmount	Sets the amount to move the image when the mouse is clicked within the scrollbar

Remarks	Valid values are in the range of 1 through 32767.  Default is 10.


property, ScrollBarsSmallChange
ScrollBarsSmallChange property

Overview	Sets the scroll amount when the arrow button is clicked.

Data Type	Short

Syntax	PicBuf.ScrollBarsSmallChange =ScrollAmount

Part	Description
ScrollAmount	Sets the amount to move the image when the mouse is clicked on the arrow button in the scrollbar.

Remarks	Valid values are in the range of 1 through 32767.  The default is 1.


property, SelectHeight
SelectTop, SelectLeft, SelectHeight, SelectWidth properties

Overview	Determines the  dimensions of the rectangular area used to select the area available for several PicBuf-to-PicBuf operations, such as image assignment, and for Draw and Text methods.

Data Type	Short; must be positive.

Syntax	PicBuf.SelectHeight  = numeric expression

PicBuf.SelectWidth  = numeric expression

Part	Description
numeric expression	Sets the dimensions of of the rectangular area for performing operations

Remarks	Measurements are calculated in pixels.


property, SelectHeight, see also
See Also

SelectLeft property

SelectTop property


property, SelectLeft
SelectLeft, SelectTop Properties

Description	SelectLeft determines X-coordinate of left edge of a rectangular area used to select a specific portion of an image.

SelectTop determines Y-coordinate of top edge of a rectangular area used to select a specific portion of an image.

Data Type	Short; must be positive.

Syntax	PicBuf.SelectLeft = x
PicBuf.SelectTop = y

Part	Description
X or Y	Describes the location within the image that defines the left (X) and top (Y) edge of the selection area.  Must be >=0 and <= Picbuf.XResolution-1 or <= Picbuf.YResolution-1.

Remarks	The defined area is available for several PicBuf-to-PicBuf operations, such as image assignment, draw, and text methods. These properties are measured in pixels from the appropriate edge of the image.


property, SelectLeft, see also
See Also

SelectHeight property

SelectWidth property


property, SelectTop
SelectLeft, SelectTop Properties

See Also	Sample Code

Run & Design Time

Description	SelectLeft determines X-coordinate of left edge of a rectangular area used to select a specific portion of an image.

SelectTop determines Y-coordinate of top edge of a rectangular area used to select a specific portion of an image.

Data Type	Short; must be positive.

Syntax	[form.]PicBuf.SelectLeft[ = x]
[form.]PicBuf.SelectTop[ = y]

Remarks	The defined area is available for several PicBuf-to-PicBuf operations, such as image assignment, draw, and text methods. These properties are measured in pixels from the appropriate edge of the image.


property, SelectWidth
SelectHeight, SelectWidth properties

Description	Determine dimensions of the rectangular area used to select the area available for several PicBuf-to-PicBuf operations, such as image assignment, and for Draw and Text methods.

Data Type	Short; must be positive.

Syntax	PicBuf.SelectHeight = numericexpression
PicBuf.SelectWidth = numericexpression

Part	Description
numericExpression	Describes the location defining the rectangular area for selection.  Must be >0 and <+either Picbuf.XResolution ro Picbuf.YResolution

Remarks	Measurements are calculated in pixels.


property, Text
Text property

Overview	Determines text that is drawn into DIB.

Data Type	String

Syntax	PicBuf.Text  = string

Part	Description
String	Sets the string to draw Can contain Chr(10) (Basic) or '\n' (C) to specify hard returns in a string. Any other control character is displayed only.  Chr(13), '\r', which allows for CR-LF pairs to break a line, is ignored. The Text property from a text box control can be assigned directly to this property.

Remarks	This property is also used to calculate TextHigh and TextWide methods.


property, TextAlignment
TextAlignment property

Overview	Determines the alignment of text lines in the select area.

Data Type	Short (Enumerated)

Syntax	PicBuf.TextAlignment  = Alignment

Part	Description
Alignment	Sets how the text is to be aligned on the control
Setting	Constant	Description
0	TALeft	(DEFAULT)  Left justify.
1	TARight	Right justify
2	TAVertical	Center


property, TextAlignment, see also
See Also

InfoText property

TextDraw method


property, TextAutoSize
TextAutoSize property

Overview	This property determines the size of the text that is drawn by the TextDraw method

Data Type	Short (Boolean)

Syntax	PicBuf.TextAutoSize [ = Boolean]

Part	Description
Boolean	Sets the manner in which text is adjusted to fit the window
Setting	Description
False	(DEFAULT)  FontSize determines size of text
True	Adjust font to fit Text string into select area.

Remarks	When True, the text size is adjusted to fit the select area to the width or the height whichever dimension is maximized first.  For example, the select height will be the limiting dimension if the adjusted height of the text meets the select height before the adjusted width meets the select width. Line breaks ( Chr(10)) will work with TextAutoSize = True. The width of the Text string will be determined by the longest line contained in the Text property with breaks.

Note	If TextAutoSize = True, then the SelectHeight property must be less than 40.  Although larger sizes might work, the text might not be drawn correctly.  This limitation does not apply to 8-bit or 24-bit images.


property, TextAutoSize, see also
See Also

InfoText property

TextDraw method


property, TextExtLeading
TextExtLeading property

Overview	Uses the font External leading for output text.

Data Type	Short (Boolean)

Syntax	PicBuf.TextExtLeading = Boolean

Part	Description
Boolean	Determines whether or not to use the font't external leading value
Setting	Description
False	(DEFAULT)  Don't use fonts' external leading value.
True	Output text will use external leading specified by the container font property when outputting lines.


property, TextExtLeading, see also
See Also

TextDraw method


property, TextMultiline
TextMultiline property

Overview	Determines if line breaks are automatically inserted in a Text string to make all of the words fit within the select area without clipping.

Data Type	Short (Boolean)

Syntax	PicBuf.TextMultiLine [ = Boolean]

Part	Description
Boolean	Sets the placement of the line break
Setting	Description
False	(DEFAULT)  No automatic line breaks. If line is longer than select area, it will be clipped.
True	Insert a line break to keep text from being clipped. If a word, delimited by spaces or Chr(10) line breaks, is longer than the SelectWidth then it will be clipped anyway. Use TextWide property to set SelectWidth to avoid this problem.

Remarks	Used by the TextDraw method


property, TextMultiline, see also
See Also

TextDraw method


property, Version
Version property

Description	Indicates the version numbers of the various ImageKnife components that are being used by your application

Data Type	String

Syntax 	PicBuf.Version


property, WriteOption
WriteOption property

Overview	Defines options for outputting JPG & PNG files

Data Type	Short (enum)

Syntax	PicBuf.WriteOption = Integer (Enumerated)

Integer Setting	Constant	Description
0	WONone	None
1	WOProgressive	Writes a progressive display file.  Can be used by Internet browsers (i.e. Netscape)
2	WOGrayScale	Writes an 8 bit grayscale image.
3	WOGrayScale8bit	JPG and PNG.  Writes a progressive display, 8 bit grayscale.

Remarks	Options 2 & 3 require that the image in the control is an 8 bit grayscale image.  No conversion is done.


property, XOrigin, YOrigin
XOrigin, YOrigin properties

Overview	These properties specifiy X and Y coordinates used as relative offsets from the left and top edges of the PicBuf.

Data Type	Short

Syntax	PicBuf.Xorigin = numericexpression

PicBuf.Yorigin = numericexpression

Part	Description
numericExpression	Specifies the relative offsets (in pixels).  Default sets to zero.

Remarks	Can be negative or exceed the size of the image to control compositing. See the section on Assignment Capabilities in Chapter Four for more information.


property, XOrigin, see also
See Also

AssignMode property

MaskCopy method


property, XResolution, YResolution
XResolution, YResolution properties

Overview	Indicates X and Y dimensions in pixels, of the actual image data. Not available at design time, read-only at run time.

Data Type	Short

Syntax	PicBuf.Xresolution

PicBuf.YResolution

Remarks	These properties are quite different from the Height and Width properties, which describe the height and width of the actual PicBuf control, not the height and width of the image.


property, hDC
hDC property

Overview	Specifies a handle provided by the Windows Environment to the device context of a PicBuf.

Data Type	Short

Syntax	PicBuf.hDC

Remarks	The hDC property is extremely useful for making Windows API calls to the window of the PicBuf.


property, hDIB
hDib property

Overview	Specifies a handle to a DIB that the client can share with a PicBuf.

DataType	Short

Syntax	PicBuf.hDib = Handle

Part	Description
Handle	Handle to a Windows Device Independant Bitmap

Remarks	This is a handle to a device-independent bitmap (DIB).  When the control is unloaded, memory will not be released for reuse.  The client is responsible for all memory associated with this handle.


property, hPalette
hPalette property

Overview	Specifies a handle to a color palette that the client can remap to a PicBuf.

DataType	Short

Syntax	PicBuf.hPalette = Handle

Part	Description
Handle	Handle to a Windows palette

Remarks	This property specifies a handle to a Windows palette containing from 2 to 256 entries. Each entry contains an RGB color value that all pixels that are mapped to that palette entry will use. Palette entries are not necessarily unique, nor are they in any particular order. Likewise, unused palette entries are not necessarily contiguous. An unused palette entry will have a value of 0 (black, or 0, 0, 0 in RGB format).

When the control is unloaded, memory will not be released for reuse.  The client is responsible for all memory associated with this handle.


property, hPalette, see also
See Also

DitherPal method

GetPalColor method

GetPalette method

LoadPal method

OptimizePal method

RemapPal method

SetPalColor method

StorePal method


property, text, see also
See Also

InfoText property

TextHigh method

TextWide method


topic, A Little about Media Architects
ImageKnife Help

A Little about Media Architects

Media Architects' mission is to grow profitably by creating and marketing families of software tools which enable developers to efficiently produce world-class interactive multimedia applications and titles for Microsoft Windows® platforms using standard development systems.

Media Architects is riding the wave created by two strong currents:  first, the shift to using commercial software components to speed development of applications for Microsoft Windows and second, the push to create interactive multimedia products for CD-ROM and on-line delivery.  The company's combination of multimedia production experience and software development expertise allows it to create multimedia development tools that greatly increase developer productivity.  Not only will both the development components and multimedia markets experience rapid growth in the coming years, but efforts in each area feed ideas and tools to the other area, strengthening Media Architects' competitive position.

Current software development products include ImageKnife, TWAINWizard™, MediaKnife™ and VideoPlay™. ImageKnife is an image handling software component. These 32 bit OLE controls can be used with a number of development systems such as VB 4.0®, VC++ 4.0™, Delphi 2™, Access 95, Paradox™, and VisualFox Pro™.  By packaging a wide range of image display, processing and output capabilities in an easy-to-use custom control, ImageKnife makes it possible to develop applications incorporating advanced imaging capabilities without extensive programming or prior graphics experience. MediaKnife allows Windows developers to create high-impact multimedia games, titles, kiosks, presentations and other applications using Visual Basic. MediaKnife creates new design options for independent game and title developers, and is an ideal tool for MIS and contract developers attempting to add multimedia capabilities to specialized corporate systems. MediaKnife allows them to create applications that have a much higher impact through the use of motion, sound and other multimedia elements, without sacrificing the advantages of developing in standard development systems.

Media Architects, Inc. is based in Portland, Oregon and markets products worldwide through direct marketing, development product catalog operations and other software resellers. Founded in 1988, Media Architects, Inc. was a pioneer in the application of computers for audience presentation, providing multimedia production services for trade shows and other high visibility marketing events.  Customers have included Intel, In Focus Systems and Egghead Software.  Drawing on the experience gained from this production business, the company moved into the multimedia software tools business in 1992 and in 1994 developed a CD-ROM title, Presentation World, for Cinemar Corporation.  Media Architects' business is now entirely focused on creating multimedia tools for Windows professionals.

MediaKnife and ImageKnife are trademarks of Media Architects, Inc.  All other trademarks and  registered trademarks are the property of their respective owners.


topic, A Palette Primer
ImageKnife Help

A Palette Primer

With the advent of inexpensive High Color and True Color video cards and advanced compression techniques for the PC, palettized images will eventually become the exception. However, the installed base of standard VGA and SuperVGA cards is enormous and still growing, so it will be several years before we see the disappearance of palettized images.

This is unfortunate because palettized images can create a lot of headaches for programmers. ImageKnife can help ease these headaches for you with our palette manipulation routines. We have found that many of our users are not familiar with how palettes work and what their programs need to be able to do to insure reliable display of images on any video card. The appendix below is in response to your requests for more information about palettes.

What is a Palette

Why Does Only One Image Displays Properly at a Time?

Why Should I Even Bother with Palettized Images?

Problems with Palettes

I Have A 24-bit Image--Why Does it Look So Bad?

But {program name} Displays the Image Just Fine...

How Does ImageKnife Display a Palettized Image?

What Can ImageKnife Do with Palettes?


topic, Alignment Control in PicBuf Assignments
ImageKnife Help

PicBuf Assignment Capabilities

Alignment Control in PicBuf Assignments

In addition to the variety of methods by which PicBuf images can be combined through varying the properties AssignMode and ResizeMode, ImageKnife allows source and destination images to be offset from each other prior to completing an assignment method. This allows tremendous flexibility in compositing; in effect, cropping and compositing can be accomplished at the same time.

The alignment of source image over the destination is controlled by the destination’s XOrigin and YOrigin properties. Positive YOrigin and XOrigin values move the origin down and to the right, respectively; negative values move the origin up and to the left. Alignment occurs after any resizing specified by AssignMode and ResizeMode. After these adjustments, the composition takes place, completing the assignment. Note that if AssignMode is 0, the effects of XOrigin and YOrigin are ignored (there is no concept of alignment with Total Replacement). For all other AssignMode values, however, there is full control over the alignment of source and destination images.


topic, Anatomy of the PicBuf
ImageKnife Help

The PicBuf Control

Anatomy of the PicBuf

ImageKnife PicBuf controls provide screen-mode-independent containers for images of variable bit depth. The PicBuf, which logically contains the bitmap and palette, gives ImageKnife the ability to perform sophisticated processing on up to 24-bit images without losing color data, even if the operations are performed using a monochrome video adapter.

The Picture property is included for compatibility with the Visual Basic picture box control, and is for transferring images between the two types of controls.

There are a number of other properties that comprise PicBuf controls, including those that are part of the Visual Basic Picture Box control, and numerous special properties that support the advanced image handling capabilities of ImageKnife.

ImageKnife also provides a number of special properties to:

♦	control panning and zooming of an image within a visible PicBuf control

♦	force "realization" of an image’s palette upon gaining the Windows focus

♦	full control resizing, resampling, cropping, and compositing through simple assignment methods

♦	obtain the current version of ImageKnife

♦	easily produce high-quality color output to a Windows device such a color printer at the full resolution of the image

For full reference information on the capabilities afforded by PicBuf special properties, refer to the reference section of this system.  For more explanation of the PicBuf control’s assignment capabilities, look ahead in this chapter to "PicBuf Assignment Capabilities".


topic, Before Installation
ImageKnife Help

Before Installation

To use ImageKnife, you must first have a 32-bit container application installed on your computer, along with Microsoft Windows 95 or Windows NT.  Refer to the appropriate manuals if you need assistance installing a programming environment suitable for use with ImageKnife.

ImageKnife requires approximately three megabytes of free disk space on a 486 or better computer with at least eight megabytes of memory.

Please be sure you have read the license agreement that comes with this manual before installing ImageKnife, especially if you are installing ImageKnife on a second machine.


topic, Bitdepths and the PicBuf
ImageKnife Help

The PicBuf Control

Bitdepths and the PicBuf

The following table shows the image bit depths that a PicBuf control can contain.

Bit Depth	Max # of Colors	Palettized?

1	2	yes

4	16	yes

8	256	yes

24	16.7 million	no

Note	The bit depth of an image determines the maximum number of colors that can be present in an image. For example, an 8-bit image could contain 256 different colors, but use only 216 colors.

Sometimes 24-bit imaging is referred to as True Color. The term High Color is commonly used to refer to non-palettized 15-bit (32,768 colors) and/or 16-bit (65,536 colors) graphics. ImageKnife stores High Color images in 24-bit format. For more information about palettes and palettized images, see, "A Palette Primer."


topic, But {program name} Displays the Image Just Fine...
ImageKnife Help

Problems With Palettes

But {program name} displays the image just fine...

Any image loaded into a PicBuf is always loaded as a DIB (Device Independent Bitmap) with the full color depth of the original image, even when the video card does not support display at that color depth.  This is in contrast with Microsoft’s Visual Basic Picture Box control which loads the image as a DDB (Device Dependent Bitmap) which causes the original color depth information of non-palettized images to be lost.  ImageKnife image processing methods can always work at full color depth for highest quality results regardless of what video mode the machine is using.

In designing ImageKnife, we chose this route to give you, the applications programmer, the most latitude in handling image processing. If you want your application to be like the off-the-shelf image processing applications that display an image "properly" no matter what video mode you are running in, you can easily write the code to have ImageKnife reduce the color depth of the image to do this. You can maintain a "shadow" image in the background that contains the image with all its original information while the user sees an image that matches their video capabilities. Or, you can conserve resources and overhead by working directly with the image at its full bit-depth. The choice is yours.


topic, Color Quantization
ImageKnife Help

Advanced Issues

Color Quantization

Eight-bit video hardware stores 8 bits per pixel, so it can display 256 or fewer distinct colors at a time. To display a True Color image, the computer must map the image into an appropriate set of representative colors. This process is called "color quantization". (This is something of a misnomer, "color selection" would be a better term. We’re stuck with the standard usage though.)

Clearly, color quantization is a lossy process. It turns out that for most images, the details of the color quantization algorithm have much more impact on the final image quality than do any errors introduced by JPEG (except at the lowest JPEG quality settings).

Since JPEG is a 24-bit format, converting a color JPEG image for display on 8-bit or less hardware requires color quantization. This is true for all color JPEGs: even if you feed a 256-or-less color GIF into JPEG, what comes out of the decompressor is not 256 colors, but thousands of colors. This happens because JPEG’s lossiness affects each pixel a little differently, so two pixels that started with identical colors will probably come out with slightly different colors. Each original color gets "smeared" into a group of nearby colors. Therefore quantization is always required to display a color JPEG on a palettized display, regardless of the image source. The only way to avoid quantization is to ask for gray-scale output. (Incidentally, because of this effect it’s pretty much meaningless to talk about the number of colors used by a JPEG image.) Color quantization is handled in ImageKnife through the use of the ReduceColors method.

On the other hand, a palettized image by definition has already been quantized to 256 or fewer colors. For purposes of image distribution, palettized images such as GIF files have the advantage that the sender precomputes the color quantization, so recipients don’t have to. This is also the disadvantage of palettization: you’re stuck with the sender’s quantization. If the sender quantized to a different number of colors than what you can display, you have to re-quantize, resulting in much poorer image quality than if you had quantized once from a True Color image. Furthermore, if the sender didn’t use a high-quality color quantization algorithm, you’re out of luck.

For this reason, JPEG offers the promise of significantly better image quality for all users whose machines don’t match the sender’s display hardware. You can have your application quantize the JPEG True Color image to precisely match the user’s display hardware using the ReduceColors method on the receiving end. With a palettized image, you’re stuck forevermore with what was sent. Furthermore, you can send a higher quality image that is smaller that a lower quality palettized image.

Finally, an ever-growing number of people have better-than-8-bit video hardware already; consisting of 15- or 16-bit High Color PC video displays, true 24-bit video, etc. For these people, palettes are already obsolete, as palettized images cannot represent an image to the full capabilities of their display. JPEG images can drive these displays much more effectively. Thus, JPEG is an all-around better choice than GIF for representing images in a machine-independent fashion.


topic, Deleting PicBuf Images
ImageKnife

Basic Structure

Deleting PicBuf Images

To delete an image from a PicBuf control, including both its bitmap and palette, use the Clear method.  This not only removes the image from the control, but also frees up all memory associated with that image and palette. This can be quite significant when dealing with large images (e.g. a 640 x 480 x 24 bit image consumes over 900k of memory).

If the hDib property is used, the PicBuf will display the image that hDib refers to.  To clear the image in this case, set hDib=0.  You are responsible for the memory associated with hDib.   To remove this memory, call the Windows API method GlobalFree.

Note	Be sure to set hDib=0 before you call GlobalFree.  Otherwise, the PicBuf will be using a deleted handle.


topic, Does Loss Accumulate with Repeated Compression?
ImageKnife Help

Advanced Issues

Does loss accumulate with repeated compression/decompression?

It would be nice if, having compressed an image with JPEG, you could decompress it, manipulate it (crop off a border, say), and recompress it without any further image degradation beyond what you lost initially. Unfortunately this is not the case. In general, recompressing an altered image loses more information, though usually not as much as was lost the first time around.

The next best thing would be that if you decompress an image and recompress it without changing it then there is no further loss, i.e., you get an identical JPEG file. Even this is not true; at least, not with the current version of ImageKnife. It’s essentially a problem of accumulation of roundoff error. If you repeatedly compress and decompress, the image will eventually degrade to where you can see visible changes from the first-generation output. (It usually takes many such cycles to get visible change.)

The bottom line is that JPEG is a useful format for archival storage and transmission of images, but you don’t want to use it as an intermediate format for sequences of image manipulation steps. Use a lossless format (PCX, TGA, TIFF, etc.) while working on the image, then JPEG it when you are ready to file it away. Aside from avoiding degradation, you will save a lot of compression/decompression time this way.


topic, Exchanging Images Directly with other Applications
ImageKnife Help

Image Exchange Compatibility

Exchanging Images Directly with Other Applications

The ImageKnife tools can be extremely powerful when used by skilled software writers. This section discusses techniques for programming tasks such as grabbing an image from another program without writing the image to disk as a middle step. Use these techniques with caution, as sloppy use of these techniques may cause your application to behave erratically.


topic, File Formats
ImageKnife Help

Advanced Issues

File formats

Strictly speaking, JPEG refers only to a family of compression algorithms; it does not refer to a specific image file format. The JPEG committee was prevented from defining a file format by turf wars within the international standards organizations.

Since we can’t actually exchange images with anyone else unless we agree on a common file format, this leaves us with a problem. In the absence of official standards, a number of JPEG program writers have just gone off to "do their own thing", and as a result their programs aren’t compatible with anybody else’s.

The closest thing we have to a de facto standard JPEG format is some work that’s been coordinated by C-Cube Microsystems. They have defined two JPEG-based formats file:

♦	JFIF (JPEG File Interchange Format), a format that transports pixels and little else.

♦	TIFF/JPEG, a.k.a. TIFF 6.0, an extension of the Aldus TIFF format. TIFF is a "high-end" format that will let you record just about everything you ever wanted to know about an image, and a lot more besides. TIFF is a lot more complex than JFIF, and may well prove less transportable, because different vendors have historically implemented slightly different and incompatible subsets of TIFF. It’s not likely that adding JPEG to the mix will do anything to improve this situation.

Both of these formats were developed with input from all the major vendors of JPEG-related products; it’s reasonably likely that future commercial products will adhere to one or both standards.

We at Media Architects have chosen the JFIF standard for several reasons. JFIF is simpler than TIFF and is available now; the TIFF 6.0 specification is vague on some crucial details. Even when TIFF/JPEG is well defined, the JFIF format is likely to be a widely supported "lowest common denominator"; TIFF/JPEG files may never be as transportable. It is also interesting to note that the JPEG files now being distributed in the various graphics groups on the Internet (which includes well over a million users) are for the most part JFIF-flavor JPEGs.

A particular case that people may be interested in is Apple’s QuickTime software for the Macintosh. QuickTime uses a JFIF-compatible format wrapped inside the Mac-specific PICT structure. Conversion between JFIF and QuickTime JPEG is pretty straightforward, and several Mac programs are available to do it. If you have an editor that handles binary files, you can strip a QuickTime JPEG PICT down to JFIF by hand (see below).


topic, Files You Need to Distribute
ImageKnife Help

Files You Need to Distribute

Files You Need to Distribute

The following steps are necessary to take for any application using ImageKnife to work on a system on which it was not Installed from the master disks:

1. 	MFC40.DLL and MSVCRT40.DLL must be put in the \Windows\System directory.  These are Visual C++ runtime DLL’s.  As with any common runtime file, your setup program should only overwrite older versions of these files.

2. 	IK32.OCX should be put on the target computer and registered.  Most installation programs will register a custom control for you.  If your setup program is having problems registering ImageKnife, consult the Technical Support Frequently Asked Questions list, available from all of Media Architects’ online locations.

3. 	Under NO circumstances should you distribute the file IK32.LIC.  To do so would violate the license agreement.

4. 	In the event that other ImageKnife components or modules are made available by Media Architects, put any .DLL files into the \Windows\System Directory, and any other file in the same directory as IK32.OCX.  This is the case with Iterated System's decompression DLL (Deco_32.dll).  This DLL is needed to decompress fractal image files (.fif).


topic, How Do I Recognize Which File Format I Have?
ImageKnife Help

Advanced Issues

How do I recognize which file format I have, and what do I do about it?

If you have an alleged JPEG file that ImageKnife won’t read, it’s likely to be Hand-Made Software (HSI) format or some other proprietary JPEG-based format. You can tell what you have by inspecting the first few bytes of the file:

1.	A JFIF-standard file will start with the characters (hex) FF D8 FF E0, followed by two variable bytes (often hex 00 10), followed by ‘JFIF’.

2.	If you see FF D8 at the start, but not the rest of it, you may have a "raw JPEG" file. This is probably decodable as-is by JFIF software like ImageKnife-- it’s worth a try, anyway.

3.	HSI files start with ‘hsi1’. You’re out of luck unless you have HSI software. Portions of the file may look like plain JPEG data, but they won’t decompress properly with non-HSI programs.

4.	A Macintosh PICT file, if JPEG-compressed, will have a couple hundred bytes of header followed by a JFIF header (scan for ‘JFIF’). Strip off everything before the FF D8 and you should be able to read it.

5.	Anything else: it’s a proprietary format, or not JPEG at all. If you are lucky, the file may consist of a header and a raw JPEG data stream. If you can identify the start of the JPEG data stream (look for FF D8), try stripping off everything before that.


topic, How Does ImageKnife Display a Palettized Image?
ImageKnife Help

A Palette Primer

How does ImageKnife display a palettized image?

ImageKnife handles all images as DIBs (device independent bitmaps) once they are read from disk. A DIB that is less than 24 bits deep contains a color lookup table.  Each of the entries in the pixel table contains an index into this color table which indicates the color information for that pixel.  When the image is displayed, the color table is converted to a logical palette which Windows maps to the system palette.  If the window that the image is going to be displayed in has the focus, then the Windows video device driver will attempt to insert the actual colors from this palette into the system palette (i.e. the video hardware).  In any case, the device driver will match the palette as closely as it can with the actual colors in the hardware registers and produce a map of the image indices onto the system color registers.  The image is then displayed by using this map to place the image data on the screen.

If the image palette does not have a color in it, say one of the reserved Windows colors, that is in the hardware registers, there is a good chance that this color will not be displayable in the image. It may happen that all of the palette colors will map to other colors.  For instance, if the palette contains no yellow color, then yellow cannot be displayed in the window which has this palette realized even though there is a video register which contains yellow.  There is just no mapping to this color.


topic, How Does the OCX differ from the VBX?
ImageKnife Help

How Does OCX version differ from VBX?

Major New Features

♦	New 32 bit JPG

♦	New PNG file format

New 32-bit Fractal Format

♦	Easy to use methods

♦	Faster file IO

Differences

The differences in the features of the ImageKnife user interface are changes to the properties and statements (now Methods).

Removed from OCX

Properties

Name	Reason
Control	No longer needed
FontBold, FontItalic, FontName, FontSize, FontStrikethru, FontUnderline	Embedded into the stock Font object
PasteDib, PasteSelection	Moved functionality to the PasteClipboard method
CopyDib, CopySelection	Moved functionality to the CopyClipboard method
TextHigh	Moved functionality to the TextHigh method
TextWidth	Moved functionality to the TextWidth method
Statements

Name	Reason
ikLoadCursor	With the new MouseIcon property the basic functionality of loading various objects (.cur,.ico,.bmp) is provided.  Due to certain losses of functionality (combining all resources into a single DLL) and reported problems with performance, this method will be provided in a future release.
IkView	Due to the architecture of Win95 this was not portable from the VBX.
Additions to OCX

Properties	Description
AutoLoad	Allows design and run time displaying of images
InfoDraw, InfoImage, InfoIO, InfoText, InfoView	Provides informational strings useful for debugging
MouseIcon	Attaches objects to the mouse
WriteOption	Allows specialized output of PNG & JPG
Methods	Description
CopyClipboard	replaces CopyDib & CopySelection properties
PasteClipboard	replaces PasteDib & PasteSelection properties
TextHigh	replaces the TextHigh property
RegionRb	Allows dynamic setting of the select ?? and Print ??? Properties.
TextWidth	replaces the TextWidth property
Converting your ImageKnife/VBX projects to ImageKnife/OCX

First, when ImageKnife is installed, it modifies the VB.INI file to allow you to load in your existing projects created with VB 3.0 or VB 4(16-bit) and convert ImageKnife/VBX Version 2.0 or 1.3 controls to use ImageKnife version 1.0

Second, remove all ikdsp16.vbx (ver 2.0)or Knife.VBX (ver 1.3) Declare statements from the project.

Third, modify all ikxxxxx calls in your program so that they use methods.  Example pairs are shown below, with IK2 usage above IK32 usage.

ikload PicBuf1(0)

PicBuf1(0).Load

ikclear PicBuf1(0)

PicBuf1(0).Clear

ikassign PicBuf1(1), False, PicBuf1(0), False

PicBuf1(1).Assign False, PicBuf1(0), False

temppanx = ikScreenToImageX(PicBuf1(1), 0)

temppanx = PicBuf1(1).ScreenToImageX(0)


topic, How Well Does JPEG Compress Images?
ImageKnife Help

ImageKnife and JPEG

How well does JPEG compress images?

Very well. Here are some sample file sizes for an image, a 480 x 360 x 24-bit image of a person in her vegetable garden (this image is included on your distribution diskette). The first three files are for comparison purposes; the rest were created with ImageKnife JPEG software.

File	Size in bytes	Comments

marybeth.tif	518,596 	Original file in TIFF format (no compression; 24 bits or 3 bytes per pixel, plus a few bytes overhead)

mblzw.tif	563,633 	Saved as a TIFF with LZW compression.  Notice this actually results in negative compression.

marybeth.gif	148,150 	Saved as a GIF.  Converted to 256 colors using the ReduceColors method. Most of the savings is the result of losing color info.

mb95.jpg	143,567 	with quality 95 (highest useful quality setting).  This is indistinguishable from the 24-bit original.

mb75.jpg	62,076 	with quality 75.  You have to look mighty darn close to distinguish this from the original, even with both on-screen at once.

mb50.jpg	40,882 	with quality 50.  This has slight defects; if you know what to look for, you could tell it’s been JPEGed without seeing the original. Still good image quality.

mb25.jpg	25,984 	with quality 25.  JPEG’s characteristic "blockiness" becomes apparent at this setting. Still, there have been lots of GIF files that were of poorer image quality than this.

mb5.jpg	8,783 	with quality 5.  Blocky, but perfectly satisfactory for preview or indexing purposes. Note that this file is tiny: the compression ratio from the original is over 60:1!

In this case JPEG can make a file that’s a factor of 4 or 5 smaller than a GIF of comparable quality (the quality 75 file is every bit as good as the GIF, better if you have a 24-bit display). This seems to be a typical ratio for real-world scenes. However, just as with all image compression schemes, it is important to realize that even though JPEG images are much smaller on disk, the still take up just as much space in memory when you are manipulating and viewing them.


topic, I Have A 24-bit Image--Why Does it Look So Bad?
ImageKnife Help

Problems With Palettes

I have a 24-bit image--why does it look so "bad"?

These 24-bit images display with the "wrong" colors when viewed in 16 or 256 color video modes. The reason for this is quite simple: VGA and SuperVGA video modes require palettes and 24-bit images don’t have palettes. So, Windows makes its best guess at what it thinks the image should use for a palette and maps the various colors in the image to the colors it has available. Windows’ best guess is usually far from correct and the image generally looks quite garish.


topic, ImageKnife Error Codes
ImageKnife Help

ImageKnife Error Codes

Trappable errors

The following error codes are generated by ImageKnife for the appropriate events. If left untrapped, your application will close after displaying an error dialog box. For more information about trapping errors in Visual Basic, see the Visual Basic Programmer’s Guide Chapter 10, "Handling Run-Time Errors."

Control Errors

Error Code	Message

   20300	This control does not support that type of picture

   20301 	Array is of zero size or too many dimensions

   20302 	Picture is zero size

   20303 	Invalid chunk index

   20304 	Opening the Clipboard failed

   20305 	Emptying the Clipboard failed

   20306 	Control does not contain a Dib

   20307 	Setting the Dib to the Clipboard failed

   20308 	Closing the Clipboard failed

   20309 	Getting the Dib on the Clipboard failed

   20310 	Scrollbars can't be used if AutoSize is TRUE

   20311 	Scrollbars can't be used if AutoScale is TRUE

   20312 	AutoScale can't be TRUE if Scrollbars are used

   20313 	AutoSize can't be TRUE if Scrollbars are used

   20314 	The From Control is Invalid

   20315 	The To Control is Invalid

   20316 	The Mask Control is Invalid

   20317 	The From Control does not contain an image

   20318 	The To Control does not contain an image

   20319 	The Mask Control does not contain an image

   20320 	The Control parameter is NULL

   20321 	The Control does NOT contain a palette

   20322 	The Control contains an image.  It can't

   20323 	The Control must contain an image or a palette

   20324 	The Control is already System Colors add to it

   20325 	The 'lines' parameter must be >= 0

   20326 	The window for the control that handles the callback message does not exist

   20327 	Not a valid MousePointer property.

   20328 	Cursor file cannot be found

   20329 	Cursor file is bad

   20330 	Could not find cursor in file

   20331 	cursor Index must be one of 13 through 31

   20332 	WARNING

Use of this software for developing any software providing LZW capability for any purpose is not authorized unless user first enters into a license agreement with Unisys under U.S. Patent No. 4,558,302 and foreign counterparts (see LZW property)

   20333 	ScrollBarsSmallChange and ScrollBarsLargeChange value must be greater than 0.

   20334 	RePos can't be used if AutoSize is True.

   20335 	RePos can't be used if AutoScale is True.

   20336 	RePos control coordinates are out of range. Must be >= 0 and < Height or Width

   20337 	RePos image coordinates are out of range. Must be >= 0 and < Xresolution or Yresolution

   20338 	ReduceColors property must be one of 2 through 256

   20339 	DrawWidth property must be one of 1 through 32767

   20340 	Open file failure:

   20341 	Close file failure:

   20342 	Write file failure:

   20343 	ScaleScreen property must be one of 1 through 32767

   20344 	ScaleImage property must be one of 1 through 32767

   20345 	Attempt to paint a PicBuf with ScaleScreen:ScaleImage ratio less than 1:200 or greater than 200:1

   20346 	hDib property is write only

   20347 	hPalette property is write only

   20348 	Contents property is read only

   20349 	Selection flag is True with SelectWidth = 0 and/or SelectHeight = 0

   20350 	Control is NOT an ImageKnife control

   20351 	Could not set the palette color.

   20352 	Filename Property is empty.

   20353 	Filename Property is too large to copy.

   20354 	Out of memory. Operation Failure.  Shutdown Processes and try again

   20355 	Number to process in array is not within the bounds of the array

   20356 	Array is not allocated

   20357 	Array must be 1 dimensional

   20358 	the hDibDC property can only be set to 0

   20359 	releasing the DC for the DIB failed

   20360 	locking DIB failed

   20361 	Device Context creation failed

   20362 	Control already has created a Device Context for the DIB. Only one at a time is allowed.

   20363 	Control array must contains some controls

   20364 	No controls or files to operate on

   20365 	An unroverable error has occurred.  The control is unstable.  Contact customer support.

   20366 	Value outside of valid range of >= 0 and <= 3

   20367 	ColorDepth can't be set a run time

   20368 	Invalid draw arrow property setting

   20369 	Invalid draw style property setting

   20370 	Invalid fill style property setting

   20371 	The hDC property is read only.

   20372 	Not a valid ImageFormat value.

   20373 	Not a valid LoadScale.

   20374 	The LZW property is not available at run time.

   20375 	MouseIcon can only be a *.CUR or *.ICO file.

   20376 	Could not create Picture.

   20377 	The PrinterhDC property is write only.

   20378 	Not a valid ResizeMode value.

   20379 	Can't set ScaleImage or ScaleScreen with AutoScale True.

   20380 	Not a valid ScrollBars value.

   20381 	Not a valid TextAlignment value.

   20382 	The TextWide property is read only.

   20383 	The TextHigh property is read only.

   20384 	The Xresolution property is read only.

   20385 	The Yresolution property is read only.

   20386 	Bad array type parameter has been found

   20387 	The AutoLoad property is not available at run time.

   20388 	The Embedded property is not available at run time.

   20389 	System failure (GetPaletteEntries)

   20390 	Drawing Destination parmeter must be a short

   20391 	Invalid write option property setting

   20392 	Value outside of valid range of >= 0 and <= 2

   20393 	This fuctionality not implemented in this version.  To obtain a version of ImageKnife/OCX that supports decompression of fractal images, contact Media Architects Technical Support.

   20394 	This fuctionality not implemented in this version.  To obtain a version of ImageKnife/OCX that supports drawing, contact Media Architects Technical Support.

   20395 	Clipboard Destination parmeter must be a short

   20396 	Number of points is non-existent or of wrong type

   20397 	type of region to create is invalid

   20398 	region at location does not exist

   20399 	location parameter is required

   20400 	bad location for insertion of region

   20401 	enabled parameter is of wrong type

   20402	bad raster operation setting

   20403 	can't be set to less than zero. Printing to area out of range

   20404 	Printing will be disabled.  Width to print must be > zero

   20405 	Printing will be disabled.  Height to print must be > zero

   20406 	can't be set to less thn or equal to zero.  Printing to an empty area

   20407 	Not available in the 16 bit OCX version

   20408 	 is out of resources

   20409 	an unknown exception has been detected

   20410 	an assertion has failed

Engine Errors

Error Code	Message

   20100 	The specified file does not exist

   20101 	The specified file was of the incorrect type or corrupted

   20102 	Out of memory

   20103 	The picture does not have a palette

   20104 	The picture does not have a bitmap

   20105 	The specified format parameter (or DataFormat) is not supported

   20106 	The specified bit-depth is invalid

   20107 	An error occurred while writing the file

   20108 	The specified format parameter does not support the image

   20109 	The specified picture is invalid

   20110 	Invalid DIB: Not in Global Entry Table List

   20111 	Invalid DIB: contains an Invalid BITMAPINFOHEADER

   20112 	Invalid DIB: can't lock in memory

   20113 	Invalid DIB: size of BITMAPINFOHEADER does not match entry size in the global entry table

   20114 	Invalid DIB: number of bit planes must be 1

   20115 	Invalid DIB: must be in uncompressed (BI_RGB) format

   20116 	Invalid DIB: bit depth must be 1,4,8, or 24

   20117 	Invalid DIB: bit depth must 8 or 24

   20118 	Invalid DIB: invalid color table (Must be 1 4 8 24)

   20119 	Invalid DIB: size of data in the Global Entry Table does not match size in BITMAPINFOHEADER

   20120 	he source images must have the same bit-depth

   20121 	The specified image area is invalid

   20122 	The specified magnitude is invalid

   20123 	The specified softness is invalid

   20124 	The specified sharpness is invalid

   20125 	No manipulation was specified

   20126 	he specified rotation angle is invalid

   20127 	The specified brightness is invalid

   20128 	The specified contrast is invalid

   20129 	e specified area is invalid

   20130 	The specified option is invalid

   20131 	Operation Failure

   20132 	The specified compression parameter is invalid

   20133 	The specified TIFF compression scheme is not supported

   20134 	Can't find IKJPG16 dll

   20135 	Invalid version of IKJPG16 dll loaded

   20136 	The image could not be displayed.  You may be low on memory.

   20137 	The X value is NOT within the bounds of the image

   20138 	The Y value is NOT within the bounds of the image

   20139 	Mismatch of the bit depth of the image and the number of colors in the palette.  Setting a Picbuf image to a Palette requires the bit depth of the image match the number of colors in the palette

   20140 	Invalid palette used in setting a image to a palette

   20141 	A True Color Image does not have a palette

   20142 	An invalid palette with < 2 colors has been detected

   20143 	Invalid Option: must be >= 0 or <= 2

   20144 	Number of colors must be >=2 or <= 256

   20145 	Desired colors in palette exceeds limit of 256 colors with 20 colors included in the System Palette

   20146 	a ZASSERT has FAILED.  Fatal error.

   20147 	Image contains more than 236 colors

   20148 	This operation only operates on 8 bit images

   20149 	Cannot load IKFAX.DLL

   20150 	Cannot find procedures to load in IKFAX.DLL

   20151 	Invalid CCITT group 3 or 4 file.

   20152 	Invalid CCITT group 3 or 4 file loading option. Cannot load only the palette

   20153 	Image number specified must >= 0

   20154 	Draw failed. Could not create DC.

   20155 	Draw failed. Could not execute draw statement

   20156 	Text Draw failed. Could not execute text draw statement

   20157 	Text AutoSize failed.

   20158 	Select area must be greater than 0.

   20159 	Can't find DECO_32.DLL

   20160 	Bad DECO_32.DLL

   20161 	FIF decompression error

   20162 	Cannot find FTT file for FIF decompression.

   20163 	Color reduction code for this operation requires an 8 bit image

   20164 	Operating System Error has occurred.  Please notify Customer Support

   20165 	The result of this operation has generated too many colors

   20166 	The result of this operation has generated too few colors

   20167 	The settings for the reserved entries are out of bounds < 10 or > 245

   20168 	The selected palette is invalid.

   20169 	Loading LZW compressed TIFF files is NOT allowed unless the user has authorization through Unisys.  (see LZW property).

   20170 	Loading GIF files is NOT allowed unless the user has authorization through Unisys.  (see LZW property).

   20171 	Storing LZW compressed TIFF files is NOT allowed unless the user has authorization through Unisys.  (see LZW property).

   20172 	Storing GIF files is NOT allowed unless the user has authorization through Unisys.  (see LZW property).

   20173 	FIF image area is too large for double scale output.

   20174 	JPEG file type is not supported.

   20175 	source index is not used in the image

   20176 	destination index is not used in the image

   20177 	can't load MKFILE16.DLL

   20178 	can't find mkfLoad prodcedure in MKFILE16.DLL

   20179 	can't find mkfLoadSprite prodcedure in MKFILE16.DLL

   20180 	unknown symbol found while reading file

   20181 	An error was encountered while reading the PNG file

   20182 	An error was encountered while writing the PNG file

   20183 	An error was encountered while reading the JPEG file

   20184 	An error was encountered while writing the JPEG file

   20185 	Bad red color range

   20186 	Bad green color range

   20187 	Bad blue color range

   20188 	Wrong FIF DLL Version

   20189 	FIF file is greater than version 6.0.  Contact vendor about updated support

   20190 	One or more of the Load parameters is Invalid

   20191 	Original Resolution of the image is unknown, or not in given pixels

   20192 	An error was encountered in either reading or finding the FTT file

   20193 	An error was encountered while reading the FIF file

   20194 	more than 2 points must de defined for a polygon

   20195 	more than 1 point must de defined for a polyline

   20196 	An error was encountered while reading the file


topic, ImageKnife and PNG
ImageKnife Help

ImageKnife and PNG

What is PNG?

PNG, officially pronounced "ping," stands for Portable Network Graphics. This new graphics standard is being promoted by a number of organizations, especially CompuServe, as an alternative to the GIF standard. For those who don't know, GIF became decidedly less popular right around New Year's Day 1995 when Unisys and CompuServe suddenly announced that programs implementing GIF would require royalties, due to Unisys' patent on the LZW compression method used in the GIF format. Since GIF had been showing its age in a number of ways even prior to that, the announcement only catalyzed the development of a new and much-improved replacement format, PNG. It is a format, which provides a portable, legally unencumbered, well-compressed, well-specified standard for handling lossless bitmapped image files.

GIF Features Retained in PNG

•	Indexed-color images of up to 256 colors.

•	Streamability: files can be read and written serially, thus allowing the file format to be used as a communications protocol for on-the-fly generation and display of images.

•	Progressive display: a suitably prepared image file can be displayed as it is received over a communications link, yielding a low-resolution image very quickly followed by gradual improvement of detail.

•	Transparency: portions of the image can be marked as transparent, creating the effect of a non-rectangular image.

•	Ancillary information: textual comments and other data can be stored within the image file.

•	Complete hardware and platform independence.

•	Effective, 100% lossless compression.

Important and Popular New Features of PNG

•	True color images up to 48 bits (16 bits for each RGB value).

•	Grayscale images up to 16 bits.

•	Full alpha channel, and general transparency masks.

•	Image gamma information, which supports automatic display of images with correct brightness/contrast regardless of the machines used to originate and display the image.

•	Reliable, straightforward detection of file corruption

•	Faster initial presentation in progressive display mode.

•	Better compression than GIF, typically 10% to 30%

Benefits of the PNG Design

•	Simple and portable: developers should be able to implement PNG easily.

•	Legally unencumbered: to the best knowledge of the PNG authors, no algorithms under legal challenge are used. (Some considerable effort has been put into verifying this.)

•	Well compressed: both indexed-color and true color images are compressed as effectively as in any other widely used lossless format, and in most cases more effectively.

•	Interchangeable: any standard-conforming PNG decoder will read all conforming PNG files.

•	Flexible: the format allows for future extensions and private add-ons, without compromising interchangeability of basic PNG, nor is there any need for a versioning scheme which might stop some programs from reading in an image they are perfectly capable of, just because it has some newer version number that they do not recognize or support.

•	Robust: the design supports full file integrity checking as well as simple, quick detection of common transmission errors.

PNG Features that ImageKnife currently does and does not support

PNG feature	ImageKnife support
Progressive Display (see description below)	Can read and write, but can't display progressively
2, 4, 8, and 24-bit color images	Full read and write support these bit depths
8 and 16-bit grayscale images	Read and write 8 bit grayscale, 16-bit reading only uses the most significant byte, 16-bit writing is currently unsupported.
Text chunks	Currently no support for compressed or uncompressed chunks of text
Gamma correction	Currently unsupported
Alpha Channel/Transparency	Currently unsupported
Pixel Dimensions	Currently unsupported
How do PNG’s progressive images work, and what good are they to me?

Progressive display is becoming popular with the growing use of on-line services. Given the relatively low transmission rates, it is often boring to wait with nothing to see on the screen until an entire image has been transmitted. If an image viewer (e.g. a network browser) supports progressive display, you will see a blocky image on the first pass, and then a better and better image as more data comes through instead of the image on a line by line basis. A normal PNG image is stored row after row, linearly in the file, but if we have a progressive PNG, which uses a seven pass, two-dimensional interlacing scheme known as Adam7, we can get, in a much shorter amount of time, an idea of the total image rather than only a few lines of it.  In Adam 7, the image is broken into a series of 8x8 chunks from which PNG picks which pixels will be stored or read on each pass.  On the first pass, only the upper left pixel of each 8x8 chunk is used, and thus 1/64th the total image can be read on the first pass.  On the second pass 1/64th again is read in, on the third 1/32nd, the fourth 1/16th, the fifth 1/8th, the sixth 1/4th, and finally on the last pass, 1/2 of the total image is read in  For a great explanation of the entire process see the PNG home page listed below.

Where to get More Information on PNG

CompuServe:	The library of the Graphics Support Forum (GO GRAPHS)

Internet:	http://quest.jpl.nasa.gov/PNG/  (PNG home page)


topic, ImageKnife and Visual C++
ImageKnife Help

Compatibility

Implementing ImageKnife in Visual C++ 4.0

You can easily use Microsoft Visual C++ (32-bit versions 4.0 and higher) as a container for ImageKnife.  OCX controls may be added to any C++ dialog in your application.

Step 1: Add OLE control support to your application.

Your C++ application must have OLE control support.  When you use the MSVC AppWizard to generate your application, one of the dialogs asks you the question "What OLE support would you like to include?".  You should check the "OLE controls" checkbox.  If you are adding an OCX to an application you have already created you can add OLE control support with the "OLE Control Containment" Component Wizard found in the Microsoft section (tab) of the Component Gallery.

Step 2: Add ImageKnife support to your application.

To add ImageKnife support into your application, you use the Microsoft Component Gallery (from the "Insert / Component..." menu entry).  From the "OLE Controls" tab of the Component Gallery locate and select the "ImageKnife Control" icon.  Choose the "Insert button".

The file Picbuf.cpp and Picbuf.h are added to your project to make calling ImageKnife methods and getting or setting ImageKnife properties easy.

The class "CPicbuf" is defined in these files.  This class defines Set and Get routines for each ImageKnife property, as well as a routine for each ImageKnife method.  These routines are what you use to set property values, retrieve property values, or call ImageKnife methods.

The ImageKnife icon is added to the Controls toolbar in the MSVC resource editor.

Step 3: Add an instance of ImageKnife to your application.

Use the resource editor to add a ImageKnife object to one of your dialogs.  The ImageKnife icon can be drawn at the location you want the image to appear.  The size of the window will be determined by a series of properties.

Step 4: Set design-time properties using property pages.

Most properties of a ImageKnife control may be set at design time.  The ImageKnife control has a number of tabbed property pages to allow you to set these properties.

•	General	AppStudio specific

•	Control	Generalized control properties

•	IO	Input & Output properties

•	Select	Selection Area properties

•	View	Viewing Attribute properties

•	Drawing	Drawing Attribute properties

•	Text	Text Attribute properties

•	Fonts	Fonts Attribute properties

•	Colors	Color Attribute properties

•	All	All properties

The more properties you set at design-time via the property pages, the less C++ code you will have to write.  Accessing the ImageKnife property pages (make sure that the ImageKnife window has the focus) can be done by one of 2 methods:

•	double clicking the left mouse on the ImageKnife control

•	clicking the right mouse button and selecting the "Properties/ImageKnife Control Object->Properties" menu entry.

Lets see how easy it is to display an image.  ImageKnife has an enumerated type  property “AutoLoad” that controls the display of images at both design and run time.  By setting this property to “1 - File” and setting the “Filename” property to a location that contains an image, ImageKnife will open that file and display it in AppStudio and at run time when the dialog box is displayed.

•	Go to the “View” tab

•	Set “AutoLoad” to 1

•	Go to the IO tab

•	Select the “Browse” button

•	Select a file to display.

The image appears in the window.  You can set many other properties such as “AutoScale”, “AutoSize”, MousePointer ........

Step 5: Set the run-time behavior of ImageKnife.

You may want to change the value of a property at a user's request, or based upon some dynamically determined condition.  For this reason, properties may be queried or set at run time.  Also, much of ImageKnife's behavior is determined by methods (image processing, drawing, ....) which must be called at run-time.  Any property you can set or view on the property page may also be read or set at runtime via C++ code.  Event handling is also done by C++ runtime code you write.

To call methods or properties on the ImageKnife object, you need access to an instance of the CPicbuf class object created earlier.  You can do this via pointer to a dialog item, or by creating a member variable of type CPicbuf.  Note the different syntax for pointer references ("->") and for member variables (".").  You only need to use one of these approaches (pointer or member variable); whichever works best for you.

To get a pointer to the control you placed on a dialog, you can use the GetDlgItem() function call as follows:

// Get a pointer to the picbuf control on this dialog:

CPicbuf *CPicBuf = (CPicbuf *)GetDlgItem(IDC_PICBUF1);

// Use the pointer to set a property:

// Turn Scrollbars on both horizontally & vertically

CPicBuf->SetScrollbars(SBBOTH);

To create a member variable, invoke the Class Wizard and choose the "Member Variables" tab.  Choose the ID which represents the ImageKnife control (such as IDC_PICBUF1), then click the "Add Variable" button.  Make sure that the category is "Control".  Name the variable anything you like, such as "m_Picbuf".  You use this variable to access the control:

// Use the member variable to set a property:

m_Picbuf.SetAutoScale(TRUE);

NOTE: you must include "Picbuf.h" into the file where you create the member variable.

To retrieve information about an ImageKnife control from C++ code, use the pointer or member variable you got from above as in the following example:

long nNumColors = pPicbuf->GetColorCount();

To set a property, you make similar calls:

pPicbuf->SetFilename("bambi.bmp");

To call a method, you make similar calls:

pPicbuf->Soften(5);

Some methods take arguments of type "VARIANT".  These arguments are structures that give type information as well as a value.  When you pass a variant, you must specify the data type along with the data value.  One possible data type of a variant  is used to represent optional parameters.  Some methods take optional parameters to perform some default action.

// To create an integer parameter for a method:

VARIANT ip = COleVariant (1, VT_I2);

// Which is equivalent to

VARIANT ip;

ip.vt = VT_I2;

ip.iVal = 1;

// To create an optional parameter for a method:

VARIANT opt;

opt.vt = VT_ERROR;

// To invoke the CopyClipboard method and use

// the optional parameter to specify using the

// SelectLeft, SelectTop

// SelectWidth, SelectHeight values

// to determine what part of the image to copy

// to the Clipboard

VARIANT option;

option.vt = VT_ERROR;

option.iVal = 0;

pPicbuf->CopyClipboard(option);

OCX Events (notifications) are set up via the MSVC Class Wizard.  Use the "Message Maps" tab and select the class and object ID corresponding to you ImageKnife control.  The "Messages" list box will show you all the events you can respond to.  The messages "Signal", "Notify", "MouseDown", and "KeyPress" are examples.  When you select one of these messages to catch, a code stub is generated (such as "OnSignal").  You add code that responds to this event in that stub routine.

To find the location of sample code for VC++ see the Sample Code section of this document


topic, Installation/Uninstallation
ImageKnife Help

Installation/Uninstallation

Installation of ImageKnife is initiated by running setup.exe from the first disk in a disk set (or from a directory containing the installation file(s) in the case of downloaded software.) By default, all Media Architects' products are installed onto the hard drive under a common directory named “MediArch”. Unless you change the destination directory during installation, each major version of product creates its own directory under this common directory. All files and directories created by our install programs are placed under this product level directory.

Installation programs for ImageKnife will only work on Windows 95 and Windows NT.

To unistall ImageKnife simply run the Uninstall program located in ImageKnife’s directory.  Under Windows 95 or Windows NT, the Add/Remove program option in the Windows Control Panel is also available.

Occasionally, the need arises when a Media Architects product must be installed by hand.  This is the proper method for installing 32 bit OLE controls (ImageKnife in particular):

Be sure you have all required files in the appropriate locations.   This includes the IK32.OCX,  IK32.LIC file, and any run time files which may be needed.  Unless otherwise notified, all of MAI’s 32 bit OLE controls require MFC40.DLL and MSVCRT40.DLL to be in the \Windows\System Directory.  The OLE controls may be in any directory, so long as the license file is also in the same directory.   If to be used, the help file should be in the same directory as the OCX.

Register the controls.  OCX controls need to be registered with the System before they can be used.  Ordinarily, the install program would take care of  this, but it can be done manually.  The applications RegSvr32.exe and RegSur.exe are shipped with ImageKnife (and other MAI 32 bit controls.) To register an OCX, simply drag it onto the appropriate tool (RegSvr32.exe for IK32.ocx or RegSvr.exe for IK16.ocx) and drop.  From a command line, run either RegSvr32 ocx32.ocx or RegSvr IK16.ocx.  (To  un-register ImageKnifef/OCX, run either RegSvr32 /u IK32.OCX or RegSvr IK16.ocx)

GO.  ImageKnife should now be registered.  If any error messages come up from the Registration, be sure to check the file locations.  If you’re still having problems, MAI Technical Support maintains a list of common registration problems in their list of Frequently Asked Questions, available from our Online locations.  Check this before contacting MAI Technical Support, if possible.

See “Files You Need to Distribute” for requirements for distributing and installing a product that utilizes our development components.


topic, Intersection Composite (AssignMode 2)
ImageKnife Help

Assignment

AssignMode 2 -- Intersection Composite

Here are examples of each of the possible assignment operations:

Smaller image or selection area  to larger image

Larger image or selection area  to smaller image


topic, License Agreement
ImageKnife Help

License Agreement

Media Architects and its licensers grant a license to use the accompanying software (“Software”) and printed material (collectively referred to as the “Product”) to you, the original purchaser. This is a binding Agreement between you and Media Architects. If you do not agree to the provisions of this Agreement, then promptly return the Product and all accompanying items to the place you obtained them for a full refund. Use of the Product shall constitute your acceptance and agreement to this Agreement. Only two (2) copies of the Product may be made and used only for back-up purposes. The copying of the Product for any other purpose is strictly prohibited and adherence to this requirement is your sole responsibility. This license may be transferred to a third party only if the third party agrees to be bound by the terms of this License Agreement and all existing copies of the Product are also transferred.

The Software is owned by Media Architects or its licensers and is protected by United States copyright, patent, trademark and other intellectual property laws and international copyright, patent, trademark, and intellectual property laws and treaty provisions.  All rights, titles and interests are reserved by Media Architects and its licensers.  The licensers of Media Architects are intended beneficiaries of this Agreement and are entitled to enforce the provisions of this Agreement.

You may install the Software on more than one computer as long as there is no reasonable possibility that the Software will be used on more than one computer at the same time. This restriction extends to installation on a network server, if more than one workstation will be accessing the Software. The Software shall not be used in a service bureau or time-sharing facility.  You shall not disassemble, de-compile, reverse engineer, lend, rent, lease sublicense or pledge the Software.

Media Architects grants you a royalty-free right to reproduce and distribute the run-time modules of the Software provided that you:  (a) distribute the run-time modules only in conjunction with and as part of your own software product;  (b) all copies of this Software bear a valid copyright notice. By copyright notice, Media Architects means either your own copyright notice or a copyright notice which is identical to those written on the diskettes containing this Software and/or as appears in the "About" display. You may not give away, sell or distribute any original or derivative product created with the Product which substantially duplicates the Product in appearance, function or design.  Utilities/editors supplied as part of the Product are licensed only for use by the original purchaser and may not be distributed in any way under this license agreement.

Some portions of the Product have been developed with the use of technology and materials sold or licensed to Media Architects by other parties. Provisions in sale and licensing agreements for such technology and materials which impose restrictions on use of the Product and any portion of the Product are attached to this License Agreement as Exhibit A.

By accepting the Product you agree to be bound by the terms set out in this License Agreement and Exhibit A. To the extent that any of the terms of this License Agreement conflict with the terms set out in Exhibit A, Exhibit A shall control.

You further agree to indemnify, defend and hold Media Architects, its officers, agents, licensers and employees, harmless against all liens, claims, actions, suits, expenses (including attorneys’ fees), damages and liabilities arising or growing out of any breach by you of this License Agreement or Exhibit A.

The licenses granted in this License and all of your rights to use or maintain possession of the Software shall terminate immediately upon breach of any material provision of this Agreement.

This License Agreement shall be governed and construed by the substantive, but not the conflict laws of the State of Oregon, United States of America. The rights and obligations of the parties under this License Agreement shall not be governed by the U.N. Convention on Contracts for the International Sale of Goods.

US GOVERNMENT RESTRICTED RIGHTS

The Software Program and documentation are provided with RESTRICTED RIGHTS. Use, duplication or disclosure by the Government is subject to restrictions as set forth in subparagraph (c)(1) of the Rights of Technical Data and Computer Software - Restricted Rights at 48 CFR 52.227-19 of FAR, or Clause 18-52.227-86(d) of NASA Supplement to the FAR, as applicable.  Contractor/manufacturer is Media Architects, Inc., 7320 SW Hunziker Road, Suite 305, Portland, OR 97223.

EXHIBIT A

ADDITIONAL TERMS

You shall not:

1.	remove any licensing or intellectual property notices from the Product

2.	use more than a single copy of the Product at a single site for each license purchased

3.	use any component of the Product upon which restrictions are imposed, to develop any software, unless you have first entered into a license agreement, as may be required, with the party whose technology is being used.

4.	use Iterated Systems’ Fractal Transform technology other than in connection with single user computers. IN NO EVENT WILL THE SOFTWARE BE USED IN THE DEVELOPMENT, INTEGRATION, MARKETING OR DISTRIBUTION OF TELECOMMUNICATIONS APPLICATIONS WITHOUT THE PRIOR WRITTEN CONSENT OF ITERATED SYSTEMS INC. Please call Iterated Systems, Inc. at 404-264-8000 or fax at 404-264-8300.

5.	modify the Product, except as is necessary for use at a single site

6.	copy the Product, or any portion of the Product, except for backup or archival purposes.

You shall also take reasonable steps to protect the Product from unauthorized copying, disclosure, or distribution, including instructing employees and consultants as the restrictions set forth in this Exhibit.

Exhibit A applies specifically to:

GIF-LZW and TIFF-LZW capability which is patented by Unisys under U.S. Patent Number 4,558,302 and foreign counterparts

Fractal Transform image compression technology by Iterated Systems, Norcross, Georgia, portions of which are protected by U.S. Patent Numbers 5,065,447 and 5,347,600 and Australian Patent Number 623,333.  Other patents pending.

LIMITED WARRANTY

Media Architects warrants that the Product will perform as described in the documentation. In the event that it does not meet the terms of this warranty, Media Architects will replace the product or refund the amount paid (less shipping and handling charges) if notified within 90 day of purchase.  The original software and documentation must be returned accompanied by a return merchandise authorization (RMA) number. Media Architects’ liability is limited to the purchase price. Under no circumstances shall Media Architects, its licensers or contractors be liable for any indirect, incidental, consequential or exemplary damages arising from use, or inability to use, Software, even if they knew of the possibility of such damages.

The software contains portions of program code owned by Iterated Systems, Inc. and is provided under license to Media Architects by Iterated Systems, Inc. ITERATED SYSTEMS, INC. DISCLAIMS ALL WARRANTIES WITH RESPECT TO THE USE OF SUCH CODE IN THE SOFTWARE, INCLUDING (WITHOUT LIMITATION) ANY WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. In no event shall Iterated Systems, Inc. be liable for indirect, incidental, consequential or exemplary damages arising from use, or inability to use Software, even if they knew of the possibility of such damages. LIABILITY OF ITERATED SYSTEMS, INC. FOR DIRECT DAMAGES SHALL NOT EXCEED THE ACTUAL AMOUNT PAID FOR THE PRODUCT.


topic, Loading Images
ImageKnife Help

The PicBuf Control

Loading Images

ImageKnife supplies a method called Load for loading images into PicBuf controls. It handles a variety of image formats, including TIF, BMP, and PCX, among others. The following is an example of its use:

PicBuf1.FileName = "c:\images\dragon.tif"

PicBuf1.Load

If you were, for some reason, to use the Picture property, then the standard Visual Basic LoadPicture method can also be used:

PicBuf1.Picture = LoadPicture "c:\images\party.bmp"


topic, Other Controls
ImageKnife Help

Compression Formats

Compression Formats supported by ImageKnife

ImageKnife can read and write images in two compressed formats: GIF (you must now register with Unisys to make use of the GIF file format) and, JPEG.

For 1-, 4-, and 8-bit images, GIF is an ideal way to store them in a database. The compression and decompression time is minimal and there is no loss in image quality, yet you can typically achieve 50% compression.

For large 24-bit images, JPEG is an excellent way to save space. The tight compression provided by JPEG comes at a price,  as it is very computation intensive. It is also not suitable for images that will need to be edited and re-saved, as it is a "lossy" compression scheme and the data losses will accumulate into visible artifacts with continued re-saving. See Appendix A for more information about JPEG.


topic, Performance Issues
ImageKnife Help

Advanced Issues

Performance issues

Our JPEG code does not use any floating point math, so a math co-processor will not speed up JPEG compression or decompression. Pretty much the only way to speed up the compression or decompression of JPEG images in software is to get a faster machine, more RAM so that Windows swaps to disk less often, and/or a faster disk drive to speed up reads and writes during swapping. The fastest JPEG performance will come from using a JPEG board that handles the compression and decompression at the hardware level. At this time, ImageKnife has no support for JPEG boards.


topic, PicBuf Assignment Capabilities
ImageKnife Help

Basic Structure

PicBuf Assignment Capabilities

You can accomplish a number of useful image manipulations using only PicBuf controls and their properties in assignment methods. Among these are the following:

♦	Transfer of entire images between PicBuf controls.

♦	Transfer of source images into selected portions of destination images (compositing).

♦	Resizing of source and/or destination images to obtain desired results.

The logical range of possibilities for image assignment between PicBuf controls is shown below:

'full source image to full destination image

PicBufDest.Assign False,PicBufSrc,False

'full source image to destination selection

PicBufDest.Assign True,PicBufSrc,False

'source selection to full destination image

PicBufDest.Assign False,PicBufSrc,True

' source selection to destination selection

PicBufDest.Assign True,PicBufSrc,True

You can use the SelectTop, SelectLeft, SelectHeight, and SelectWidth properties and the destination/source selection flags within assignment methods to isolate an area to be used in an operation. If the selected area is in the source, only that area is used in the operation as the source image-- the rest of the image is not considered as part of the source. If the selected area is in the destination, that area is the only area of the destination image that is allowed to change.


topic, PicBufs and the Form
ImageKnife

The PicBuf Control

PicBufs and the Form

Like any control, you can place PicBuf controls on forms simply by selecting the control icon and drawing them on with the mouse. Each time you do so, you create an instance of the control, and you can make such a collection of PicBufs into a control array by setting their Name properties the same.

PicBuf controls can also be created at run time via the Load method, for example:

Load PicBuf(1)

To load a control in this manner, at least one identically named instance of the control type must already be present on the form.

Once controls are loaded into a form, they can be used in assignment methods such as

PicBuf2.Assign False,PicBuf1,False

which transfers the full bit depth image in PicBuf1 into PicBuf2.

Controls can also be used in the following manner:

PicBuf1.BrightCont 0.6,0.6

The previous line of code increases the contrast and brightness of an entire PicBuf image by 20%.

A useful feature of PicBuf controls is that they can be kept invisible until they contain exactly what you want to display by setting the Visible property to false. They can then be made visible once again by setting the Visible property back to true, like this:

PicBuf1.Visible = False

PicBuf1.Negate

PicBuf1.Rotate 45

PicBuf1.Visible = true


topic, Printing with ImageKnife
ImageKnife Help

Printing Compatibility

ImageKnife allows images to be printed at any size and at any location on the printed page, and merged with any other information printable using the Printer object. The properties PrintLeft, PrintTop, PrintHeight and PrintWidth specify the placement of the image on the page in printer pixels. So for a 300 dpi printer, setting PrintWidth to 300 will always produce an image one inch wide on the printer.

An image is transferred to the printer when the PrinterhDC property is set from the Printer object. This example prints an image mixed with text on the page when the user clicks a button.  (Note, this is a Visual Basic code example).

Sub Command_Click ()

  Printer.ScaleMode = 3  ' set to pixels

  Printer.Print ""  ' Initialize the printer

  ' Place text at the top of the page

  Printer.Print "This is the text I wish to print."

  ' Place 6.5 inch wide image one inch down and one

  ' inch over on an 8.5 inch wide, 300 dpi page.

  PicBuf1.PrintLeft = 300

  PicBuf1.PrintTop = 300

  PicBuf1.PrintWidth = 1950  ' 300 * 6.5 = 1950

  PicBuf1.PrintHeight = 1950.0 * PicBuf1.Yresolution / PicBuf1.Xresolution

  ' Print it

  PicBuf1.PrinterhDC = Printer.hDC

  Printer.EndDoc

End Sub


topic, Property Settings
ImageKnife

Drawing Methods

Property Settings

Property Settings for Fill Areas

The following settings apply to the Chord, Pie, Polygon, Rect, and RoundRect methods.   The outline of the shapes is determined by the property settings for lines.(see below).

FillStyle	FillTransparent	FillColor	BackColor	Result
0	ignored	USE	ignored
1	ignored	ignored	ignored
2-7 (4 shown)	0	USE	USE
2-7 (4 shown)	1	USE	ignored
Property Settings for Lines

The following settings apply to all draw methods:

DrawStyle	FillTransparent	ForeColor	BackColor	Result
0	ignored	USE	ignored
1-4, 6	0	USE	USE
1-4, 6	1	USE	ignored
5	ignored	ignored	ignored
CAUTION:

Do not use DrawStyle = 5 (transparent) with Arc or PolyLine.  Do not use DrawStyle = 5 (transparent) in combination with FillStyle = 1 (transparent).  Attempting to do so will generate an error.

If you use DrawStyle = 5 (transparent) with Chord, Pie, Polygon, Rect, or RoundRect,
the FillStyle must be 0 or 2-7.


topic, Registration
ImageKnife Help

Registration

ImageKnife Registration Form

If you did not buy this product directly from Media Architects, please send this card in to register your copy. This makes you eligible for support and will let us keep you informed of updates, new products and special offers. As an added benefit, this registration will get you entered in our monthly drawing to win a cool Media Architects T-shirt!

Please send this card to Media Architects via:

Fax:	503-620-5451

Internet:	support@mediarch.com

CompuServe:	74774,707

Mail:	Media Architects, Inc.

7320 SW Hunziker Rd. Suite 305

Portland, OR 97223

USA

Name:	_________________________________________________________________

Company;	_________________________________________________________________

Address:	_________________________________________________________________

_________________________________________________________________

_________________________________________________________________

Phone:	____________________	Fax:	__________________________

Email:	_______________________________________________

Serial Number (from disk 1):     _____________________

Where did you purchase this product?	___________________________________

Date Purchased?	________________________	Purchase Price?	_____________

• Please send me information about an Annual Support Agreement.


topic, Resize Composite (AssignMode 3, ResizeMode 0 or 2)
ImageKnife Help

Assignment

AssignMode 3, ResizeMode 0 or 2 -- Resize Composite

Here are examples of each of the possible assignment operations:

Smaller image or selection area to larger image

Larger image or selection area to smaller image

AssignMode 3, ResizeMode 1 or 3 -- Resize Composite

Here is an example of an assignment operation:

Larger image or selection area to smaller image


topic, Resize Composite (AssignMode 3, ResizeMode 1 or 3)
ImageKnife Help

Assignment

AssignMode 3, ResizeMode 0 or 2 -- Resize Composite

Here are examples of each of the possible assignment operations:

Smaller image or selection area to larger image

Larger image or selection area to smaller image

AssignMode 3, ResizeMode 1 or 3 -- Resize Composite

Here is an example of an assignment operation:

Larger image or selection area to smaller image


topic, Sample Code
ImageKnife Help

Sample Code Projects

Sample coded projects for Visual Basic,  Delphi 2 are installed to \MEDIARCH\IK32\SAMPLES\VB4  and \MEDIARH\IK32\SAMPLES\DELPHI2 ; the locations are default ones unless the default path was changed during setup.  Sample images are installed to \MEDIARCH\IK32\SAMPLES\IMAGES.  For the latest sample projects see our Web Site, BBS and CompuServe forum.

The following table contains a list of available sample projects (applications), and the properties, events and methods that each one of them cover.  The sample project for your selected Property, Event, or Method should appear at the top of the table below.  In some cases you may find that more than one sample project contains the control that you are interested in.  At the smae time, this tabulated list is not complete, and a specific sample-project for your selected method, event or property may not exist.

Project	        Properties	Events	Methods

Assign	AssignMode, ResizeMode		Assign
Brt&Cont			BrightCont,Gamma
Colrep	ColorDepth,ScreenToImageX, ScreenToImageY,XResolution, YResolution		ColorReplace,SetPalColor
Cutpast	Width, Height, XResolution, YResolution		PasteClipboard, CopyClipboard, CopySelection, PasteSelection
Draw	BackColor,DrawArrows, DrawStyle,DrawWidth, FillColor,FillStyle, FillTransparent, ForeColor		Arc, Chord, Pie, Polygon, PolyLine, Rect, RoundRect, TextDraw, TextHigh, TextWide
GetPutLn			GetScanLine, PutScanLine
Greyneg			Mirror,Rotate,GrayScale,Negate
Info	XResolution,YResolution, ColorDepth	Change	GetPalColor,GetPalIndex,GetColor
iodib	hDib		DuplicateDib, ImportDib, ExportDib
Mask	XResolution,YResolution		MaskCopy,PutScanLine,Init
Load	Filename,  ImageNumber, ImageFormat	Callback	Load, LoadCallback
Matrix			Soften,Sharpen,ExtractEdges,Blur,MatrixFilter
Optim			OptimizePal,ReMapPal,DitherPal
Palette	hPalette,ColorDepth	Palette	LoadPal,StorePal,AddSystemColors
Pan		Pan
Picture	Picture		DibToBitmap,BitMapToDib
Print	PrintTop, PrintWidth, PrintLeft, PrintHeight PrinterhDC
PutCol	ScreenToImageX&Y, X&YResolutions		PutColor,GetColor
ScanLn	Xresolution, Yresolution		GetScanLine, PutScanLine
Srcap	hDC
Store	Filename, ImageFormat, WriteCompression		Store
Rubber	SelectLeft, SelectTop, SelectWidth, SelectHeight, PrintLeft, PrintTop, PrintWidth, PrintHeight		RegionRb


topic, Size Control in PicBuf Assignments
ImageKnife Help

PicBuf Assignment Capabilities

Size Control in PicBuf Assignments

The first question you might ask in PicBuf assignments is "what if the images or selected areas are different sizes?" How ImageKnife handles these common cases is key to its power in image manipulation. You, as the programmer, have complete control over how size differences are handled. The following list shows the possibilities:

♦	Source image can be resized to fit the destination.

♦	Source image can be cropped to fit the destination.

♦	Destination image can be resized to fit the source.

Note	When making assignment methods with ImageKnife, be aware that both images in the assignment method must have the same bit depth.

The values of the AssignMode and ResizeMode properties in the destination PicBuf indicate how transfers of images are conducted in assignment methods. AssignMode determines whether resizing is employed in the transfer, as follows:

AssignMode	Assignment Method
AM_TOTALREPLACEMENT	Total Replacement; destination image is resized to fit the source image.
AM_UNIONCOMPOSITE	Union Composite; source image is placed over destination and destination is enlarged if neccessary to accomodate the union of bpth images.
AM_INTERSECTIONCOMPOSITE	Intersection Composite;  source image is placed over the destination, but both images are forced to remain the same size.
AM_RESIZECOMPOSITE	Resize Composite;  Source image is resized as neccessary to fit destination image, which is held to its current size.
Note A	Before you use Assign to make an assignment, make sure that the destination PicBuf already contains an image.  To do this, use Init, Load, or any other method that fills a PicBuf image.

Note B	 the AssignMode property of the destination is non-zero and the image involved contains 256 or fewer colors (i.e. if they have palettes), you should take steps to ensure that bizarre palette shifts do not occur. Although ImageKnife can composite two images together, it cannot composite two palettes together. Instead, the palette of the destination PicBuf does not change (i.e. the palette of the source PicBuf is ignored). The easiest way around this problem is to remap all of the images to the same palette.


topic, Summary of Assignment Capabilities
ImageKnife Help

PicBuf Assignment Capabilities

Summary of Assignment Capabilities

The ability to work with either full images or selected portions, to control how image transfer/compositing is done relative to resizing, and to control source and destination image alignment results in an extremely flexible system for image handling that goes hand-in-hand with the extensive array of methods in ImageKnife. Within the limitations that image areas must be rectangular, and that image overlays are complete (i.e. without variable opacity), simple assignments are capable of most operations you will need to construct resultant images from multiple sources.

Consider also that using assignments in series or in loops, very involved compositing of multiple sources onto a single destination can be achieved. For example, creating a set of images that contain thumbnail-sized versions of a number of other images on a background can be done in a single-nested loop consisting of a few assignment methods

When you need to combine images without the limitation of rectangular source and destination shapes or if variable opacity is needed, refer to the MaskCopy method.


topic, The PicBuf Control
ImageKnife Help

Basic Structure

The PicBuf Control

The central component of ImageKnife is a control called the PicBuf, short for "picture buffer." The PicBuf control is similar in concept to the Visual Basic Picture Box control, but it has a number of additional properties associated with it that support the extensive library of image handling and processing methods supplied with ImageKnife. Also, the PicBuf control supports a number of useful capabilities directly through assignment methods, an approach that is uniquely intuitive and powerful.

With some exceptions, you can think of the PicBuf control as a superset of the Picture Box control. For example, like Picture Box controls, PicBuf controls contain image data, but unlike Picture Box controls, the image data is not limited to the current bit depth of the screen (as determined by the current screen graphics mode). Also, image data can be transferred from one PicBuf control to another, but in addition PicBufs can transfer a selected portion of an image into a selected portion of another in a simple assignment method. This process, important in image handling, is called compositing.

For compatibility purposes, PicBuf controls can exchange image data with Visual Basic Picture Box controls. This allows you to capitalize on the best features of both, while minimizing impact to your current applications. The exchange, however, is limited to the current color bit depth of the screen.


topic, Total Replacement (AssignMode 0)
ImageKnife Help

Assignment

AssignMode -- AM_Total Replacement

Here are examples of each of the possible assignment operations:

Smaller control image or selection area to larger control image

Larger control image or selection area to smaller selection area

Smaller control image or selection area to larger selection area


topic, Union Composite (AssignMode 1)
ImageKnife Help

Assignment

AssignMode -- AM Union Composite

Here are examples of each of the possible assignment operations:

Smaller image or selection area to larger image

Larger image or selection area to smaller image

Smaller image or selection area to larger selection area

Larger image or selection area to smaller selection area


topic, Using DIBs Created in other Applications
ImageKnife Help

Exchanging Images Directly with other Applications

Using DIBs Created in Other Applications

The ImageKnife PicBuf control internally uses a Microsoft Device Independent Bitmap (or DIB) to store an image.  Many third-party libraries and applications (such as Kodak’s PhotoCD Developer’s Kit) allow you to obtain a memory handle to a DIB, known as an hDib.  This handle provides a simple way of passing pictures between applications, and is actually the way many bitmaps are stored on the Windows clipboard.

The ImageKnife control's image is actually an hDib.  The PicBuf control can be made to use an external hDib with this simple assignment:

' Use with caution!

PicBuf.hDib = MyhDib

Although simple, this assignment may not be all you need. Dibs are allocated in Windows memory.  When an application prepares to create a DIB (whether from scratch or by reading it from a disk file), it allocates enough memory to hold the image and its associated parameters (such as the palette, the dimensions, and so forth).  This memory is said to be "owned" by the application which allocated it.  When an application is done with the memory it de-allocates (or frees) the memory which it "owns."

ImageKnife does not own the memory for any image that is assigned to the hDib property.  It does, however, use that memory.  If the application that created an hDib frees the memory after the image has been assigned to a PicBuf control, the PicBuf control will now have a handle to an image which no longer exists.  Soon your machine will crash, or produce error messages.

To free the memory owned by the application, the PicBuf hDib property must first be assigned zero.  The memory associated with the hDib can then be freed.  Here’s an example of how you might import a DIB into ImageKnife and then get ImageKnife to own that memory:

‘PicBuf1 & temp = ImageKnife controls

temp.hdib = hdib

PicBuf1.Assign FALSE, temp, FALSE

GlobalFree( hdib )   ‘ removes hdib, now in IK

temp.clear


topic, Using ImageKnife DIBs in Other Applications
ImageKnife Help

Exchanging Images Directly with other Applications

Using ImageKnife Dibs in Other Applications

Dibs from ImageKnife can be sent to other applications by using DuplicateDib to duplicate the internal image or selection area of a control:

myHDib = PicBuf.DuplicateDib False ‘ duplicate full image

When the application is done with the memory returned by DuplicateDib, it must de-allocate (or free) that memory.


topic, Verifying the Validity of DIBs
ImageKnife Help

Exchanging Images Directly with other Applications

Verifying the Validity of Dibs

Passing handles to Dibs between ImageKnife and other applications can be dangerous to debug.  If an invalid hDib is passed, Windows can crash, losing valuable changes you may have made to your code.  To prevent such problems, ImageKnife includes a method to validate an hDib before it is assigned to anything.  This method could save you hours of time, and we highly recommend that you use it while bringing up your application.  Once stable, you may want to remove these calls, although they take very little time, and can just as easily remain.

Here’s how you might want to use it in your code:

On ERROR Resume

' Verify an external hDib

If myHDib.Verify = 0

Then

  MsgBox "DIB is valid"

  PicBuf.hDib = myHDib

Else

  MsgBox "ERROR: DIB is invalid!"

End If


topic, Visual Basic 4.0  Object Browser
ImageKnife Help

Using ImageKnife with Visual Basic 4.0 Object Browser

Visual Basic 4.0 now comes with a powerful feature called the Object Browser.  This allows you to look at controls that you have loaded into your project and see what properties and methods it supports.  Parameters are also defined in terms of enumerated types.

To use the Visual Basic Object Browser, do the following:

♦	Choose View...Object Browser from the Visual Basic menu.

♦	Under Libraries/Projects, choose “ik32Lib-Media Architects ImageKnife Control”

Now, the Object Browser can give you detailed information about the ImageKnife control.  Under Classes/Modules are listed all the enumerated type values valid for ImageKnife’s properties and methods.  Note that the property names are all preceded with “enum”.  For example by clicking on enumScrollBars gives you the following list in the Methods/Properties section “SBBOTH, SBHorizontal, SBNone, SBVertical”.  So, if you were setting the ScrollBars property in your code, you could go to the Object Browser and select from one of the scrollbars enumerated types, making your code more readable and never having to crack open a book or go to the on-line help system.

The ImageKnife PicBuf itself is also listed under Classes/Modules in the Object Browser.  Once PicBuf is selected, all of its properties and methods can be viewed.  This is helpful since you see exactly how many parameters are required and the data types required by the methods.

Currently, if you paste in the code for a method into your Visual Basic app, it will give you the following syntax (using Init method as an example):

Init nDepth:=, nWidth:=, nHeignt:=, nColor:=

Modify what is pasted in to the following:

Picbuf1.Init 8, 640, 480, 256

You must replace the variables that object browser puts in with your own variables or values.  ImageKnife does NOT currently support Named Arguments, such as nDepth:=5, nWidth:=6, etc.


topic, What Are Good "Quality" Settings for JPEG?
ImageKnife Help

ImageKnife and JPEG

What are good "quality" settings for JPEG?

The name of the game in using JPEG is to pick the lowest quality setting (smallest file size) that decompresses into an image indistinguishable from the original. This setting will vary from one image to another and from one observer to another, but here are some rules of thumb.

A quality setting of 75 is very often the best choice. This setting is about the lowest you can go without expecting to see defects in a typical image. Try quality 75 first; if you see defects, then go up.

If the image was less than perfect quality to begin with, you might be able to go down to quality 50 without objectionable degradation. On the other hand, you might need to go to a higher quality setting to avoid further degradation. The second case seems to apply much of the time when converting GIFs to JPEG. Quality 75 is about right for compressing 24-bit images, but quality 85 to 95 is usually better for converting GIFs.

If you want a very small file (say for preview or indexing purposes) and are prepared to tolerate large defects, a quality setting in the range of 5 to 10 is about right. It should be noted that not all JPEG decompressors can handle a quality setting below 25.


topic, What Are the Rules of Thumb for Converting to JPEG?
ImageKnife Help

Advanced Issues

What are some rules of thumb for converting palettized images to JPEG?

As stated earlier, you will lose some amount of image information if you convert an existing palettized image to JPEG. If you can obtain the original True Color data the GIF was made from (such as a 24-bit BMP file), it’s far better to make a JPEG from that. But if you need to save space and have only the palettized version to work from, here are some suggestions for getting maximum space savings with minimum loss of quality.

The first rule when converting a palettized image library is to look at each JPEG, to make sure you are happy with it, before throwing away the corresponding palettized file; that will give you a chance to re-do the conversion with a higher quality setting if necessary. Some palettized images may be better left alone; in particular, cartoon-type images with sixteen or fewer colors don’t convert well. You may find that a reasonable quality JPEG file will be larger than the original palettized image, so check the sizes, too.

Experience to date suggests that large, high-visual-quality images are the best candidates for conversion to JPEG. They chew up the most storage so offer the most potential savings, and they convert to JPEG with least degradation. Don’t waste your time converting any image much under 100 K, especially if it is a GIF. Also, don’t expect JPEG files converted from palettized images to be as small as those created directly from True Color originals. To maintain image quality you may have to let the converted files be as much as twice as big as straight-through JPEG files would be (i.e., shoot for 1/2 or 1/3 the size of the original file, not 1/4 as suggested in earlier comparisons).

Many people have developed an odd habit of putting a large constant-color border around an image. While useless, this was nearly free in terms of storage cost in GIF files. It is not free in JPEG files, and the sharp border boundary can create visible artifacts ("ghost" edges). Do yourself a favor and crop off any border before JPEGing. Use of ImageKnife’s assignment capabilities will make this easy. A quality setting of 75 is appropriate for True Color input, but for GIF inputs, quality settings of 85 to 95 often seem to be necessary to avoid image degradation.

Color palettized images of photographs or complex artwork are often "dithered" to fool your eye into seeing more than the 256 colors that GIF can actually store. If you enlarge the image, you will see that adjacent pixels are often of significantly different colors; at normal size the eye averages these pixels together to produce the illusion of an intermediate color value. The trouble with dithering is that, to JPEG, it looks like high-spatial-frequency color noise; and JPEG can’t compress noise very well. The resulting JPEG file is both larger and of lower image quality than what you would have gotten from JPEGing the original full color image (if you had it). To get around this, you want to "soften" the image before compression. Softening averages together nearby pixels, thus approximating the color that you thought you saw anyway, and in the process getting rid of the rapid color changes that give JPEG trouble. Appropriate use of softening will often let you avoid using a high Q factor, thus further reducing the size of the compressed file, while still obtaining a better-looking output image than you’d get without softening.

You can use the Soften and IncreaseColors methods to help with this problem. First, use IncreaseColors to increase the color depth of the image to 24 bits. Now try using Soften with a softness of 2 or 3 when converting GIFs. Heavy-handed dithering may require larger softening factors. (If you can see regular fish-scale patterns on the GIF image even without enlargement, then strong softening is definitely called for.) Too large a softening factor will blur the output image, which you don’t want.


topic, What Can ImageKnife Do with Palettes?
ImageKnife Help

A Palette Primer

What can ImageKnife do with palettes?

ImageKnife includes a wide range of methods to deal with correct display of images on 4-, 8-, 15/16-bit and 24-bit displays.  They can be combined in a variety of ways to meet your particular needs.  This overview section gives some guidance for how the methods can best be used.

Common problems that can be solved with ImageKnife’s color methods:

Reduce True Color/High Color images to palettized images for display on 256- or 16-color cards:  Use the ReduceColors method.  (If you want to store images in one file with all three color depths, use the AppendTiff method to put them all in one file.)

Display several palettized images at the same time:  Use the OptimizePal method to create a palette that is a compromise between several images’ palettes.  Then use the RemapPal or DitherPal methods to give that palette to all the images.  If starting with True Color images, either reduce colors to 256 first and then optimize, or pick a palette that you want them mapped to and use the DitherPal method to force them to reduce to the closest colors in that palette.

Real-time palette conversion:  As an alternative to creating an optimized palette, the RemapPalette method is fast enough to be used for real-time palette conversion.  If you have several images in memory at once, you can display them by remapping to a generic or common palette and still keep a copy of the original in an invisible control. This will take twice the normal memory for each image displayed on the screen.  (Or to avoid the double memory usage, reread the image with the original palette, when needed.)


topic, What is ImageKnife?
ImageKnife Help

What is ImageKnife?

ImageKnife is a custom control for use with preferred programming environments such as Microsoft Visual Basic 4.0, Delphi 2.0, and Visual C++ 4.0.  A custom control is a file with an OCX extension that contains specially written code that can be added to a visual programming environment to add increased methodality to your applications. ImageKnife consists of ImageKnife, TWAINWizard, sample applications and an extensive on-line help system.  The TWAINWizard control is called a Twiz.

This control is in some ways similar to the standard Visual Basic Picture Box control. Either control can be used to display a graphic in your application. But the PicBuf control can handle images with up to 24-bit color and has additional special properties which make it easy to load, display, output, resize and process your graphics. ImageKnife is also an extensive set of powerful methods which allows you to program advanced graphics capabilities into your applications.

The PicBuf control, its special properties and the ImageKnife methods are the perfect tools to aid in the development of many types of graphics-oriented applications. Use ImageKnife to create browsers, batch processors, database front ends, video image processors, and presentation managers. The advanced image processing techniques made easy with ImageKnife include manipulating palettes, reducing colors, adding text, and smoothing, sharpening, rotating, mirroring and filtering images.

The PicBuf control’s unique properties and the ImageKnife methods can be combined into simple, yet powerful assignment methods. By simple assignment of image properties, you can transfer entire images between PicBuf controls, transfer source images over portions of destination images, and resize source or destination images to fit the desired dimensions for your application project.

We hope that you will find the ImageKnife custom control a powerful programming tool for achieving your programming goals.


topic, What is JPEG?
ImageKnife Help

ImageKnife and JPEG

What is JPEG?

JPEG (pronounced "jay-peg") is a standardized image compression mechanism. JPEG stands for Joint Photographic Experts Group, the original name of the committee that wrote the standard. JPEG is designed for compressing either full-color or gray-scale digital images of "natural," real-world scenes. It does not work so well on non-realistic images, such as cartoons or line drawings.

JPEG does not handle black-and-white (1 bit per pixel) images, nor does it handle motion picture compression. Standards for compressing those types of images are being worked on by other committees, named JBIG and MPEG respectively.

JPEG is "lossy," meaning that the image you get out of decompression isn’t quite identical to what you originally put in. The algorithm achieves much of its compression by exploiting known limitations of the human eye, notably the fact that small color details aren’t perceived as well as small details of light-and-dark. Thus, JPEG is intended for compressing images that will be looked at by humans. If you plan to machine-analyze your images, the small errors introduced by JPEG may be a problem for you, even if they are invisible to the eye.

A useful property of JPEG is that the degree of lossiness can be varied by adjusting compression parameters. This means that the image maker can trade off file size against output image quality. You can make extremely small files if you don’t mind poor quality; this is useful for indexing image archives, making thumbnail views or icons, etc. Conversely, if you aren’t happy with the output quality at the default compression setting, you can jack up the quality until you are satisfied, and accept lesser compression.


topic, What is a Palette
ImageKnife Help

A Palette Primer

What is a palette?

The now-inexpensive VGA and SuperVGA cards can display a maximum of 16 and 256 simultaneous colors respectively. But images don’t all use the same 16 or 256 colors of course. So, video cards can display their given number of colors from a possible range of thousands of colors. This is a little bit like all the neighborhood kids going into a fancy ice cream store that has 99 flavors of ice cream. Each person can only hold three of the 99 possible flavors on their triple-dip ice cream cone, so they pick the flavors that they want.

Each image has a palette (a color table) to which each pixel in an image is mapped. Just like the kids in the ice cream shop, each image can only have a certain number of colors (16 colors maximum for 4-bit images, 256 colors maximum for 8-bit images) out of a wide assortment of thousands of colors. While this allows enough colors to be chosen to make a given image display reasonably well, the colors in another image’s palette are often quite different.

To continue with the ice cream analogy, let’s say that the ice cream shop only has room to display three of their 99 different flavors of ice cream at a time. If you want Rocky Road, Butterscotch, and Strawberry on your triple scoop (who said anything about good taste?), and the shop has Strawberry, Chocolate, and Vanilla out, you have to wait while the clerk puts away the two unneeded flavors, gets the two new flavors, and then puts them in the case before he scoops up your order.

Palettized images work the same way: if some of the colors that the image has in its palette are not in use by the video card, the system waits while the video card finishes loading and unloading colors to get the ones that the image needs. This is partly why palettized images tend to display more slowly.


topic, When Should I Use JPEG?
ImageKnife Help

ImageKnife and JPEG

When should I use JPEG?

JPEG is not going to displace GIF, PNG or any other format entirely; for some types of images, GIF is superior in image quality, file size, or both. One of the first things to learn about JPEG is which kinds of images to apply it to.

As a rule of thumb, JPEG is superior to GIF for storing full-color or gray-scale images of "realistic" scenes; that means scanned photographs and similar material. JPEG is superior even if you don’t have 24-bit display hardware, and it is a lot superior if you do.

GIF, PNG and other formats do significantly better on images with only a few distinct colors, such as cartoons and line drawings. In particular, large areas of pixels that are all exactly the same color are compressed very efficiently indeed by GIF. JPEG can’t squeeze these files as much as GIF does without introducing visible defects. This sort of image is best kept in GIF or PNG form. (In particular, single-color borders are quite cheap in GIF files, but they should be avoided in JPEG files.)

JPEG also has a hard time with very sharp edges: a row of pure-black pixels adjacent to a row of pure-white pixels, for example. Sharp edges tend to come out blurred unless you use a very high quality setting. Again, this sort of thing is not found in scanned photographs, but it shows up fairly often in GIF files: borders, overlaid text, etc. The blurriness is particularly objectionable with text that’s only a few pixels high. If you have an image with a lot of small-size overlaid text, don’t JPEG it.

Computer-drawn images (ray-traced scenes, for instance) usually fall between scanned images and cartoons in terms of complexity. The more complex and subtly rendered the image, the more likely that JPEG will do well on it. The same goes for semi-realistic artwork (fantasy drawings and such).

Plain black-and-white (monochrome) images should never be converted to JPEG. You need at least about 16 gray levels before JPEG is useful for gray-scale images. It should be noted that GIF and PNG are lossless for gray-scale images of up to 256 levels, while JPEG is not.


topic, Why Does Only One Image Displays Properly at a Time?
ImageKnife Help

Commonly Asked Questions

Why only one image displays properly at a time

Now let’s say that our ice cream shop has two clerks behind the counter to deal with the rush of customers. They still only have one display case that can hold only three flavors at once. So, one kid orders Chocolate Chip Mint, Peppermint, and Vanilla. At the same time, the other clerk takes an order for Vanilla, Black Raspberry Cheesecake, and Butter Crunch. Since the store can only have three buckets out at a time, this creates a problem. In an ice cream shop, one of the customers will have to wait for the buckets to be swapped out.

However, if you are trying to display two images with differing palettes on the screen simultaneously under Windows, you have a problem. Windows solves this problem by allowing only one image (the image that has the focus) to have its palette realized at a time. So, all the other images on the screen are temporarily forced to use the palette of the image that has the focus. This can result in some bizarre color displays. If one image’s bright red pixels are all mapped to palette entry 124, and the image that has the focus has dark green in entry 124, all pixels in all images that are mapped to entry 124 will display as dark green (instead of bright red).

Let’s also say that the order that you get the scoops put in your ice cream cone is always the same order that the buckets are in the display. So, if you want Strawberry, Vanilla, and Chocolate (in that order) and the first bucket in the display is Vanilla, the next one is Strawberry, and the last one is Chocolate, your cone will have Vanilla, Strawberry, and Chocolate instead of Strawberry, Vanilla, and Chocolate.

Likewise, the pixels of a palettized image are mapped to a specific entry in the palette. Let’s say that palette entry 139 contains the color blue. So the pixel at x,y coordinate 20,34 might be mapped to palette entry 139. If the color in palette entry 139 is changed to red, then pixel 20,34 and all other pixels that are mapped to that palette entry will become red.


topic, Why Should I Even Bother with Palettized Images?
ImageKnife Help

Commonly Asked Questions

Why should I even bother with palettized images?

Given the number of VGA and SuperVGA cards in use, you may have no choice. Additionally, the chief advantage of palettized images is that they are relatively small compared to High Color and True Color images.

Furthermore, High Color (32,768 color) and True Color (16.7 million color) display cards allow the use of non-palettized image display. This can be accomplished because the wide range of colors that can be displayed simultaneously are sufficient to enable a video card to display virtually any image using either the colors it is actually supposed to use or colors that are similar enough that the unaided eye cannot easily tell the difference. These display cards are more expensive, but their prices are now falling rapidly.

The color information for each pixel is stored directly, without the use of a hardware palette. Thus a given pixel’s value will be that of the actual color that is supposed to be displayed rather than an index to a palette. By using non-palettized images, this makes possible a photo-realistic display, but also requires much larger files that are slower to manipulate and require more memory.

For example, an 8-bit (palettized) image that is 640 x 480 pixels (a full screen in standard VGA mode) requires about 305 kilobytes -- (640 x 480 x 1) + overhead -- of memory. Compare this with a 24-bit image (non-palettized, photo-realistic) that is the same size (640 x 480), but contains three times as much data per pixel (8 x 3 = 24): this image would require over 900 kilobytes of memory -- almost a megabyte! This requires more disk space to store, more memory to process, and more "oomph" to display with reasonable speed.

So, palettized images will continue to have a good deal of attractiveness until the prices of memory, truly high-speed modems, disk space, processor speed, and 24-bit accelerated video cards fall even further. The sheer size of 24-bit images creates a substantial problem for low-end and entry-level hardware platforms.

A rapidly emerging alternative solution seems to be emerging. This alternative is image compression. One particular solution is called JPEG and involves compressing 24-bit images in a relatively new way: the compression algorithm analyzes the image and throws away the data it thinks that the unaided eye is incapable of distinguishing. By doing this, compression ratios of 20-, 30-, even 50-to-1 are possible. ImageKnife supports JPEG. For more details, please see Appendix A, "ImageKnife and JPEG."


topic, Why Use JPEG?
ImageKnife Help

ImageKnife and JPEG

Why Use JPEG?

There are two good reasons: to make your image files smaller, and to store 24-bit per pixel color data instead of 8-bit per pixel data.

Making image files smaller is a big win for transmitting files across networks and for archiving libraries of images. Being able to compress a 2 MB full-color file down to 100K or so makes a big difference in disk space and transmission time. (If you are comparing GIF and JPEG, the size ratio is more like four to one. More details below. Comparisons in this appendix will be between GIF and JPEG for simplicity’s sake and also because GIF seems to have the best compression ratio for "natural" images among lossless formats.)

JPEG images take longer to decode and view than to view simpler formats (GIF, for instance). Thus, using JPEG is essentially a time/space trade-off: you give up some time in order to store or transmit an image more cheaply. It’s worth noting that when network or phone transmission is involved, the time savings from transferring a shorter file can be much greater than the extra time to decompress the file. We’ll let you do the arithmetic yourself.

Another reason why JPEG will gradually replace GIF as a standard format for transmitting or storing images is that JPEG can store full color information: 24 bits/pixel (16 million colors) instead of 8 or less (256 or fewer colors). If you have only 8-bit display hardware then this may not seem like much of an advantage to you. Within a couple of years, though, 8-bit GIF will look as obsolete as black-and-white MacPaint format does today. Furthermore, for reasons detailed further on, JPEG is far more useful than GIF for exchanging images among people with widely varying color display hardware. Hence JPEG is considerably more appropriate than GIF for use as a standard format for transmitting or storing images.