1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-05 18:16:23 +03:00

0023486: Remove obsolete image manipulation classes

Remove AlienImage package. Clean up Image package.
This commit is contained in:
kgv 2013-04-20 11:25:18 +04:00
parent bbd048069d
commit 2361d7e861
89 changed files with 21 additions and 15972 deletions

View File

@ -205,7 +205,6 @@ t TKTopAlgo
t TKXMesh
n InterfaceGraphic
p AIS
p AlienImage
p Aspect
p DsgPrs
p Graphic3d

View File

@ -59,13 +59,11 @@ is
------------------------------------------------------------
SetTextureFileName( me: mutable;
TextureFileName: AsciiString from TCollection)
TextureFileName: AsciiString from TCollection)
is virtual;
---Purpose : Sets the name of the texture file to map. The accepted
-- file types are those used in AlienImage with extensions
-- such as xwd, bmp, gif, rgb, ras, rs and more.
---Purpose : Sets the name of the texture file to map. The accepted
-- file types are those used in Image_AlienPixMap with extensions
-- such as rgb, png, jpg and more.
------------------------------------------------------------

View File

@ -1,148 +0,0 @@
-- Created on: 1993-07-27
-- Created by: Jean Louis FRENKEL
-- Copyright (c) 1993-1999 Matra Datavision
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
--
-- The content of this file is subject to the Open CASCADE Technology Public
-- License Version 6.5 (the "License"). You may not use the content of this file
-- except in compliance with the License. Please obtain a copy of the License
-- at http://www.opencascade.org and read it completely before using this file.
--
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
--
-- The Original Code and all software distributed under the License is
-- distributed on an "AS IS" basis, without warranty of any kind, and the
-- Initial Developer hereby disclaims all such warranties, including without
-- limitation, any warranties of merchantability, fitness for a particular
-- purpose or non-infringement. Please see the License for the specific terms
-- and conditions governing the rights and limitations under the License.
package AlienImage
---Purpose: This package allows importation of images
-- from some other format into CAS.CADE format.
uses
Image,
TColStd,
TCollection,
Aspect,
OSD,
MMgt
is
------------------------
---Category: The classes
------------------------
deferred class AlienImage;
---Purpose: Define the general methods on AlienImage
deferred class AlienImageData ;
---Purpose: Internal Definition of AlienImage.
deferred class AlienUserImage ;
---Purpose: Public Definition of AlienImage.
-- class PSAlienImage;
---Purpose: Definition of PostScript AlienImage.
class SunRFAlienData;
---Purpose: Private definition of Sun Raster File .rs AlienImage.
class SunRFAlienImage;
---Purpose: Public definition of Sun Raster File .rs AlienImage.
class EuclidAlienData;
---Purpose: Private definition of Euclid .pix AlienImage.
class EuclidAlienImage;
---Purpose: Public definition of Euclid .pix AlienImage.
class SGIRGBAlienData;
---Purpose: Private definition of SGI .rgb AlienImage.
class SGIRGBAlienImage;
---Purpose: Public definition of SGI .rgb AlienImage.
class X11XWDAlienData;
---Purpose: Private definition X11 .xwd AlienImage .
class XAlienImage;
---Purpose: Public definition X11 .xwd AlienImage.
class AidaAlienData;
---Purpose: Private definition of Aida .i AlienImage .
class AidaAlienImage;
---Purpose: Public definition of Aida .i AlienImage.
class MemoryOperations;
---Purpose: A set of function to swap byte in memory, used for
-- comaptibility between LSBFirst and MSBFirst .
private class BMPAlienData;
---Purpose: Private definition of windows .bmp AlienImage.
private class GIFAlienData;
---Purpose: Private definition of windows .gif AlienImage.
class BMPAlienImage;
---Purpose: Public definition of windows .bmp AlienImage.
class GIFAlienImage;
---Purpose: Public definition of windows .gif AlienImage.
---Category: Imported types:
imported GIFLZWDict;
imported BMPHeader;
imported X11XColor ;
imported X11XWDFileHeader ;
imported SGIRGBFileHeader ;
imported SUNRFFileHeader ;
enumeration SUNRFFormat is SUNRF_Old,
SUNRF_Standard,
SUNRF_ByteEncoded,
SUNRF_RGB,
SUNRF_Unknown
end SUNRFFormat ;
---Purpose: Type of code for a SUNRF image.
----------------------------
---Category: Package methods
----------------------------
CreateImage (theFileName : AsciiString from TCollection;
theImage : out Image from Image)
returns Boolean from Standard;
---Purpose:
CreateImage (theFileName : CString from Standard;
theImage : out Image from Image)
returns Boolean from Standard;
---Purpose:
CreateImage (theFile : in out File from OSD;
theImage : out Image from Image)
returns Boolean from Standard;
---Purpose:
LoadImageFile (anImageFile : CString from Standard;
anImage : out Image from Image;
aWidth : out Integer from Standard;
aHeight : out Integer from Standard
) returns Boolean from Standard;
---Purpose: Used by plotter drivers
end AlienImage;

View File

@ -1,145 +0,0 @@
// Created on: 1998-10-21
// Created by: DCB
// Copyright (c) 1998-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <AlienImage.hxx>
#include <OSD_Path.hxx>
#include <OSD_File.hxx>
#include <OSD_Protection.hxx>
#include <OSD_Environment.hxx>
#include <Image_Image.hxx>
#include <AlienImage_AlienUserImage.hxx>
#include <AlienImage_XAlienImage.hxx>
#include <AlienImage_SGIRGBAlienImage.hxx>
#include <AlienImage_EuclidAlienImage.hxx>
#include <AlienImage_SunRFAlienImage.hxx>
#include <AlienImage_GIFAlienImage.hxx>
#include <AlienImage_BMPAlienImage.hxx>
//====================================================================
static OSD_Environment& _CSF_DefaultImageFormat() {
static OSD_Environment CSF_DefaultImageFormat("CSF_DefaultImageFormat");
return CSF_DefaultImageFormat;
}
#define CSF_DefaultImageFormat _CSF_DefaultImageFormat()
//====================================================================
Standard_Boolean AlienImage::CreateImage (const TCollection_AsciiString& theFileName,
Handle(Image_Image)& theImage)
{
OSD_File file = OSD_File (OSD_Path (theFileName));
return AlienImage::CreateImage (file, theImage);
}
//====================================================================
Standard_Boolean AlienImage::CreateImage (const Standard_CString theFileName,
Handle(Image_Image)& theImage)
{
OSD_File file = OSD_File (OSD_Path (TCollection_AsciiString (theFileName)));
return AlienImage::CreateImage (file, theImage);
}
//====================================================================
Standard_Boolean AlienImage::CreateImage (OSD_File& theFile,
Handle(Image_Image)& theImage)
{
OSD_Protection theProtection (OSD_R, OSD_R, OSD_R, OSD_R);
OSD_Path thePath;
theFile.Path (thePath);
TCollection_AsciiString theExtension = thePath.Extension();
theExtension.UpperCase ();
Handle(AlienImage_AlienUserImage) theAlienImage;
theFile.Open (OSD_ReadOnly, theProtection);
if (theFile.IsOpen()) {
if (theExtension.IsEqual (".XWD"))
_CreateXWD:
theAlienImage = new AlienImage_XAlienImage ();
else if (theExtension.IsEqual (".RGB"))
_CreateRGB:
theAlienImage = new AlienImage_SGIRGBAlienImage ();
else if (theExtension.IsEqual (".RS"))
_CreateRS:
theAlienImage = new AlienImage_SunRFAlienImage ();
else if (theExtension.IsEqual (".PIX"))
_CreatePIX:
theAlienImage = new AlienImage_EuclidAlienImage ();
else if (theExtension.IsEqual (".GIF"))
_CreateGIF:
theAlienImage = new AlienImage_GIFAlienImage ();
else if (theExtension.IsEqual (".BMP"))
_CreateBMP:
theAlienImage = new AlienImage_BMPAlienImage ();
else if (theExtension.IsEmpty ()) {
// Trye to read $CSF_DefaultImageFormat environment
TCollection_AsciiString theDefExt = CSF_DefaultImageFormat.Value();
theDefExt.Prepend (".");
thePath.SetExtension (theDefExt);
theExtension = theDefExt;
theExtension.UpperCase ();
if (theExtension.IsEqual (".XWD")) goto _CreateXWD;
else if (theExtension.IsEqual (".RGB")) goto _CreateRGB;
else if (theExtension.IsEqual (".RS")) goto _CreateRS;
else if (theExtension.IsEqual (".PIX")) goto _CreatePIX;
else if (theExtension.IsEqual (".GIF")) goto _CreateGIF;
else if (theExtension.IsEqual (".BMP")) goto _CreateBMP;
else return Standard_False;
} else {
return Standard_False;
}
if (!theAlienImage -> Read (theFile)) {
theFile.Close ();
return Standard_False;
}
theImage = theAlienImage -> ToImage ();
theFile.Close ();
return (!theImage.IsNull());
}
return Standard_False;
}
//====================================================================
Standard_Boolean AlienImage::LoadImageFile(const Standard_CString anImageFile,
Handle(Image_Image)& myImage,
Standard_Integer& aWidth,
Standard_Integer& aHeight)
{
// Try to load new image
myImage.Nullify ();
if (AlienImage::CreateImage (anImageFile, myImage)) {
// New image loaded
//_ExitOK:
aWidth = myImage -> Width ();
aHeight = myImage -> Height ();
return Standard_True;
} else {
// Could not load new image
//_ExitError:
myImage.Nullify ();
aWidth = aHeight = 0;
return Standard_False;
}
}

View File

@ -1,123 +0,0 @@
-- Created on: 1993-03-23
-- Created by: BBL
-- Copyright (c) 1993-1999 Matra Datavision
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
--
-- The content of this file is subject to the Open CASCADE Technology Public
-- License Version 6.5 (the "License"). You may not use the content of this file
-- except in compliance with the License. Please obtain a copy of the License
-- at http://www.opencascade.org and read it completely before using this file.
--
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
--
-- The Original Code and all software distributed under the License is
-- distributed on an "AS IS" basis, without warranty of any kind, and the
-- Initial Developer hereby disclaims all such warranties, including without
-- limitation, any warranties of merchantability, fitness for a particular
-- purpose or non-infringement. Please see the License for the specific terms
-- and conditions governing the rights and limitations under the License.
class AidaAlienData from AlienImage inherits AlienImageData from AlienImage
---Version: 0.0
---Level: Public
---Purpose: This class defines an Aida Alien image.
uses
File from OSD,
ColorImage from Image,
PseudoColorImage from Image,
ColorMap from Aspect,
HArray2OfInteger from TColStd,
DitheringMethod from Image,
Image from Image
raises
OutOfRange from Standard,
TypeMismatch from Standard
is
Create returns mutable AidaAlienData from AlienImage ;
Clear( me : in out mutable ) ;
---Level: Public
---Purpose: Frees memory allocated by AidaAlienData
---C++: alias ~
Read ( me : in out mutable ; afile : in out File from OSD )
returns Boolean from Standard ;
---Level: Public
---Purpose: Read content of a AidaAlienData object from a file .
-- Returns True if file is a Aida file .
Write( me : in immutable; afile : in out File from OSD )
returns Boolean from Standard ;
---Level: Public
---Purpose: Write content of a AidaAlienData object to a file .
ToImage( me : in immutable)
returns mutable Image from Image
raises TypeMismatch from Standard ;
---Purpose : Converts a AidaAlienData object to a Image object.
FromImage( me : in out mutable ; anImage : in Image from Image )
raises TypeMismatch from Standard ;
---Purpose : Converts a Image object to a AidaAlienData object.
SetColorImageDitheringMethod( me : in out mutable ;
aMethod : DitheringMethod from Image;
aColorMap : ColorMap from Aspect ) ;
---Level: Public
---Purpose: Set the ImageDitheringMethod and the ColorMap when
-- FromImage is called with a ColorImage .
-- Aida BYTEMAPS file handle only PseudoColorImage .
-- Default value is DM_NearestColor,
-- ColorCubeColorMap( 40, 5,1, 8,6, 3,54 )
AllocData( me : in out mutable ; DX,DY : in Integer from Standard )
is private;
---Level: Internal
---Purpose : Allocate HArray2 to store Image data
Pixel ( me : in immutable ; X,Y : in Integer from Standard )
returns Integer from Standard
raises OutOfRange from Standard is private ;
---Level: Internal
SetPixel( me : in out mutable; X,Y : in Integer from Standard ;
Value : in Integer from Standard )
raises OutOfRange from Standard is private ;
---Level: Internal
FromPseudoColorImage( me : in out mutable;
anImage : in PseudoColorImage from Image )
is private ;
---Level: Internal
---Purpose : convert a Image object to a AidaAlienData object.
FromColorImage( me : in out mutable;
anImage : in ColorImage from Image)
is private ;
---Level: Internal
---Purpose : convert a Image object to a AidaAlienData object.
fields
myDitheringMethod : DitheringMethod from Image is protected ;
myDitheringColorMap : ColorMap from Aspect is protected ;
myColors : ColorMap from Aspect is protected ;
myColorsIsDef : Boolean from Standard is protected ;
-- AidaColors definition
myData : HArray2OfInteger from TColStd ;
myDataIsDef : Boolean from Standard is protected ;
end ;

View File

@ -1,557 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#define TEST //GG_140699
// Check file extension, must be ".aida".
#include <TCollection_AsciiString.hxx>
#include <Image_Convertor.hxx>
#include <Aspect_GenericColorMap.hxx>
#include <Aspect_ColorCubeColorMap.hxx>
#include <AlienImage_AidaAlienData.ixx>
#include <Aspect_ColorMapEntry.hxx>
# include <stdio.h>
#ifdef TRACE
static int Verbose = 0 ;
#endif
AlienImage_AidaAlienData::AlienImage_AidaAlienData()
{
myDataIsDef = Standard_False ;
myColorsIsDef = Standard_False ;
myDitheringColorMap = new Aspect_ColorCubeColorMap( 40, 5,1, 8,6, 3,54 ) ;
myDitheringMethod = Image_DM_NearestColor ;
}
void AlienImage_AidaAlienData::Clear()
{
myDataIsDef = Standard_False ;
myColorsIsDef = Standard_False ;
}
Standard_Boolean AlienImage_AidaAlienData::Write( OSD_File& file ) const
{ Standard_Integer r,c ;
TCollection_AsciiString out ;
char hexa[3] ;
unsigned char p ;
unsigned long int rc,gc,bc ;
TCollection_AsciiString Space = " " ;
if ( ! myDataIsDef ) return( Standard_False ) ;
if ( ! myColorsIsDef ) return( Standard_False ) ;
out = TCollection_AsciiString( "#BC(" ) +
TCollection_AsciiString( myData->RowLength() ) +
Space +
TCollection_AsciiString( myData->ColLength() ) +
TCollection_AsciiString( " #[\n" ) ;
file.Write( out, out.Length() ) ;
if ( file.Failed() ) {
// ERROR
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ;
}
for ( r = myData->LowerRow() ; r <= myData->UpperRow() ; r++ ) {
out = TCollection_AsciiString( "#*" ) ;
for ( c = myData->LowerCol() ; c <= myData->UpperCol() ; c++ ) {
p = ( unsigned char ) myData->Value( r, c ) ;
sprintf( hexa , "%.2x", p ) ;
out += TCollection_AsciiString( hexa ) ;
}
out += TCollection_AsciiString( "\n" ) ;
file.Write( out, out.Length() ) ;
if ( file.Failed() ) {
// ERROR
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ;
}
}
out = TCollection_AsciiString( "](\n" ) ;
file.Write( out, out.Length() ) ;
if ( file.Failed() ) {
// ERROR
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ;
}
// write out the color map buffer
for ( c = 1 ; c <= myColors->Size() ; c++ ) {
rc = (long unsigned int )( myColors->Entry(c).Color().Red() * 32767 + 0.5 );
gc = (long unsigned int )( myColors->Entry(c).Color().Green() * 32767 + 0.5 );
bc = (long unsigned int )( myColors->Entry(c).Color().Blue() * 32767 + 0.5 );
out = TCollection_AsciiString( "#[" ) +
TCollection_AsciiString( myColors->Entry(c).Index() ) + Space +
TCollection_AsciiString( Standard_Integer(rc) ) + Space +
TCollection_AsciiString( Standard_Integer(gc) ) + Space +
TCollection_AsciiString( Standard_Integer(bc) ) + Space +
TCollection_AsciiString( "()]\n" ) ;
file.Write( out, out.Length() ) ;
if ( file.Failed() ) {
// ERROR
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ;
}
}
out = TCollection_AsciiString( "))" ) ;
file.Write( out, out.Length() ) ;
if ( file.Failed() ) {
// ERROR
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ;
}
return( Standard_True ) ;
}
Standard_Boolean AlienImage_AidaAlienData::Read( OSD_File& file )
{ TCollection_AsciiString tmp, in ;
Standard_Integer loc1, loc2, width, height, i, bblcount, l ,value ;
TCollection_AsciiString HexaSet = "0123456789ABCDEFabcdef" ;
int r,g,b,pixel,status ;
Handle(Aspect_GenericColorMap) GenCmap = NULL ;
#ifdef TEST
OSD_Path path; file.Path(path);
TCollection_AsciiString ext = path.Extension(); ext.LowerCase();
if( ext != ".aida" ) {
TCollection_AsciiString sysname; path.SystemName(sysname);
#ifdef TRACE
cout << " *** AlienImage_AidaAlienData::Read('" << sysname << "'). must have an '.aida' extension" << endl;
#endif
return Standard_False;
}
#endif
Clear() ;
// Extract AidaBYTEMAPS type "#BC"
// Get "#"
do {
file.Read( tmp, 1) ;
} while( !file.Failed() && tmp != TCollection_AsciiString( "#" ) ) ;
if ( file.Failed() ) {
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ; // ERROR
}
// Get "BC"
file.Read( tmp, 2 ) ;
if ( file.Failed() ) {
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ; // ERROR
}
if ( tmp != TCollection_AsciiString( "BC" ) ) {
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ; // ERROR
}
// Get "(" Start of AidaBYTEMAPS size definition
do {
file.Read( tmp, 1) ;
} while( !file.Failed() && tmp != TCollection_AsciiString( "(" ) ) ;
if ( file.Failed() ) {
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ; // ERROR
}
// Get "#" Start of AidaBYTEMAPS Pixel definition
in.Clear() ;
do {
file.Read( tmp, 1) ;
if ( tmp.IsAscii() ) {
in += tmp ;
}
} while( !file.Failed() && tmp != TCollection_AsciiString( "#" ) ) ;
if ( file.Failed() ) {
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ; // ERROR
}
// Extract Image size in "Width Height #"
loc1 = 1 ;
if ( ( loc2 = in.Location( 1, ' ', loc1, in.Length() ) ) == 0 ) {
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ; // ERROR
}
if ( ( loc1 ) > ( loc2-1 ) ) {
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ; // ERROR
}
tmp = in.SubString( loc1, loc2-1 ) ;
if ( !tmp.IsIntegerValue() ) {
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ; // ERROR
}
if ( ( width = tmp.IntegerValue() ) <= 0 ) {
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ; // ERROR
}
tmp = in.SubString( loc2, in.Length()-1 ) ;
if ( !tmp.IsIntegerValue() ) {
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ; // ERROR
}
if ( ( height = tmp.IntegerValue() ) <= 0 ) {
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ; // ERROR
}
#ifdef TRACE
if ( Verbose )
cout << "Width,Height :" << width << "," << height << endl << flush ;
#endif
AllocData( width, height ) ;
// Get "[" start of AidaBYTEMAPS Pixel definition
do {
file.Read( tmp, 1) ;
} while( !file.Failed() && tmp != TCollection_AsciiString( "[" ) ) ;
if ( file.Failed() ) {
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ; // ERROR
}
// Extract Pixel lines "#*................."
in.Clear() ;
for ( i = 0 ; i < height ; i++ ) {
// Get "#"
do {
file.Read( tmp, 1) ;
} while( !file.Failed() && tmp != TCollection_AsciiString( "#" ) ) ;
if ( file.Failed() ) {
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ; // ERROR
}
// Get "*"
file.Read( tmp, 1) ;
if ( file.Failed() ) {
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ; // ERROR
}
if ( tmp != TCollection_AsciiString( "*" ) ) {
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ; // ERROR
}
// Get Pixel line
bblcount = 0 ;
in.Clear() ;
while ( bblcount < (2*width) ) {// Two byte per PIXEL
file.Read( tmp, 1) ;
if ( file.Failed() ) {
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ; // ERROR
}
if ( tmp.IsAscii() ) {
if ( tmp.FirstLocationInSet( HexaSet, 1, 1 ) ) {
in += tmp ; bblcount++ ;
}
else {
// Get Next line character before end of current line
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ; // ERROR
}
}
}
#ifdef TRACE
if ( Verbose )
cout << "Get one line :\"" << in << "\"\n" << flush ;
#endif
for ( l = 0 ; l < in.Length() ; l += 2 ) {
tmp = in.SubString( l+1, l+2 ) ;
value = ( Standard_Integer )strtol( tmp.ToCString(), NULL, 16 );
SetPixel( l/2 , i, value ) ;
#ifdef TRACE
if ( Verbose > 1 )
cout << "SetPixel(" << l/2 << "," << i << "," << value << ")\n" <<flush;
#endif
}
}
// Get "]" end of Aida image data
do {
file.Read( tmp, 1) ;
} while( !file.Failed() && tmp != TCollection_AsciiString( "]" ) ) ;
if ( file.Failed() ) {
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ; // ERROR
}
// Get "(" start of Aida colors definition or ")" end of Aida ByteMaps
do {
file.Read( tmp, 1) ;
} while( !file.Failed() &&
tmp != TCollection_AsciiString( "(" ) &&
tmp != TCollection_AsciiString( ")" ) ) ;
if ( file.Failed() ) {
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ; // ERROR
}
if ( tmp == TCollection_AsciiString( ")" ) ) {
return( Standard_True ) ; // No Color definition ERROR ??
}
// Find Color definition "#[ Red Green Blue ... ]" color is from 0->32767
myColors = GenCmap = new Aspect_GenericColorMap() ;
myColorsIsDef = Standard_True ;
do {
// Get "#" start of a Aida color definition or
// Get ")" end of Aida colors definition
do {
file.Read( tmp, 1) ;
} while( !file.Failed() &&
tmp != TCollection_AsciiString( "#" ) &&
tmp != TCollection_AsciiString( ")" ) ) ;
if ( file.Failed() ) {
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ; // ERROR
}
if ( tmp == TCollection_AsciiString( "#" ) ) {
// Get "[" start of a Aida color definition
do {
file.Read( tmp, 1) ;
} while( !file.Failed() && tmp != TCollection_AsciiString( "[" ) ) ;
if ( file.Failed() ) {
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ; // ERROR
}
// Get "]" end of a Aida color definition
in.Clear() ;
do {
file.Read( tmp, 1) ;
if ( tmp.IsAscii() && tmp != TCollection_AsciiString( "]" ) ) {
in += tmp ;
}
} while( !file.Failed() && tmp != TCollection_AsciiString( "]" ) ) ;
if ( file.Failed() ) {
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ; // ERROR
}
status = sscanf( in.ToCString(), "%d %d %d %d", &pixel,&r,&g,&b ) ;
if ( status == 4 ) {
GenCmap->AddEntry(
Aspect_ColorMapEntry( pixel,
Quantity_Color( r/32767.,g/32767.,b/32767.,
Quantity_TOC_RGB ) ) ) ;
}
#ifdef TRACE
if ( Verbose )
cout << in << endl << flush ;
#endif
}
} while ( !file.Failed() && tmp != TCollection_AsciiString( ")" ) ) ;
if ( file.Failed() ) {
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ; // ERROR
}
return( Standard_True ) ;
}
Handle_Image_Image AlienImage_AidaAlienData::ToImage() const
{ Standard_Integer x,y ;
Handle(Image_PseudoColorImage) aPImage =
new Image_PseudoColorImage( 0, 0,
myData->RowLength(), myData->ColLength(),
myColors );
for( y = 0 ; y < aPImage->Height() ; y++ ) {
for( x = 0 ; x < aPImage->Width() ; x++ ) {
aPImage->SetPixel( aPImage->LowerX()+x,
aPImage->LowerY()+y, Pixel( x, y ) ) ;
}
}
return aPImage ;
}
void AlienImage_AidaAlienData::FromImage( const Handle_Image_Image& anImage )
{ if ( anImage->IsInstance(STANDARD_TYPE(Image_PseudoColorImage)) ) {
Handle(Image_PseudoColorImage) aPImage =
Handle(Image_PseudoColorImage)::DownCast(anImage) ;
FromPseudoColorImage( aPImage ) ;
}
else if ( anImage->IsInstance(STANDARD_TYPE(Image_ColorImage)) ) {
Handle(Image_ColorImage) aCImage =
Handle(Image_ColorImage)::DownCast(anImage) ;
FromColorImage( aCImage ) ;
}
else {
Standard_TypeMismatch_Raise_if( Standard_True,
"Attempt to convert a unknown Image_Image type to a AidaAlienData");
}
}
void AlienImage_AidaAlienData::SetColorImageDitheringMethod(
const Image_DitheringMethod aMethod ,
const Handle(Aspect_ColorMap)& aColorMap )
{ myDitheringMethod = aMethod ; myDitheringColorMap = aColorMap ; }
//------------------------------------------------------------------------------
// Private Method
//------------------------------------------------------------------------------
void AlienImage_AidaAlienData::FromPseudoColorImage(
const Handle_Image_PseudoColorImage& anImage)
{ Standard_Integer x,y ;
AllocData( anImage->Width(), anImage->Height() ) ;
myColors = anImage->ColorMap() ;
myColorsIsDef = Standard_True ;
for ( y = 0 ; y < anImage->Height() ; y++ ) {
for ( x = 0 ; x < anImage->Width() ; x++ ) {
SetPixel( x,
y,
anImage->Pixel( anImage->LowerX()+x,
anImage->LowerY()+y ).Value() ) ;
}
}
}
void AlienImage_AidaAlienData::FromColorImage(
const Handle_Image_ColorImage& anImage)
{ Image_Convertor Convertor ;
Handle(Image_PseudoColorImage) aPImage =
new Image_PseudoColorImage( anImage->LowerX(), anImage->LowerY(),
anImage->Width(), anImage->Height(),
myDitheringColorMap ) ;
Convertor.SetDitheringMethod( myDitheringMethod ) ;
aPImage = Convertor.Convert( anImage, myDitheringColorMap ) ;
FromPseudoColorImage( aPImage ) ;
}
void AlienImage_AidaAlienData::AllocData(
const Standard_Integer dx,
const Standard_Integer dy )
{
myData = new TColStd_HArray2OfInteger( 0, dy-1 , 0, dx-1 ) ;
myDataIsDef = Standard_True ;
}
void AlienImage_AidaAlienData::SetPixel(
const Standard_Integer x,
const Standard_Integer y,
const Standard_Integer value )
{
myData->SetValue( y, x, value ) ;
}
Standard_Integer AlienImage_AidaAlienData::Pixel(
const Standard_Integer x, const Standard_Integer y ) const
{ return myData->Value( y, x ) ; }

View File

@ -1,81 +0,0 @@
-- Created on: 1993-03-23
-- Created by: BBL
-- Copyright (c) 1993-1999 Matra Datavision
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
--
-- The content of this file is subject to the Open CASCADE Technology Public
-- License Version 6.5 (the "License"). You may not use the content of this file
-- except in compliance with the License. Please obtain a copy of the License
-- at http://www.opencascade.org and read it completely before using this file.
--
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
--
-- The Original Code and all software distributed under the License is
-- distributed on an "AS IS" basis, without warranty of any kind, and the
-- Initial Developer hereby disclaims all such warranties, including without
-- limitation, any warranties of merchantability, fitness for a particular
-- purpose or non-infringement. Please see the License for the specific terms
-- and conditions governing the rights and limitations under the License.
-- Modified: 02-06-98 : FMN ; Suppression appel Clear (deja fait dans ALienData)
class AidaAlienImage from AlienImage inherits AlienUserImage from AlienImage
---Version: 0.0
---Purpose: This class defines an Aida Alien image ( BYTEMAPS ).
---Keywords:
---Warning:
---References:
uses
File from OSD,
ColorMap from Aspect,
Image from Image,
DitheringMethod from Image,
AidaAlienData from AlienImage
is
Create returns mutable AidaAlienImage from AlienImage;
Clear( me : in out mutable) ;
---Level: Public
---Purpose: Frees memory allocated by AidaAlienImage
ToImage( me : in immutable )
returns mutable Image from Image ;
---Level: Public
---Purpose : convert a AidaAlienImage object to a Image object.
FromImage( me : in out mutable ; anImage : in Image from Image ) ;
---Level: Public
---Purpose : convert a Image object to a AidaAlienImage object.
Read ( me : in out mutable; afile : in out File from OSD )
returns Boolean from Standard ;
---Level: Public
---Purpose: Read content of a AidaAlienImage object from a file .
-- Returns True if file is a Aida file .
Write( me : in immutable; afile : in out File from OSD )
returns Boolean from Standard ;
---Level: Public
---Purpose: Write content of a AidaAlienImage object to a file .
SetColorImageDitheringMethod( me : in out mutable ;
aMethod : DitheringMethod from Image;
aColorMap : ColorMap from Aspect ) ;
---Level: Public
---Purpose: Set the ImageDitheringMethod and the ColorMap when
-- FromImage is called with a ColorImage .
-- Aida BYTEMAPS file handle only PseudoColorImage .
-- Default value is DM_NearestColor,
-- ColorCubeColorMap( 40, 5,1, 8,6, 3,54 )
fields
myData : AidaAlienData from AlienImage;
end ;

View File

@ -1,59 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <stdio.h>
#include <AlienImage_XAlienImage.hxx>
#include <OSD_Protection.hxx>
#include <OSD_File.hxx>
#include <AlienImage_AidaAlienImage.ixx>
AlienImage_AidaAlienImage::AlienImage_AidaAlienImage()
{ // il faut faire un new si mydata est du type HANDLE
myData = new AlienImage_AidaAlienData() ;
}
void AlienImage_AidaAlienImage::Clear()
{ myData->Clear() ; }
Standard_Boolean AlienImage_AidaAlienImage::Write( OSD_File& file ) const
{ return( myData->Write( file ) ) ; }
Standard_Boolean AlienImage_AidaAlienImage::Read( OSD_File& file )
{ return( myData->Read( file ) ) ; }
Handle(Image_Image) AlienImage_AidaAlienImage::ToImage() const
{ return( myData->ToImage() ) ; }
void AlienImage_AidaAlienImage::FromImage( const Handle(Image_Image)& anImage )
{ myData->FromImage( anImage ) ; }
void AlienImage_AidaAlienImage::SetColorImageDitheringMethod(
const Image_DitheringMethod aMethod ,
const Handle(Aspect_ColorMap)& aColorMap )
{ myData->SetColorImageDitheringMethod( aMethod, aColorMap ) ; }

View File

@ -1,60 +0,0 @@
-- Created on: 1993-03-23
-- Created by: BBL,JLF
-- Copyright (c) 1993-1999 Matra Datavision
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
--
-- The content of this file is subject to the Open CASCADE Technology Public
-- License Version 6.5 (the "License"). You may not use the content of this file
-- except in compliance with the License. Please obtain a copy of the License
-- at http://www.opencascade.org and read it completely before using this file.
--
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
--
-- The Original Code and all software distributed under the License is
-- distributed on an "AS IS" basis, without warranty of any kind, and the
-- Initial Developer hereby disclaims all such warranties, including without
-- limitation, any warranties of merchantability, fitness for a particular
-- purpose or non-infringement. Please see the License for the specific terms
-- and conditions governing the rights and limitations under the License.
deferred class AlienImage from AlienImage inherits TShared from MMgt
---Purpose: This class defines an Alien image.
-- Alien Image is X11 .xwd image or SGI .rgb image for example
uses
File from OSD,
Image from Image
raises
TypeMismatch from Standard
is
Initialize ;
Read ( me : in out mutable ; afile : in out File from OSD )
returns Boolean from Standard is deferred;
---Level: Public
---Purpose: Reads content of a AlienImage object from a file .
-- Returns True if file is a XWD file .
Write( me : in immutable ; afile : in out File from OSD )
returns Boolean from Standard is deferred ;
---Level: Public
---Purpose: Writes content of a AlienImage object to a file .
ToImage ( me : in immutable )
returns mutable Image from Image
raises TypeMismatch from Standard is deferred ;
---Level: Public
---Purpose : Converts a AlienImage object to a Image object.
FromImage( me : in out mutable ; anImage : in Image from Image )
raises TypeMismatch from Standard is deferred ;
---Level: Public
---Purpose : Converts a Image object to a AlienImage object.
end AlienImage;

View File

@ -1,27 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <AlienImage_AlienImage.ixx>
AlienImage_AlienImage::AlienImage_AlienImage()
{
#ifdef TRACE
cout << "AlienImage_AlienImage constructor \n" ;
#endif
}

View File

@ -1,57 +0,0 @@
-- Created on: 1993-03-23
-- Created by: BBL,JLF
-- Copyright (c) 1993-1999 Matra Datavision
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
--
-- The content of this file is subject to the Open CASCADE Technology Public
-- License Version 6.5 (the "License"). You may not use the content of this file
-- except in compliance with the License. Please obtain a copy of the License
-- at http://www.opencascade.org and read it completely before using this file.
--
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
--
-- The Original Code and all software distributed under the License is
-- distributed on an "AS IS" basis, without warranty of any kind, and the
-- Initial Developer hereby disclaims all such warranties, including without
-- limitation, any warranties of merchantability, fitness for a particular
-- purpose or non-infringement. Please see the License for the specific terms
-- and conditions governing the rights and limitations under the License.
-- Modified: DCB (20-OCT-98)
-- Define Name()/SetName() as deferred.
deferred class AlienImageData from AlienImage inherits AlienImage
---Version: 0.0
---Purpose: This class defines an Alien image.
-- Alien Image is X11 . xwd image or SGI .rgb image for examples
---Keywords:
---Warning:
---References:
uses
AsciiString from TCollection
is
Initialize ;
SetName( me : in out mutable;
aName : in AsciiString from TCollection)
is virtual;
---Level: Public
---Purpose: Set Image name .
Name( me : in immutable ) returns AsciiString from TCollection
is virtual;
---C++: return const &
---Level: Public
---Purpose: get Image name .
fields
myName: AsciiString from TCollection is protected;
end AlienImageData;

View File

@ -1,37 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <AlienImage_AlienImageData.ixx>
AlienImage_AlienImageData::AlienImage_AlienImageData()
{
#ifdef TRACE
cout << "AlienImage_AlienImageData constructor \n" ;
#endif
}
void AlienImage_AlienImageData::SetName (const TCollection_AsciiString& aName)
{
myName = aName + TCollection_AsciiString ("\0");
}
const TCollection_AsciiString& AlienImage_AlienImageData::Name () const
{
return myName;
}

View File

@ -1,81 +0,0 @@
-- Created on: 1993-03-23
-- Created by: BBL,JLF
-- Copyright (c) 1993-1999 Matra Datavision
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
--
-- The content of this file is subject to the Open CASCADE Technology Public
-- License Version 6.5 (the "License"). You may not use the content of this file
-- except in compliance with the License. Please obtain a copy of the License
-- at http://www.opencascade.org and read it completely before using this file.
--
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
--
-- The Original Code and all software distributed under the License is
-- distributed on an "AS IS" basis, without warranty of any kind, and the
-- Initial Developer hereby disclaims all such warranties, including without
-- limitation, any warranties of merchantability, fitness for a particular
-- purpose or non-infringement. Please see the License for the specific terms
-- and conditions governing the rights and limitations under the License.
-- Modified: DCB (20-OCT-98)
-- Define ToImage()/FromName() as deferred.
deferred class AlienUserImage from AlienImage inherits AlienImage
---Version: 0.0
---Purpose: This class defines an Alien user image.
-- Alien Image is X11 .xwd image or SGI .rgb image for examples
---Keywords:
---Warning:
---References:
uses
Image from Image,
File from OSD
raises
TypeMismatch from Standard
is
Initialize ;
Read ( me : in out mutable ; afile : in out File from OSD )
returns Boolean from Standard is deferred;
---Level: Public
---Purpose: Read content of a UserAlienImage object from a file .
-- Returns True if sucess .
Read ( me : in out mutable ; afile : in CString from Standard )
returns Boolean from Standard ;
---Level: Public
---Purpose: Read content of a UserAlienImage object from a file .
-- Returns True if file is a AlienImage file .
Write ( me : in immutable ; afile : in out File from OSD )
returns Boolean from Standard is deferred ;
---Level: Public
---Purpose: Write content of a UserAlienImage object to a file .
Write ( me : in immutable ; afile : in CString from Standard )
returns Boolean from Standard ;
---Level: Public
---Purpose: Write content of a UserAlienImage object to a file .
ToImage ( me : in immutable )
returns mutable Image from Image
raises TypeMismatch from Standard
is deferred;
---Level: Public
---Purpose : convert a AidaAlienData object to a Image object.
FromImage ( me : in out mutable ; anImage : in Image from Image )
raises TypeMismatch from Standard
is deferred;
---Level: Public
---Purpose : convert a Image object to a AidaAlienData object.
end AlienUserImage;

View File

@ -1,93 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <OSD_Process.hxx>
#include <OSD_Protection.hxx>
#include <AlienImage_XAlienImage.hxx>
#include <AlienImage_AlienUserImage.ixx>
#include <OSD_File.hxx>
#include <OSD_Path.hxx>
AlienImage_AlienUserImage::AlienImage_AlienUserImage()
{
#ifdef TRACE
cout << "AlienImage_AlienUserImage constructor \n" ;
#endif
}
#ifdef IMPLEMENTED
AlienImage_AlienUserImage::AlienImage_AlienUserImage(
const Standard_CString afile,
Standard_Boolean& Success )
{
#ifdef TRACE
cout << "AlienImage_AlienUserImage constructor \n" ;
#endif
Success = Read( afile ) ;
}
AlienImage_AlienUserImage::AlienImage_AlienUserImage(
const Handle(Image_Image)& anImage)
{
#ifdef TRACE
cout << "AlienImage_AlienUserImage constructor \n" ;
#endif
FromImage( anImage ) ;
}
#endif
Standard_Boolean AlienImage_AlienUserImage::Read( const Standard_CString file )
{ OSD_File File ;
OSD_Protection Protection ;
OSD_Path Path;
Standard_Boolean Ret ;
Protection.SetValues( OSD_R, OSD_R, OSD_R, OSD_R ) ;
Path = OSD_Path( TCollection_AsciiString( file ),OSD_Default);
File.SetPath ( Path ); // Instanciate
File.Open ( OSD_ReadOnly, Protection ) ;
Ret = Read( File ) ;
File.Close() ;
return( Ret ) ;
}
Standard_Boolean AlienImage_AlienUserImage::Write(
const Standard_CString file)const
{ OSD_File File ;
OSD_Protection Protection ;
OSD_Path Path;
Standard_Boolean Ret ;
Protection.SetValues( OSD_RW, OSD_RW, OSD_RW, OSD_RW ) ;
Path = OSD_Path( TCollection_AsciiString( file ),OSD_Default);
File.SetPath ( Path ); // Instanciate
File.Build ( OSD_WriteOnly, Protection ) ;
Ret = Write( File ) ;
File.Close() ;
return( Ret ) ;
}

View File

@ -1,87 +0,0 @@
-- Created on: 1998-10-20
-- Created by: DCB
-- Copyright (c) 1998-1999 Matra Datavision
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
--
-- The content of this file is subject to the Open CASCADE Technology Public
-- License Version 6.5 (the "License"). You may not use the content of this file
-- except in compliance with the License. Please obtain a copy of the License
-- at http://www.opencascade.org and read it completely before using this file.
--
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
--
-- The Original Code and all software distributed under the License is
-- distributed on an "AS IS" basis, without warranty of any kind, and the
-- Initial Developer hereby disclaims all such warranties, including without
-- limitation, any warranties of merchantability, fitness for a particular
-- purpose or non-infringement. Please see the License for the specific terms
-- and conditions governing the rights and limitations under the License.
private class BMPAlienData from AlienImage inherits AlienImageData from AlienImage
uses
File from OSD,
GenericColorMap from Aspect,
PseudoColorImage from Image,
ColorImage from Image,
Image from Image
raises
OutOfRange from Standard,
TypeMismatch from Standard
is
Create returns mutable BMPAlienData from AlienImage ;
Clear( me : in out mutable );
---Level: Public
---Purpose: Frees memory allocated by BMPAlienData
---C++: alias ~
Read ( me : in out mutable ; afile : in out File from OSD )
returns Boolean from Standard;
---Level: Public
---Purpose: Read content of a BMPAlienData object from a file
-- Returns True if file is a BMP file .
Write( me : in immutable; afile : in out File from OSD )
returns Boolean from Standard;
---Level: Public
---Purpose: Write content of a BMPAlienData object to a file
ToImage( me : in immutable)
returns mutable Image from Image
raises TypeMismatch from Standard ;
---Level: Public
---Purpose : convert a BMPAlienData object to a Image object.
FromImage( me : in out mutable ; anImage : in Image from Image )
raises TypeMismatch from Standard ;
---Level: Public
---Purpose : convert a Image object to a BMPAlienData object.
------------------------------------------------------
--- Private methods
------------------------------------------------------
FromPseudoColorImage (me : in out mutable;
anImage : in PseudoColorImage from Image )
is private;
---Level: Internal
---Purpose : convert a Image object to a GIFAlienData object.
FromColorImage (me : in out mutable;
anImage : in ColorImage from Image)
is private;
---Level: Internal
---Purpose : convert a Image object to a GIFAlienData object.
fields
myColorMap : GenericColorMap from Aspect;
myData : Address from Standard; --BYTE* or DWORD*
myWidth : Integer from Standard;
myHeight : Integer from Standard;
end;

View File

@ -1,589 +0,0 @@
// Created by: DCB
// Copyright (c) 1998-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
// Notes:
// Read()/Write() code is taken from ZOV's sources from Xw package.
// include windows.h first to ensure that it is loaded completely
#ifdef WNT
#include <windows.h>
#endif
#include <AlienImage_BMPAlienData.ixx>
#include <AlienImage_BMPHeader.hxx>
#include <Aspect_ColorMap.hxx>
#include <Aspect_ColorMapEntry.hxx>
#include <Quantity_Color.hxx>
#include <Image_PseudoColorImage.hxx>
#include <Image_ColorImage.hxx>
#include <OSD_FromWhere.hxx>
#include <Standard.hxx>
static unsigned long __swaptest = 1;
WORD static _TestSwapWORD (WORD __w)
{
return LOW_VAL_AT_LOW_ADDR ? __w:
((__w&0xFF) << 8) | ((__w&0xFF00) >> 8);
}
DWORD static _TestSwapDWORD (DWORD __dw)
{
return LOW_VAL_AT_LOW_ADDR ? __dw:
((__dw&0x000000FF) << 24) | ((__dw&0x0000FF00) << 8)
| ((__dw&0xFF0000) >> 8) | ((__dw&0xFF000000) >> 24);
}
#define STGMGR_ALLOC(size) Standard::Allocate(size)
#define STGMGR_FREE(buf,size) Standard::Free((void*&)buf)
#define BPIXEL ((BYTE *) myData)
#define DWPIXEL ((DWORD*) myData)
//================================================================
AlienImage_BMPAlienData::AlienImage_BMPAlienData ()
: AlienImage_AlienImageData ()
{
myData = NULL;
myWidth = 0;
myHeight = 0;
myColorMap.Nullify ();
}
//================================================================
void AlienImage_BMPAlienData::Clear ()
{
if (myData) {
STGMGR_FREE (myData, (!myColorMap.IsNull() ? myWidth*myHeight :
myWidth*myHeight*4));
myData = NULL;
}
myWidth = 0;
myHeight = 0;
myColorMap.Nullify ();
}
//================================================================
Standard_Boolean AlienImage_BMPAlienData::Read (OSD_File& file)
{
BYTE *pData = NULL, *pbData=NULL; // pointer to bitmap pixels
BYTE *ptrByte;
int i, isize, ncolors, bytes_per_line, x, y, width, height;
DWORD dwRMask, dwGMask, dwBMask, dwSize;
int nRMult, nGMult, nBMult;
int isInsideOut, hasMask, nBitCount;
int iCompression, isOS2Format, hasColormap;
int nBytes, iDataSize;
char bmpSign[2];
AlienImage_BMPHeader bmfh; // Standard BMP file header
BITMAPINFOHEADER bmih; // Windows BMP header
BITMAPCOREHEADER bmch; // OS/2 BMP header
Standard_Address lpVoid;
Quantity_Color color;
Standard_Real r, g, b;
Aspect_ColorMapEntry entry;
RGBQUAD* pColors256 = (RGBQUAD*) STGMGR_ALLOC (sizeof(RGBQUAD)*256);
// Check 'BM' signature
file.Seek (0, OSD_FromBeginning);
lpVoid = Standard_Address(&bmpSign[0]);
file.Read ((void*&)lpVoid, 2, nBytes);
if (file.Failed () || strncmp (bmpSign, "BM", 2) || nBytes != 2) {
// cout << "AlienImage_BMPAlienData::Read() : 'BM' signature not found."
// << endl << flush;
goto _ExitReadError;
}
lpVoid = Standard_Address(&bmfh);
file.Read ((void*&)lpVoid, sizeof(AlienImage_BMPHeader), nBytes);
if (file.Failed () || nBytes != sizeof(AlienImage_BMPHeader)) {
cout << "AlienImage_BMPAlienData::Read() : Reading AlienImage_BMPHeader."
<< endl << flush;
goto _ExitReadError;
}
lpVoid = Standard_Address (&dwSize);
file.Read ((void*&)lpVoid, sizeof (DWORD), nBytes);
if (file.Failed() || nBytes != sizeof (DWORD)) {
cout << "AlienImage_BMPAlienData::Read() : BAD file size." << endl << flush;
goto _ExitReadError;
}
file.Seek (-(int)sizeof(DWORD), OSD_FromHere);
isOS2Format = _TestSwapDWORD(dwSize) == sizeof (BITMAPCOREHEADER);
if (isOS2Format) {
lpVoid = Standard_Address(&bmch);
file.Read ((void*&)lpVoid, sizeof(BITMAPCOREHEADER), nBytes);
if (file.Failed() || nBytes != sizeof(BITMAPCOREHEADER)) {
cout << "AlienImage_BMPAlienData::Read() : Reading BITMAPCOREHEADER."
<< endl << flush;
goto _ExitReadError;
}
} else {
lpVoid = Standard_Address(&bmih);
file.Read ((void*&)lpVoid, sizeof(BITMAPINFOHEADER), nBytes);
if (file.Failed() || nBytes != sizeof(BITMAPINFOHEADER)) {
cout << "AlienImage_BMPAlienData::Read() : Reading BITMAPINFOHEADER."
<< endl << flush;
goto _ExitReadError;
}
}
nBitCount = _TestSwapWORD (isOS2Format ? bmch.bcBitCount: bmih.biBitCount);
if ((nBitCount != 1 && nBitCount != 4 && nBitCount != 8 &&
nBitCount != 16 && nBitCount != 24 && nBitCount != 32) ||
isOS2Format && (nBitCount == 16 || nBitCount == 32)) {
cout << "AlienImage_BMPAlienData::Read() : Bad <nBitCount> value :"
<< nBitCount << " " << isOS2Format << endl << flush;
goto _ExitReadError;
}
iCompression = isOS2Format ? BI_RGB: _TestSwapDWORD (bmih.biCompression);
hasColormap = nBitCount <= 8;
hasMask = iCompression == BI_BITFIELDS;
ncolors = hasColormap ? 1 << nBitCount: 0;
width = isOS2Format ? _TestSwapWORD (bmch.bcWidth)
: _TestSwapDWORD (bmih.biWidth);
height = isOS2Format ? _TestSwapWORD (bmch.bcHeight)
: _TestSwapDWORD (bmih.biHeight);
isInsideOut = !isOS2Format && height < 0;
height = isInsideOut ? -height: height;
bytes_per_line = width * nBitCount;
bytes_per_line = (bytes_per_line>>3) + (bytes_per_line&0x7 ? 1: 0);
bytes_per_line += (bytes_per_line&0x3)? (4-(bytes_per_line&0x3)): 0;
myWidth = width;
myHeight = height;
if (hasColormap) {
// Retreive array of colors (as RGBQUAD sequence).
// Note, that there can be less then ncolors colors.
isize = ncolors * sizeof (RGBQUAD);
file.Read ((void*&)pColors256, isize, nBytes);
if (file.Failed() || nBytes != isize) {
cout << "AlienImage_BMPAlienData::Read() : Reading ColorMap."
<< endl << flush;
goto _ExitReadError;
}
// Build colormap
myColorMap = new Aspect_GenericColorMap ();
for (i=0; i<ncolors; i++) {
r = ((float)pColors256[i].rgbRed / 255.);
g = ((float)pColors256[i].rgbGreen / 255.);
b = ((float)pColors256[i].rgbBlue / 255.);
color.SetValues (r, g, b, Quantity_TOC_RGB);
entry.SetValue (i, color);
myColorMap -> AddEntry (entry);
}
}
if (hasMask) {
PDWORD pdw;
// Retrieve three DWORD's that contain the masks for R, G and B respectively
file.Read ((void*&)(pdw = &dwRMask), sizeof (DWORD), nBytes);
if (file.Failed() || nBytes != sizeof(DWORD)) {
cout << "AlienImage_BMPAlienData::Read() : BAD file size." << endl << flush;
goto _ExitReadError;
}
file.Read ((void*&)(pdw = &dwGMask), sizeof (DWORD), nBytes);
if (file.Failed() || nBytes != sizeof(DWORD)) {
cout << "AlienImage_BMPAlienData::Read() : BAD file size." << endl << flush;
goto _ExitReadError;
}
file.Read ((void*&)(pdw = &dwBMask), sizeof (DWORD), nBytes);
if (file.Failed() || nBytes != sizeof(DWORD)) {
cout << "AlienImage_BMPAlienData::Read() : BAD file size." << endl << flush;
goto _ExitReadError;
}
if (hasColormap || !dwRMask || !dwGMask || !dwBMask) {
cout << "AlienImage_BMPAlienData::Read() : BAD image colormap." << endl << flush;
goto _ExitReadError;
}
dwRMask = _TestSwapDWORD (dwRMask);
dwGMask = _TestSwapDWORD (dwGMask);
dwBMask = _TestSwapDWORD (dwBMask);
nRMult = nGMult = nBMult = 0;
for (i=dwRMask; (i&1)^1; i >>= 1)
nRMult++;
for (i=dwGMask; (i&1)^1; i >>= 1)
nGMult++;
for (i=dwBMask; (i&1)^1; i >>= 1)
nBMult++;
} else {
dwBMask = 0x000000ff, dwGMask = 0x0000ff00, dwRMask = 0x00ff0000,
nBMult = 0, nGMult = 8, nRMult = 16;
}
// Allocate the pixel buffer and load raw data from file
i = _TestSwapDWORD (bmfh.bfOffBits);
iDataSize = _TestSwapDWORD (bmfh.bfSize) - i;
pData = (BYTE *) STGMGR_ALLOC (iDataSize);
pbData = pData;
file.Seek (i, OSD_FromBeginning);
file.Read ((void*&)pData, iDataSize, nBytes);
if (file.Failed () || nBytes != iDataSize) {
cout << "AlienImage_BMPAlienData::Read() : Image data."
<< endl << flush;
goto _ExitReadError;
}
if (iCompression == BI_RLE4 || iCompression == BI_RLE8) {
pbData = (BYTE*) STGMGR_ALLOC (width*height);
// Note, that it is possible that "spots" could appear
// after decompressing the data encoded using RLE algorith.
// The method assumes that the image is drawn to an already
// defined background. That's why I have to fill in these
// probable spots with some color (I have chosen 0-indexed one).
memset (pbData, 0, iDataSize);
// Decompress the data to array of 8-bit color indices
x = 0;
y = 0;
ptrByte = pData;
for (;;) {
BYTE bPixCount = *ptrByte++;
BYTE bCode, bColor;
if (bPixCount) {
bColor = *ptrByte++;
//fprintf (stderr, "[%02x S]", (int)bPixCount);
if (iCompression == BI_RLE8) {
while (bPixCount--)
pbData [width*y + x++] = bColor;
} else {
BYTE bColor0 = (bColor & 0xf0) >> 4;
BYTE bColor1 = bColor & 0x0f;
i = 0;
while (bPixCount--)
pbData [width*y + x++] = i++ & 1 ? bColor1: bColor0;
}
continue;
}
// Zero code has been reached.
// Do the command specified in the second byte.
bCode = *ptrByte++;
if (!bCode) { // EOL
x = 0, y++; //,fprintf (stderr, "\r\n");
} else if (bCode == 1) { // EOF
break;
} else if (bCode == 2) { // Delta
x += (unsigned) *ptrByte++;
y += (unsigned) *ptrByte++;
//fprintf (stderr, "[POS=%d,%d]", x, y);
} else { // Absolute mode
bPixCount = bCode;
//fprintf (stderr, "[%02x D]", (int)bPixCount);
if (iCompression == BI_RLE8) {
while (bPixCount--)
pbData [width*y + x++] = *ptrByte++;
} else {
i = 0;
while (bPixCount--)
pbData [width*y + x++] = i++ & 1 ? *ptrByte & 0x0f
: (*ptrByte++ & 0xf0) >> 4;
}
// each run must aligned on a word boundary
if (iCompression == BI_RLE8 && (bCode & 1) ||
iCompression == BI_RLE4 && (bCode & 3))
ptrByte ++;
}
}
bytes_per_line = width;
nBitCount = 8;
STGMGR_FREE (pData, iDataSize);
iDataSize = width*height;
}
// Data isn't comressed. Can just use the raw data
// Alloc image data (pidata) and fill in the buffer with RGBQUAD's
isize = width*height;
myData = STGMGR_ALLOC (!myColorMap.IsNull() ? myWidth*myHeight : myWidth*myHeight*4);
x = 0;
y = isInsideOut? 0: height-1;
for (i = 0; i < isize; i++) {
DWORD dwValue=0;
BYTE* pbLine = pbData + y*bytes_per_line;
switch (nBitCount) {
case 32:
dwValue = *(((DWORD *) pbLine) + x); break; // next double word value
case 16:
dwValue = *(((WORD *) pbLine) + x); break; // next word
case 8:
dwValue = *(((BYTE *) pbLine) + x); break; // next byte
case 24: {
BYTE* pbTripple = pbLine + x+(x<<1);
dwValue = *pbTripple + (*(pbTripple +1) <<8) + (*(pbTripple +2) <<16);
} break;
case 4:
dwValue = (x&1) ? *(pbLine+(x>>1))&0x0f: (*(pbLine+(x>>1))&0xf0) >> 4; break;
case 1: {
int iBit = 7 - (x&7);
dwValue = (*(pbLine+(x>>3)) & (1 <<iBit)) >>iBit;
} break; // next bit
}
if (hasColormap) {
BPIXEL [i] = (BYTE) dwValue; // put index in colormap
} else {
DWPIXEL[i] = (DWORD) dwValue; // put RGB
}
if (++x == width) {
x = 0;
y += isInsideOut? 1: -1;
}
}
STGMGR_FREE (pColors256, sizeof(RGBQUAD)*256);
STGMGR_FREE (pbData, iDataSize);
return Standard_True;
_ExitReadError:
// cout << "AlienImage_BMPAlienData::Read() : Read file error." << endl << flush;
STGMGR_FREE (pColors256, sizeof(RGBQUAD)*256);
if (pbData) STGMGR_FREE (pbData, iDataSize);
Clear ();
return Standard_False;
}
//================================================================
Standard_Boolean AlienImage_BMPAlienData::Write (OSD_File& file) const
{
AlienImage_BMPHeader bfh;
BITMAPINFOHEADER bih;
int isize, x, y;
BYTE *pbData = NULL, *pbCell = NULL;
WORD sign = _TestSwapWORD(0x4D42); // BMP file signature: SWAP('MB')
DWORD dwPixel;
RGBQUAD* prgbColor = (RGBQUAD*)&dwPixel;
Quantity_Color color;
Standard_Real r, g, b;
if (myData == NULL || myWidth == 0 || myHeight == 0 )
return Standard_False;
// Get the size of array of pixels
isize = myWidth*3; // actual size of data in each scan line
isize += (isize & 3 ? 4 - (isize & 3): 0); // plus pad size
isize *= myHeight;
pbData = (BYTE*) STGMGR_ALLOC (isize);
// Build and write File Header.
bfh.bfSize = _TestSwapDWORD(2+sizeof (AlienImage_BMPHeader) +
sizeof (BITMAPINFOHEADER) +
sizeof (RGBQUAD)*0 +
isize);
bfh.bfReserved = 0;
bfh.bfOffBits = _TestSwapDWORD(2+sizeof (AlienImage_BMPHeader) +
sizeof (BITMAPINFOHEADER) +
sizeof (RGBQUAD)*0);
// Write file signature
file.Write (&sign, 2);
if (file.Failed ())
goto _ExitWriteError;
// Write file header
file.Write (&bfh, sizeof (bfh));
if (file.Failed ())
goto _ExitWriteError;
// Build and write Info Header.
bih.biSize = _TestSwapDWORD(sizeof (BITMAPINFOHEADER));
bih.biWidth = _TestSwapDWORD(myWidth );
bih.biHeight = _TestSwapDWORD(myHeight);
bih.biPlanes = _TestSwapWORD (1);
bih.biBitCount = _TestSwapWORD (24); // 8 bits per each of R,G and B value
bih.biCompression = 0; // BI_RGB
bih.biSizeImage = 0; // can be zero for BI_RGB
bih.biXPelsPerMeter = 0;
bih.biYPelsPerMeter = 0;
bih.biClrUsed = 0; // all colors used
bih.biClrImportant = 0; // all colors imortant
file.Write (&bih, sizeof (bih));
if (file.Failed ())
goto _ExitWriteError;
// Fill in array of pixels and write out the buffer.
pbCell = pbData;
for (y = myHeight-1; y >= 0; y--) {
for (x = 0; x < myWidth; x++) {
if (!myColorMap.IsNull ()) {
color = myColorMap -> FindEntry (BPIXEL[y*myWidth + x]).Color ();
color.Values (r, g, b, Quantity_TOC_RGB);
*pbCell++ = (BYTE)(b*255.);
*pbCell++ = (BYTE)(g*255.);
*pbCell++ = (BYTE)(r*255.);
} else {
dwPixel = _TestSwapDWORD (DWPIXEL[y*myWidth + x]);
*pbCell++ = prgbColor -> rgbBlue;
*pbCell++ = prgbColor -> rgbGreen;
*pbCell++ = prgbColor -> rgbRed;
}
}
x *= 3;
// Pad each scan line with zeroes to end on a LONG data-type boundary
while (x++ & 0x03) // i.e. until 4 devides x
*pbCell++ = 0;
}
file.Write (pbData, isize);
if (file.Failed ())
goto _ExitWriteError;
STGMGR_FREE (pbData, isize);
return Standard_True;
_ExitWriteError:
cout << "AlienImage_BMPAlienData::Write() : Write file error." << endl << flush;
STGMGR_FREE (pbData, isize);
return Standard_False;
}
//================================================================
Handle_Image_Image AlienImage_BMPAlienData::ToImage () const
{
Standard_Integer x, y, LowX, LowY;
Handle(Image_Image) theImage;
if (!myColorMap.IsNull()) {
Aspect_IndexPixel iPixel;
theImage = new Image_PseudoColorImage (0, 0, myWidth, myHeight, myColorMap);
LowX = theImage -> LowerX ();
LowY = theImage -> LowerY ();
for (y = 0; y < myHeight; y++) {
for (x = 0; x < myWidth; x++) {
iPixel.SetValue (BPIXEL[y*myWidth + x]);
theImage -> SetPixel (LowX + x, LowY + y, iPixel);
}
}
} else {
DWORD dwPixel;
RGBQUAD* pRgb = (RGBQUAD*)&dwPixel;
Standard_Real r, g, b;
Quantity_Color color;
Aspect_ColorPixel cPixel;
theImage = new Image_ColorImage (0, 0, myWidth, myHeight);
LowX = theImage -> LowerX ();
LowY = theImage -> LowerY ();
for (y = 0; y < myHeight; y++) {
for (x = 0; x < myWidth; x++) {
dwPixel = _TestSwapDWORD (DWPIXEL[y*myWidth + x]);
r = ((float)pRgb -> rgbRed / 255.);
g = ((float)pRgb -> rgbGreen / 255.);
b = ((float)pRgb -> rgbBlue / 255.);
color.SetValues (r, g, b, Quantity_TOC_RGB);
cPixel.SetValue (color);
theImage -> SetPixel (LowX + x, LowY + y, cPixel);
}
}
}
return theImage;
}
//================================================================
void AlienImage_BMPAlienData::FromImage (const Handle_Image_Image& anImage)
{
if (anImage -> Type() == Image_TOI_PseudoColorImage) {
// Build from PseudoColorImage
Handle(Image_PseudoColorImage) aPImage =
Handle(Image_PseudoColorImage)::DownCast(anImage);
FromPseudoColorImage (aPImage);
} else if (anImage -> Type() == Image_TOI_ColorImage) {
// Build from ColorImage
Handle(Image_ColorImage) aCImage =
Handle(Image_ColorImage)::DownCast(anImage);
FromColorImage (aCImage);
} else {
// Unknown type of image
Standard_TypeMismatch_Raise_if (Standard_True,
"Attempt to convert a unknown Image_Image type to a BMPAlienData");
}
}
//================================================================
void AlienImage_BMPAlienData::FromPseudoColorImage (
const Handle(Image_PseudoColorImage)& anImage)
{
int width = anImage -> Width ();
int height = anImage -> Height ();
int x, y, LowX = anImage -> LowerX(), LowY = anImage -> LowerY();
Aspect_IndexPixel iPixel;
BYTE index;
if (width*height > 0) {
Handle(Aspect_ColorMap) aColorMap = anImage -> ColorMap ();
// Clear old data if any
Clear ();
// Fill colormap
myColorMap = new Aspect_GenericColorMap ();
for (int i = 1; i <= aColorMap -> Size (); i++)
myColorMap -> AddEntry (aColorMap -> Entry (i));
// Fill image's data
myWidth = width;
myHeight = height;
myData = STGMGR_ALLOC (myWidth*myHeight);
for (y = 0; y < myHeight; y++) {
for (x = 0; x < myWidth; x++) {
iPixel = anImage -> Pixel (LowX + x, LowY + y);
index = aColorMap -> FindEntry (iPixel.Value ()).Index ();
BPIXEL[y*myWidth + x] = index;
}
}
}
}
//================================================================
void AlienImage_BMPAlienData::FromColorImage (
const Handle(Image_ColorImage)& anImage)
{
int width = anImage -> Width ();
int height = anImage -> Height ();
int x, y, LowX = anImage -> LowerX(), LowY = anImage -> LowerY();
Standard_Real r, g, b;
Quantity_Color color;
RGBQUAD rgbColor;
DWORD* pdwPixel = (DWORD*)&rgbColor;
if (width*height > 0) {
// Clear old data if any
Clear ();
// Fill image's data
myWidth = width;
myHeight = height;
myData = STGMGR_ALLOC (myWidth*myHeight*4);
for (y = 0; y < myHeight; y++) {
for (x = 0; x < myWidth; x++) {
color = anImage -> PixelColor (LowX + x, LowY + y);
color.Values (r, g, b, Quantity_TOC_RGB);
rgbColor.rgbRed = (int)(r*255.);
rgbColor.rgbGreen = (int)(g*255.);
rgbColor.rgbBlue = (int)(b*255.);
rgbColor.rgbReserved = 0;
DWPIXEL[y*myWidth + x] = _TestSwapDWORD (*pdwPixel);
}
}
}
}

View File

@ -1,73 +0,0 @@
-- Created on: 1998-10-20
-- Created by: DCB
-- Copyright (c) 1998-1999 Matra Datavision
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
--
-- The content of this file is subject to the Open CASCADE Technology Public
-- License Version 6.5 (the "License"). You may not use the content of this file
-- except in compliance with the License. Please obtain a copy of the License
-- at http://www.opencascade.org and read it completely before using this file.
--
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
--
-- The Original Code and all software distributed under the License is
-- distributed on an "AS IS" basis, without warranty of any kind, and the
-- Initial Developer hereby disclaims all such warranties, including without
-- limitation, any warranties of merchantability, fitness for a particular
-- purpose or non-infringement. Please see the License for the specific terms
-- and conditions governing the rights and limitations under the License.
class BMPAlienImage from AlienImage inherits AlienUserImage from AlienImage
uses
BMPAlienData from AlienImage,
File from OSD,
AsciiString from TCollection,
Image from Image
is
Create
returns mutable BMPAlienImage from AlienImage;
Clear( me : in out mutable) ;
---Level: Public
---Purpose: Frees memory allocated by BMPAlienImage
---C++: alias ~
SetName( me : in out mutable;
aName : in AsciiString from TCollection) ;
---Level: Public
---Purpose: Set Image name .
Name( me : in immutable ) returns AsciiString from TCollection ;
---C++: return const &
---Level: Public
---Purpose: get Image name .
ToImage( me : in immutable )
returns mutable Image from Image ;
---Level: Public
---Purpose : convert a BMPAlienImage object to a Image object.
FromImage( me : in out mutable ; anImage : in Image from Image ) ;
---Level: Public
---Purpose : convert a Image object to a BMPAlienImage object.
Read ( me : in out mutable; afile : in out File from OSD )
returns Boolean from Standard ;
---Level: Public
---Purpose: Read content of a BMPAlienImage object from a file .
-- Returns True if file is a BMP file .
Write( me : in immutable; afile : in out File from OSD )
returns Boolean from Standard ;
---Level: Public
---Purpose: Write content of a BMPAlienImage object to a file .
fields
myData : BMPAlienData from AlienImage;
end;

View File

@ -1,70 +0,0 @@
// Created by: DCB
// Copyright (c) 1998-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <AlienImage_BMPAlienImage.ixx>
//================================================================
AlienImage_BMPAlienImage::AlienImage_BMPAlienImage ()
{
myData = new AlienImage_BMPAlienData() ;
}
//================================================================
void AlienImage_BMPAlienImage::Clear ()
{
myData->Clear();
}
//================================================================
void AlienImage_BMPAlienImage::SetName (const TCollection_AsciiString& aName)
{
myData->SetName (aName);
}
//================================================================
const TCollection_AsciiString& AlienImage_BMPAlienImage::Name () const
{
return (myData->Name());
}
//================================================================
Standard_Boolean AlienImage_BMPAlienImage::Write (OSD_File& file) const
{
return myData->Write(file);
}
//================================================================
Standard_Boolean AlienImage_BMPAlienImage::Read (OSD_File& file)
{
return myData->Read(file);
}
//================================================================
Handle_Image_Image AlienImage_BMPAlienImage::ToImage () const
{
return myData->ToImage();
}
//================================================================
void AlienImage_BMPAlienImage::FromImage (const Handle_Image_Image& anImage)
{
myData->FromImage(anImage);
}

View File

@ -1,30 +0,0 @@
// Created by: DCB
// Copyright (c) 1998-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
// Notes: Most of code is taken from Xw_load_bmp_image.c file (ZOV)
#include <AlienImage_BMPHeader.hxx>
const Handle(Standard_Type)& STANDARD_TYPE(AlienImage_BMPHeader)
{
static Handle(Standard_Type) _atype =
new Standard_Type ("AlienImage_BMPHeader", sizeof (AlienImage_BMPHeader));
return _atype;
}

View File

@ -1,90 +0,0 @@
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
//============================================================================
//==== Titre: AlienImage_BMPHeader.hxx
//============================================================================
#ifndef _AlienImage_BMPHeader_HeaderFile
#define _AlienImage_BMPHeader_HeaderFile
//==== Definition de Type ====================================================
#include <Standard_Type.hxx>
#ifdef WNT
# include <windows.h>
#else
typedef unsigned int DWORD; // 32-bit signed
typedef unsigned int* PDWORD;
typedef int LONG; // 32-bit unsigned
typedef unsigned short WORD; // 16-bit unsigned
typedef unsigned char BYTE; // 8-bit unsigned
#endif // WNT
typedef struct {
// WORD bfType;
DWORD bfSize;
DWORD bfReserved;
DWORD bfOffBits;
} AlienImage_BMPHeader;
const Handle(Standard_Type)& STANDARD_TYPE(AlienImage_BMPHeader);
//============================================================================
#ifndef WNT
typedef struct tagBITMAPINFOHEADER {
DWORD biSize;
LONG biWidth;
LONG biHeight;
WORD biPlanes;
WORD biBitCount;
DWORD biCompression;
DWORD biSizeImage;
LONG biXPelsPerMeter;
LONG biYPelsPerMeter;
DWORD biClrUsed;
DWORD biClrImportant;
} BITMAPINFOHEADER;
typedef struct tagBITMAPCOREHEADER {
DWORD bcSize;
WORD bcWidth;
WORD bcHeight;
WORD bcPlanes; // 1
WORD bcBitCount; // 1,4,8 or 24
} BITMAPCOREHEADER;
// constants for the biCompression field
#define BI_RGB 0
#define BI_RLE8 1
#define BI_RLE4 2
#define BI_BITFIELDS 3
typedef struct tagRGBQUAD {
BYTE rgbBlue;
BYTE rgbGreen;
BYTE rgbRed;
BYTE rgbReserved;
} RGBQUAD;
#endif // WNT
#define LOW_VAL_AT_LOW_ADDR (*(char*)&__swaptest)
#endif // _AlienImage_BMPHeader_HeaderFile

View File

@ -1,97 +0,0 @@
-- Created on: 1993-03-23
-- Created by: BBL
-- Copyright (c) 1993-1999 Matra Datavision
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
--
-- The content of this file is subject to the Open CASCADE Technology Public
-- License Version 6.5 (the "License"). You may not use the content of this file
-- except in compliance with the License. Please obtain a copy of the License
-- at http://www.opencascade.org and read it completely before using this file.
--
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
--
-- The Original Code and all software distributed under the License is
-- distributed on an "AS IS" basis, without warranty of any kind, and the
-- Initial Developer hereby disclaims all such warranties, including without
-- limitation, any warranties of merchantability, fitness for a particular
-- purpose or non-infringement. Please see the License for the specific terms
-- and conditions governing the rights and limitations under the License.
class EuclidAlienData from AlienImage inherits AlienImageData from AlienImage
---Version: 0.0
---Level: Public
---Purpose: This class defines an Euclid .PIX Alien image.
---Keywords:
---Warning:
---References:
uses
File from OSD,
AsciiString from TCollection,
ColorImage from Image,
PseudoColorImage from Image,
Image from Image,
HArray2OfInteger from TColStd
raises
OutOfRange from Standard,
TypeMismatch from Standard
is
Create returns mutable EuclidAlienData from AlienImage ;
Clear( me : in out mutable ) ;
---Level: Public
---Purpose: Frees memory allocated by EuclidAlienData
---C++: alias ~
Read ( me : in out mutable ; afile : in out File from OSD )
returns Boolean from Standard ;
---Level: Public
---Purpose: Read content of a EuclidAlienData object from a file .
-- Returns True if file is a XWD file .
Write( me : in immutable; afile : in out File from OSD )
returns Boolean from Standard ;
---Level: Public
---Purpose: Write content of a EuclidAlienData object to a file .
ToImage( me : in immutable)
returns mutable Image from Image
raises TypeMismatch from Standard ;
---Level: Public
---Purpose : convert a EuclidAlienData object to a Image object.
FromImage( me : in out mutable ; anImage : in Image from Image )
raises TypeMismatch from Standard ;
---Level: Public
---Purpose : convert a Image object to a EuclidAlienData object.
--
-- Private Method
--
FromPseudoColorImage( me : in out mutable ;
anImage : in PseudoColorImage from Image );
---Level: Internal
---Purpose : convert a Image object to a EuclidAlienData object.
FromColorImage( me : in out mutable ;
anImage : in ColorImage from Image );
---Level: Internal
---Purpose : convert a Image object to a EuclidAlienData object.
fields
myX1, myY1, myX2, myY2 : Integer from Standard ;
myNumberOfColor : Integer from Standard ;
myColors : Address from Standard ;
myPixels : HArray2OfInteger from TColStd ;
myPixelsIsDef : Boolean from Standard ;
end ;

View File

@ -1,435 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#define TEST //GG_140699
// Check file extension, must be ".PIX".
#include <Aspect_GenericColorMap.hxx>
#include <Image_Convertor.hxx>
#include <Image_PseudoColorImage.hxx>
#include <AlienImage_EuclidAlienData.ixx>
#include <Aspect_ColorMapEntry.hxx>
#include <Standard.hxx>
#define xTRACE
#ifdef TRACE
static int Verbose = 1 ;
#endif
static const unsigned int EndOfPixelLine = 65535 ;
static const unsigned int EndOfPixelField = 65534 ;
#ifdef PAGESIZE // HPUX COMPATIBILLITY
#undef PAGESIZE
#endif
#define MAXCOUL 896
#define PAGESIZE 512
#define FIRST_EUCLID_IMAGE_COLOR 37
#define LAST_EUCLID_IMAGE_COLOR 180
#define ColorsSize() ( MAXCOUL*sizeof(int) )
#define COLOR(i) ( (( int * )myColors)[i-1] ) // Fortran Array Binding
//------------------------------------------------------------------------------
// Public Method
//------------------------------------------------------------------------------
AlienImage_EuclidAlienData::AlienImage_EuclidAlienData()
{
myX1 = myY1 = myX2 = myY2 = myNumberOfColor = 0 ;
myColors = NULL ;
myPixelsIsDef = Standard_False ;
}
void AlienImage_EuclidAlienData::Clear()
{
if ( myColors ) {
// Free memory
Standard::Free(myColors) ;
myColors = NULL ;
}
myPixelsIsDef = Standard_False ;
myX1 = myY1 = myX2 = myY2 = myNumberOfColor = 0 ;
}
Standard_Boolean AlienImage_EuclidAlienData::Read( OSD_File& file )
{ Standard_Integer bblcount, i ;
#ifdef TEST
OSD_Path path; file.Path(path);
TCollection_AsciiString ext = path.Extension(); ext.LowerCase();
if( ext != ".pix" ) {
TCollection_AsciiString sysname; path.SystemName(sysname);
#ifdef TRACE
cout << " *** AlienImage_EuclidAlienData::Read('" << sysname << "'). must have an '.PIX' extension" << endl;
#endif
return Standard_False;
}
#endif
if ( myColors == NULL )
myColors = Standard::Allocate( ColorsSize() ) ;
// Read in Header information
file.Read( myColors, ColorsSize(), bblcount ) ;
if ( file.Failed() || ( bblcount != ColorsSize() ) ) {
// ERROR
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ;
}
myNumberOfColor = COLOR(1)+1 ;
myX1 = COLOR(2) ;
myY1 = COLOR(3) ;
myX2 = COLOR(4) ;
myY2 = COLOR(5) ;
#ifdef TRACE
if ( Verbose ) {
cout << "EuclidAlienData::Read(" << myNumberOfColor-1 << "," <<
myX1 << "," <<
myY1 << "," <<
myX2 << "," <<
myY2 << ")\n" << flush ;
}
#endif
myPixels = new TColStd_HArray2OfInteger( myX1, myX2, myY1, myY2, 0 ) ;
myPixelsIsDef = Standard_True ;
Standard_Boolean K_FLAG, K_LIGNE;
Standard_Integer INCRE, JNCRE, ILIGNE, NUMBLK, NMOT, NPIX, IPIXCR;
int LINPIX[(PAGESIZE*128)/sizeof(int)] ;
Standard_Address pLINPIX = ( Standard_Address ) LINPIX ;
K_FLAG = Standard_True ;
K_LIGNE = Standard_False ;
INCRE = myX1 ;
JNCRE = 1 ;
ILIGNE = myY1 ;
NUMBLK = 8 ;
NMOT = (PAGESIZE*128) ;
file.Seek( PAGESIZE*(NUMBLK-1), OSD_FromBeginning ) ;
file.Read( pLINPIX, NMOT*sizeof(int), bblcount ) ;
NUMBLK += 128 ;
if ( file.Failed() ) {
// ERROR
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ;
}
while( K_FLAG ) {
while( !K_LIGNE ) {
NPIX = LINPIX[JNCRE-1] & 0xffff ;
IPIXCR = ( LINPIX[JNCRE-1] >> 16 ) & 0xffff ;
if ( IPIXCR == (Standard_Integer ) EndOfPixelLine ) {
K_LIGNE = Standard_True ;
}
else if ( IPIXCR < 512 ) {
for( i = 0 ; i < NPIX ; i++ ) {
myPixels->SetValue(INCRE,ILIGNE,IPIXCR & 0xff);
INCRE++ ;
}
JNCRE++ ;
if ( JNCRE >= NMOT ) {
file.Seek( PAGESIZE*(NUMBLK-1), OSD_FromBeginning ) ;
file.Read( pLINPIX, NMOT*sizeof(int),bblcount );
NUMBLK += 128 ;
JNCRE = 1 ;
if ( file.Failed() ){ // ERROR
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ;
}
}
}
else {
K_LIGNE = Standard_True ;
}
}
// Next Line
K_LIGNE = Standard_False ;
ILIGNE++ ;
INCRE = myX1 ;
JNCRE++ ;
IPIXCR = ( LINPIX[JNCRE-1] >> 16 ) & 0xffff ;
if ( IPIXCR == (Standard_Integer ) EndOfPixelField )
K_FLAG = Standard_False ; // End of Image
}
return Standard_True ;
}
Standard_Boolean AlienImage_EuclidAlienData::Write( OSD_File& file ) const
{ Standard_Integer x, y ;
Standard_Integer NUMBLK, NMOT, NPIX, MAXMOT ;
Standard_Integer ITSTPIX ;
int LINPIX[(PAGESIZE*128)/sizeof(int)] ;
if ( myNumberOfColor == 0 || myColors == NULL || ! myPixelsIsDef )
return Standard_False ;
MAXMOT = (PAGESIZE*128) / sizeof(int) ;
// Write in Header information
file.Write( myColors, ColorsSize() ) ;
if ( file.Failed() ) {
// ERROR
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ;
}
NUMBLK = 8 ;
NMOT = 0 ;
for ( y = myY1 ; y <= myY2 ; y++ ) {
x = myX1 ;
ITSTPIX = myPixels->Value( x, y ) ;
x++ ;
while( x <= myX2 ) {
NPIX = 1 ;
while ( myPixels->Value( x, y ) == ITSTPIX ) {
NPIX++ ;
x++ ;
if ( x > myX2 ) break ;// End of Pixel Line
}
LINPIX[NMOT] = ( ( ( ITSTPIX&0xff ) << 16 ) & 0xffff0000 ) |
( NPIX & 0xffff );
NMOT++ ;
if ( NMOT >= MAXMOT ) {
file.Seek( PAGESIZE*(NUMBLK-1), OSD_FromBeginning ) ;
file.Write( ( void *)LINPIX, NMOT*sizeof(int) );
NMOT = 0 ;
NUMBLK += 128 ;
}
if ( x <= myX2 ) {
ITSTPIX = myPixels->Value( x, y ) ;
x++ ;
if ( x == myX2 ) {// Last Pixel
LINPIX[NMOT] = ( ( (ITSTPIX&0xff)<<16 ) & 0xffff0000 ) |
( 1 & 0xffff );
NMOT++ ;
if ( NMOT >= MAXMOT ) {
file.Seek( PAGESIZE*(NUMBLK-1), OSD_FromBeginning ) ;
file.Write( ( void *)LINPIX, NMOT*sizeof(int) );
NMOT = 0 ;
NUMBLK += 128 ;
}
}
}
}
// End of Pixel Line
LINPIX[NMOT] = ( ( EndOfPixelLine<<16 ) & 0xffff0000 ) |
( 0 & 0xffff );
NMOT++ ;
if ( NMOT >= MAXMOT ) {
file.Seek( PAGESIZE*(NUMBLK-1), OSD_FromBeginning ) ;
file.Write( ( void *)LINPIX, NMOT*sizeof(int) );
NMOT = 0 ;
NUMBLK += 128 ;
}
}
// End of Pixel Field
LINPIX[NMOT] = ( ( EndOfPixelField<<16 ) & 0xffff0000 ) |
( 0 & 0xffff );
NMOT++ ;
file.Seek( PAGESIZE*(NUMBLK-1), OSD_FromBeginning ) ;
file.Write( ( void *)LINPIX, NMOT*sizeof(int) );
return Standard_False ;
}
Handle_Image_Image AlienImage_EuclidAlienData::ToImage() const
{ Standard_Real r,g,b ;
Standard_Integer x, y, i ;
Aspect_IndexPixel IPixel ;
Aspect_ColorMapEntry Centry ;
Quantity_Color color ;
if ( myNumberOfColor == 0 || myColors == NULL || ! myPixelsIsDef )
return NULL ;
Handle(Aspect_GenericColorMap) colormap = new Aspect_GenericColorMap() ;
Handle(Image_PseudoColorImage) PImage =
new Image_PseudoColorImage( myX1, myY1,
(myX2-myX1)+1, (myY2-myY1)+1, colormap ) ;
Handle(Image_Image) RetImage = PImage ;
// Get Colors
for ( i = 0 ; i < myNumberOfColor ; i++ ) {
r = ( Standard_Real ) COLOR(129+3*i) / 255. ;
g = ( Standard_Real ) COLOR(130+3*i) / 255. ;
b = ( Standard_Real ) COLOR(131+3*i) / 255. ;
color.SetValues( r,g,b, Quantity_TOC_RGB );
Centry.SetValue( i, color ) ;
colormap->AddEntry( Centry ) ;
}
for ( y = myY1 ; y <= myY2 ; y++ ) {
for ( x = myX1 ; x <= myX2 ; x++ ) {
IPixel.SetValue( myPixels->Value( x, y ) ) ;
PImage->SetPixel( x,myY2+myY1-y, IPixel ) ;
}
}
return RetImage ;
}
void AlienImage_EuclidAlienData::FromImage( const Handle_Image_Image& anImage )
{
if ( anImage->Type() == Image_TOI_PseudoColorImage ) {
Handle(Image_PseudoColorImage) aPImage =
Handle(Image_PseudoColorImage)::DownCast(anImage) ;
FromPseudoColorImage( aPImage ) ;
}
else if ( anImage->Type() == Image_TOI_ColorImage ) {
Handle(Image_ColorImage) aCImage =
Handle(Image_ColorImage)::DownCast(anImage) ;
FromColorImage( aCImage ) ;
}
else {
Standard_TypeMismatch_Raise_if( Standard_True,
"Attempt to convert a unknown Image_Image type to a EuclidAlienImage");
}
}
//------------------------------------------------------------------------------
// Private Method
//------------------------------------------------------------------------------
void AlienImage_EuclidAlienData::FromColorImage(
const Handle_Image_ColorImage& anImage)
{ Image_Convertor Convertor ;
Handle(Aspect_ColorMap) aCmap =
anImage->ChooseColorMap(LAST_EUCLID_IMAGE_COLOR-FIRST_EUCLID_IMAGE_COLOR+1);
Handle(Image_PseudoColorImage) aPImage = Convertor.Convert( anImage, aCmap ) ;
FromPseudoColorImage( aPImage ) ;
}
void AlienImage_EuclidAlienData::FromPseudoColorImage(
const Handle_Image_PseudoColorImage& PImage)
{
if ( myColors == NULL )
myColors = Standard::Allocate( ColorsSize() ) ;
//
// Euclid ColorMap goes from 0 to 255
// We must define all colors form 0 to 255 in a EUCLID .PIX file
//
Standard_Real r,g,b ;
Standard_Integer x, y, i, index ;
Aspect_IndexPixel IPixel ;
Aspect_ColorMapEntry Centry ;
Handle(Aspect_ColorMap) colormap = PImage->ColorMap() ;
for ( i = 1 ; i <= MAXCOUL ; i++ ) {
COLOR(i) = 0 ;
}
myX1 = PImage->LowerX() ; myX2 = PImage->UpperX() ;
myY1 = PImage->LowerY() ; myY2 = PImage->UpperY() ;
myPixels = new TColStd_HArray2OfInteger( myX1, myX2, myY1, myY2, 0 ) ;
myPixelsIsDef = Standard_True ;
myNumberOfColor = 0 ;
// Get Colors
for ( i = 1 ; i <= colormap->Size() ; i++ ) {
Centry = colormap->Entry( i ) ;
index = Centry.Index() ;
if ( index >= 0 && index <= 255 ) {
myNumberOfColor = Max( myNumberOfColor, index ) ;
Centry.Color().Values( r,g,b, Quantity_TOC_RGB ) ;
COLOR(129+3*index) = ( int ) ( r * 255. + 0.5 ) ;
COLOR(130+3*index) = ( int ) ( g * 255. + 0.5 ) ;
COLOR(131+3*index) = ( int ) ( b * 255. + 0.5 ) ;
}
}
COLOR(1) = myNumberOfColor ;
COLOR(2) = myX1;
COLOR(3) = myY1 ;
COLOR(4) = myX2 ;
COLOR(5) = myY2 ;
for ( y = myY1 ; y <= myY2 ; y++ ) {
for ( x = myX1 ; x <= myX2 ; x++ ) {
PImage->Pixel( x,myY2+myY1-y, IPixel ) ;
myPixels->SetValue( x, y, IPixel.Value() ) ;
}
}
}

View File

@ -1,71 +0,0 @@
-- Created on: 1993-03-23
-- Created by: BBL
-- Copyright (c) 1993-1999 Matra Datavision
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
--
-- The content of this file is subject to the Open CASCADE Technology Public
-- License Version 6.5 (the "License"). You may not use the content of this file
-- except in compliance with the License. Please obtain a copy of the License
-- at http://www.opencascade.org and read it completely before using this file.
--
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
--
-- The Original Code and all software distributed under the License is
-- distributed on an "AS IS" basis, without warranty of any kind, and the
-- Initial Developer hereby disclaims all such warranties, including without
-- limitation, any warranties of merchantability, fitness for a particular
-- purpose or non-infringement. Please see the License for the specific terms
-- and conditions governing the rights and limitations under the License.
-- Modified: 02-06-98 : FMN ; Suppression appel Clear (deja fait dans ALienData)
class EuclidAlienImage from AlienImage inherits AlienUserImage from AlienImage
---Version: 0.0
---Purpose: This class defines an Euclid Alien image.
---Keywords:
---Warning:
---References:
uses
File from OSD,
AsciiString from TCollection,
ColorImage from Image,
PseudoColorImage from Image,
Image from Image,
EuclidAlienData from AlienImage
is
Create returns mutable EuclidAlienImage from AlienImage;
Clear( me : in out mutable) ;
---Level: Public
---Purpose: Frees memory allocated by EuclidAlienImage
ToImage( me : in immutable )
returns mutable Image from Image ;
---Level: Public
---Purpose : Converts a EuclidAlienImage object to a Image object.
FromImage( me : in out mutable ; anImage : in Image from Image ) ;
---Level: Public
---Purpose : converts a Image object to a EuclidAlienImage object.
Read ( me : in out mutable; afile : in out File from OSD )
returns Boolean from Standard ;
---Purpose: Reads content of a EuclidAlienImage object
-- from a file .
-- Returns True if file is a Euclid file .
Write( me : in immutable; afile : in out File from OSD )
returns Boolean from Standard ;
---Purpose: Writes content of a EuclidAlienImage object
-- to a file .
fields
myData : EuclidAlienData from AlienImage ;
end ;

View File

@ -1,46 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <AlienImage_EuclidAlienImage.ixx>
AlienImage_EuclidAlienImage::AlienImage_EuclidAlienImage()
{ // il faut faire un new si mydata est du type HANDLE
myData = new AlienImage_EuclidAlienData() ;
}
void AlienImage_EuclidAlienImage::Clear()
{ myData->Clear() ; }
Standard_Boolean AlienImage_EuclidAlienImage::Write( OSD_File& file ) const
{ return( myData->Write( file ) ) ; }
Standard_Boolean AlienImage_EuclidAlienImage::Read( OSD_File& file )
{ return( myData->Read( file ) ) ; }
Handle_Image_Image AlienImage_EuclidAlienImage::ToImage() const
{ return( myData->ToImage() ) ; }
void AlienImage_EuclidAlienImage::FromImage( const Handle_Image_Image& anImage )
{ myData->FromImage( anImage ) ; }

View File

@ -1,91 +0,0 @@
-- Created on: 1998-10-20
-- Created by: DCB
-- Copyright (c) 1998-1999 Matra Datavision
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
--
-- The content of this file is subject to the Open CASCADE Technology Public
-- License Version 6.5 (the "License"). You may not use the content of this file
-- except in compliance with the License. Please obtain a copy of the License
-- at http://www.opencascade.org and read it completely before using this file.
--
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
--
-- The Original Code and all software distributed under the License is
-- distributed on an "AS IS" basis, without warranty of any kind, and the
-- Initial Developer hereby disclaims all such warranties, including without
-- limitation, any warranties of merchantability, fitness for a particular
-- purpose or non-infringement. Please see the License for the specific terms
-- and conditions governing the rights and limitations under the License.
private class GIFAlienData from AlienImage inherits AlienImageData from AlienImage
uses
File from OSD,
AsciiString from TCollection,
PseudoColorImage from Image,
ColorImage from Image,
Image from Image
raises
OutOfRange from Standard,
TypeMismatch from Standard
is
Create returns mutable GIFAlienData from AlienImage ;
Clear( me : in out mutable );
---Level: Public
---Purpose: Frees memory allocated by GIFAlienData
---C++: alias ~
Read ( me : in out mutable ; afile : in out File from OSD )
returns Boolean from Standard;
---Level: Public
---Purpose: Read content of a GIFAlienData object from a file
-- Returns True if file is a GIF file .
Write( me : in immutable; afile : in out File from OSD )
returns Boolean from Standard;
---Level: Public
---Purpose: Write content of a GIFAlienData object to a file
ToImage( me : in immutable)
returns mutable Image from Image
raises TypeMismatch from Standard ;
---Level: Public
---Purpose : convert a GIFAlienData object to a Image object.
FromImage( me : in out mutable ; anImage : in Image from Image )
raises TypeMismatch from Standard ;
---Level: Public
---Purpose : convert a Image object to a GIFAlienData object.
------------------------------------------------------
--- Private methods
------------------------------------------------------
FromPseudoColorImage (me : in out mutable;
anImage : in PseudoColorImage from Image )
is private;
---Level: Internal
---Purpose : convert a Image object to a GIFAlienData object.
FromColorImage (me : in out mutable;
anImage : in ColorImage from Image)
is private;
---Level: Internal
---Purpose : convert a Image object to a GIFAlienData object.
fields
myRedColors : Address from Standard;
myGreenColors : Address from Standard;
myBlueColors : Address from Standard;
myData : Address from Standard;
myWidth : Integer from Standard;
myHeight : Integer from Standard;
end;

View File

@ -1,649 +0,0 @@
// Created by: DCB
// Copyright (c) 1998-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
// Notes:
// Read()/Write() code is taken from ZOV's sources from Xw package.
// _convert24to8() sources and all concerned code is taken from
// EUG's code of WNT_ImageProcessor.
#define TEST //GG_140699
// Check GIF format first.
#ifdef WNT
//it is important to undefine NOGDI and enforce including <windows.h> before
//Standard_Macro.hxx defines it and includes <windows.h> making GDI-related
//stuff unavailable and causing compilation errors
#undef NOGDI
#include <windows.h>
#endif
#include <AlienImage_GIFAlienData.ixx>
#include <AlienImage_GIFLZWDict.hxx>
#include <Aspect_GenericColorMap.hxx>
#include <Aspect_ColorMapEntry.hxx>
#include <Image_Convertor.hxx>
#include <Image_DitheringMethod.hxx>
#ifdef _DEBUG
//# define TRACE
#endif
#ifdef TRACE
# include <OSD_Timer.hxx>
#endif
#define STGMGR_ALLOC(size) Standard::Allocate(size)
#define STGMGR_FREE(buf,size) Standard::Free((void*&)buf)
#define COLORS_SIZE 256*sizeof(BYTE)
#define RED ((PBYTE)myRedColors)
#define GREEN ((PBYTE)myGreenColors)
#define BLUE ((PBYTE)myBlueColors)
#define PIXEL ((PBYTE)myData)
#define ZERO_COLORS() \
memset (myRedColors, 0, COLORS_SIZE); \
memset (myGreenColors, 0, COLORS_SIZE); \
memset (myBlueColors, 0, COLORS_SIZE);
#define _ADD_PIXEL(idx) \
{ \
if (y < height) \
*((PBYTE)myData + y*width + x) = ((BYTE)(idx)); \
if (++x == width) { \
x = 0; \
if (!isInterlace) ++y; \
else switch (pass) { \
case 0: y += 8; if (y >= height) ++pass, y = 4; break; \
case 1: y += 8; if (y >= height) ++pass, y = 2; break; \
case 2: y += 4; if (y >= height) ++pass, y = 1; break; \
default: y += 2; \
} \
} \
}
//================================================================
AlienImage_GIFAlienData::AlienImage_GIFAlienData()
: AlienImage_AlienImageData ()
{
myRedColors = NULL;
myGreenColors = NULL;
myBlueColors = NULL;
myData = NULL;
myWidth = 0;
myHeight = 0;
}
//================================================================
void AlienImage_GIFAlienData::Clear ()
{
if (myRedColors) {
STGMGR_FREE (myRedColors, COLORS_SIZE);
myRedColors = NULL;
}
if (myGreenColors) {
STGMGR_FREE (myGreenColors, COLORS_SIZE);
myGreenColors = NULL;
}
if (myBlueColors) {
STGMGR_FREE (myBlueColors, COLORS_SIZE);
myBlueColors = NULL;
}
if (myData) {
STGMGR_FREE (myData, myWidth*myHeight);
myData = NULL;
myWidth = myHeight = 0;
}
}
//================================================================
Standard_Boolean AlienImage_GIFAlienData::Read (OSD_File& file)
{
Standard_Integer nFileSize = file.Size(), nReadCount;
unsigned *OutCode=NULL, *Prefix=NULL, *Suffix=NULL,
BitMask, CodeSize, ClearCode, EOFCode, FreeCode, x, y, pass, width, height,
InitCodeSize, MaxCode, ReadMask, FirstFree, OutCount, BitOffset,
ByteOffset, Code, CurCode, OldCode=0, FinChar=0, InCode;
int isInterlace, hasColormap;
int i, ncolors;
BYTE byte, byte1;
PBYTE pFileStream = NULL;
// Allocate memory to read the file
PBYTE pFileBuffer =
(PBYTE) STGMGR_ALLOC (nFileSize);
PBYTE rasterPtr = NULL, ptr1;
pFileStream = pFileBuffer + 10;
#ifdef TRACE
OSD_Timer timer;
cout << "AlienImage_GIFAlienData::Read () starts" << endl << flush;
timer.Start ();
#endif
// Read file into memory
file.Read ((void*&)pFileBuffer, nFileSize, nReadCount);
if (nFileSize != nReadCount) {
cout << "GIFAlienData::Read() : BAD file size." << endl << flush;
goto _ExitReadError;
}
#ifdef TEST
if( strncmp ((char*)pFileBuffer, "GIF87a", 6) &&
strncmp ((char*)pFileBuffer, "GIF89a", 6) )
goto _ExitReadError;
#endif
// Determine if the image has colormap
byte = *pFileStream++; // Color descriptor byte (M#CR0#BP)
hasColormap = byte & 0x80;
ncolors = hasColormap ? 1<<((byte & 0x07) + 1): 1<<8;
BitMask = ncolors - 1;
pFileStream += 2; // Skip background byte and following zero byte
if (ncolors > 0 && ncolors <= 256) { // Allocate Color Table entries
myRedColors = STGMGR_ALLOC (COLORS_SIZE);
myGreenColors = STGMGR_ALLOC (COLORS_SIZE);
myBlueColors = STGMGR_ALLOC (COLORS_SIZE);
ZERO_COLORS ();
for (i=0; i<ncolors; i++) {
// Fill in array of XColor's used
// Note, that if there's no colormap specified then I use gray scale
RED [i] = ((BYTE)(hasColormap ? *pFileStream++: i));
GREEN[i] = ((BYTE)(hasColormap ? *pFileStream++: i));
BLUE [i] = ((BYTE)(hasColormap ? *pFileStream++: i));
}
} else {
cout << "GIFAlienData::Read() : There's no colormap"
<< " in the image (or too big): " << ncolors << endl << flush;
goto _ExitReadError;
}
// Skip extension blocks if any.
// Format: <'!'><size><...><size><...><0>
while (*pFileStream == '!') {
pFileStream += 2; // skip code byte followed '!' sign
while (*pFileStream)
pFileStream += (unsigned)(1 + *(PBYTE)pFileStream);
pFileStream ++;
}
if (*pFileStream++ != ',') { // must be an image descriptor
cout << "GIFAlienData::Read() : There's no separator"
<< " following the colormap" << endl << flush;
goto _ExitReadError;
}
pFileStream += 2*2; // Skip image left & top offsets
width = (unsigned) *pFileStream++;
width += ((unsigned)*pFileStream++) << 8;
height = (unsigned) *pFileStream++;
height += ((unsigned)*pFileStream++) << 8;
byte = *pFileStream++;
isInterlace = byte & 0x40;
if (byte & 0x80) {
cout << "GIFAlienData::Read() : Can't read GIF image"
<< " with locally defined colormap" << endl << flush;
goto _ExitReadError;
}
// Allocate the pixel buffer
rasterPtr = (PBYTE) STGMGR_ALLOC (nFileSize);
OutCode = (unsigned *) STGMGR_ALLOC (1025 * sizeof (unsigned int));
Prefix = (unsigned *) STGMGR_ALLOC (4096 * sizeof (unsigned int));
Suffix = (unsigned *) STGMGR_ALLOC (4096 * sizeof (unsigned int));
// Decode compressed raster data.
CodeSize = *pFileStream++;
ClearCode = 1 << CodeSize;
EOFCode = ClearCode + 1;
FreeCode = FirstFree = EOFCode + 1;
++CodeSize;
InitCodeSize = CodeSize;
MaxCode = 1 << CodeSize;
ReadMask = MaxCode - 1;
ptr1 = rasterPtr;
// Read encoded data to a continuous array pointed to by rasterPtr
do {
byte = byte1 = *pFileStream++;
while (byte--)
*ptr1++ = *pFileStream++;
if ((long) (ptr1 - rasterPtr) > nFileSize) {// Currupt file
cout << "GIFAlienData::Read() : BAD file size." << endl << flush;
goto _ExitReadError;
}
} while (byte1);
// The file data has been already read
STGMGR_FREE (pFileBuffer, nFileSize);
pFileBuffer = NULL;
// Allocate image data
myWidth = width;
myHeight = height;
myData = STGMGR_ALLOC (myWidth*myHeight);
x = y = pass = OutCount = BitOffset = ByteOffset = 0;
// Fetch the next code (3 to 12 bits) from the raster data stream
Code = rasterPtr[0] + (((unsigned) rasterPtr[1]) << 8);
if (CodeSize >= 8)
Code += ((unsigned) rasterPtr[2]) << 16;
Code >>= BitOffset & 0x7;
BitOffset += CodeSize;
Code &= ReadMask;
while (Code != EOFCode) {
if (Code == ClearCode) {
// Read the next code
CodeSize = InitCodeSize;
MaxCode = 1 << CodeSize;
ReadMask = MaxCode - 1;
FreeCode = FirstFree;
ByteOffset = BitOffset >> 3;
Code = rasterPtr[ByteOffset]
+ (((unsigned) rasterPtr[ByteOffset + 1]) << 8);
if (CodeSize >= 8)
Code += ((unsigned) rasterPtr[ByteOffset + 2]) << 16;
Code >>= BitOffset & 0x7;
BitOffset += CodeSize;
Code &= ReadMask;
CurCode = OldCode = Code;
FinChar = CurCode & BitMask;
_ADD_PIXEL (FinChar);
} else {
CurCode = InCode = Code;
if (CurCode >= FreeCode) {
CurCode = OldCode;
OutCode[OutCount++] = FinChar;
}
while (CurCode > BitMask) {
if (OutCount > 1024) {
cout << "GIFAlienData::Read() : BAD file size." << endl << flush;
goto _ExitReadError;
}
OutCode [OutCount++] = Suffix [CurCode];
CurCode = Prefix [CurCode];
}
FinChar = CurCode & BitMask;
OutCode [OutCount++] = FinChar;
for (i = OutCount - 1; i >= 0; --i)
_ADD_PIXEL (OutCode [i]);
OutCount = 0;
Prefix [FreeCode] = OldCode;
Suffix [FreeCode] = FinChar;
OldCode = InCode;
++FreeCode;
if (FreeCode >= MaxCode) {
if (CodeSize < 12) {
++CodeSize;
MaxCode <<= 1;
ReadMask = (1 << CodeSize) - 1;
}
}
}
ByteOffset = BitOffset >> 3;
Code = (unsigned) rasterPtr[ByteOffset]
+ (((unsigned) rasterPtr[ByteOffset + 1]) << 8);
if (CodeSize >= 8)
Code += ((unsigned) rasterPtr[ByteOffset + 2]) << 16;
Code >>= (BitOffset & 0x7);
BitOffset += CodeSize;
Code &= ReadMask;
} // while (Code != EOFCode)
// Free allocated memory
STGMGR_FREE (rasterPtr, nFileSize);
STGMGR_FREE (OutCode, 1025 * sizeof (unsigned int));
STGMGR_FREE (Prefix, 4096 * sizeof (unsigned int));
STGMGR_FREE (Suffix, 4096 * sizeof (unsigned int));
#ifdef TRACE
timer.Stop ();
timer.Show (cout);
cout << "AlienImage_GIFAlienData::Read () finished\n" << endl << flush;
#endif
return Standard_True;
_ExitReadError:
// cout << "GIFAlienData::Read() : Read file error." << endl << flush;
if (pFileBuffer) STGMGR_FREE (pFileBuffer, nFileSize);
if (OutCode) STGMGR_FREE (OutCode, 1025 * sizeof (unsigned int));
if (Prefix) STGMGR_FREE (Prefix, 4096 * sizeof (unsigned int));
if (Suffix) STGMGR_FREE (Suffix, 4096 * sizeof (unsigned int));
if (myRedColors) {
STGMGR_FREE (myRedColors, COLORS_SIZE);
myRedColors = NULL;
}
if (myGreenColors) {
STGMGR_FREE (myGreenColors, COLORS_SIZE);
myGreenColors = NULL;
}
if (myBlueColors) {
STGMGR_FREE (myBlueColors, COLORS_SIZE);
myBlueColors = NULL;
}
if (myData) {
STGMGR_FREE (myData, myWidth*myHeight);
myData = NULL;
myWidth = myHeight = 0;
}
return Standard_False;
}
//================================================================
Standard_Boolean AlienImage_GIFAlienData::Write (OSD_File& file) const
{
SCREEN_DESCR sd;
IMAGE_DESCR id;
BYTE image_sep = 0x2C; // gif colormap delimiter
WORD wZero = 0x00;
BYTE colors256 [256][3];
BYTE bEnd = 0x3B;
int i;
#ifdef TRACE
OSD_Timer timer;
cout << "AlienImage_GIFAlienData::Write () starts" << endl << flush;
timer.Start ();
#endif
// Check if image is loaded
if (myData == NULL || myRedColors == NULL ||
myGreenColors == NULL || myBlueColors == NULL ||
myWidth == 0 || myHeight == 0)
goto _ExitWriteError;
// Build file header
memcpy (sd.gifID, "GIF87a", 6);
sd.scrnWidth = SWAP_WORD ((WORD) myWidth );
sd.scrnHeight = SWAP_WORD ((WORD) myHeight);
sd.scrnFlag = 0x80 | ( ( 7/*[=depth-1]*/ << 4 ) & 0x70 ) | 0x07;
id.imgX = 0;
id.imgY = 0;
id.imgWidth = SWAP_WORD ((WORD) myWidth );
id.imgHeight = SWAP_WORD ((WORD) myHeight);
// imgFlag
// +-+-+-+-+-+-----+ M=0 - Use global color map, ignore 'pixel'
// |M|I|0|0|0|pixel| 10 M=1 - Local color map follows, use 'pixel'
// +-+-+-+-+-+-----+ I=0 - Image formatted in Sequential order
// I=1 - Image formatted in Interlaced order
// pixel+1 - # bits per pixel for this image
id.imgFlag = 0x07; // Global color map, Sequential order, 8 bits per pixel
for (i = 0; i < 256; i++) {
colors256[i] [0/*R*/] = RED [i];
colors256[i] [1/*G*/] = GREEN [i];
colors256[i] [2/*B*/] = BLUE [i];
}
// Write off the buffers
file.Write (&sd, 11); // Screen descriptor
if (file.Failed())
goto _ExitWriteError;
file.Write (&wZero, 2); // Zero word
if (file.Failed())
goto _ExitWriteError;
file.Write (colors256, 256*3); // Colormap
if (file.Failed())
goto _ExitWriteError;
file.Write (&image_sep, 1); // Separator
if (file.Failed())
goto _ExitWriteError;
file.Write (&id, 9); // Image descriptor
if (file.Failed())
goto _ExitWriteError;
// Write off the image data
if (!_lzw_encode (file, (PBYTE) myData, myWidth, myHeight, myWidth))
goto _ExitWriteError;
file.Write (&bEnd, 1); // End of image
if (file.Failed())
goto _ExitWriteError;
// Return SUCCESS status if there were no errors.
#ifdef TRACE
timer.Stop ();
timer.Show (cout);
cout << "AlienImage_GIFAlienData::Write () finished\n" << endl << flush;
#endif
return Standard_True;
// Exit on error
_ExitWriteError:
file.Seek (0, OSD_FromBeginning);
return Standard_False;
}
//================================================================
Handle_Image_Image AlienImage_GIFAlienData::ToImage () const
{
#ifdef TRACE
OSD_Timer timer;
cout << "AlienImage_GIFAlienData::ToImage () starts" << endl << flush;
timer.Start ();
#endif
Standard_Integer i, x, y, LowX, LowY;
Standard_Real r, g, b;
Aspect_ColorMapEntry entry;
Aspect_IndexPixel index;
Quantity_Color color;
// Build colormap
Handle(Aspect_GenericColorMap) aColorMap =
new Aspect_GenericColorMap ();
for (i = 0; i < 256; i++) {
r = ((float)RED [i] / 255.);
g = ((float)GREEN [i] / 255.);
b = ((float)BLUE [i] / 255.);
color.SetValues (r, g, b, Quantity_TOC_RGB);
entry.SetValue (i, color);
aColorMap -> AddEntry (entry);
}
// Fill image data
Handle(Image_Image) theImage =
new Image_PseudoColorImage (0, 0, myWidth, myHeight, aColorMap);
LowX = theImage -> LowerX ();
LowY = theImage -> LowerY ();
for (y = 0; y < myHeight; y++) {
for (x = 0; x < myWidth; x++) {
index.SetValue (PIXEL[y*myWidth + x]);
theImage -> SetPixel (LowX + x, LowY + y, index);
}
}
#ifdef TRACE
timer.Stop ();
timer.Show (cout);
cout << "AlienImage_GIFAlienData::ToImage () finished\n" << endl << flush;
#endif
return theImage;
}
//================================================================
void AlienImage_GIFAlienData::FromImage (const Handle_Image_Image& anImage)
{
if (anImage -> Type() == Image_TOI_PseudoColorImage) {
// Build from PseudoColorImage
Handle(Image_PseudoColorImage) aPImage =
Handle(Image_PseudoColorImage)::DownCast(anImage);
FromPseudoColorImage (aPImage);
} else if (anImage -> Type() == Image_TOI_ColorImage) {
// Build from ColorImage
Handle(Image_ColorImage) aCImage =
Handle(Image_ColorImage)::DownCast(anImage);
FromColorImage (aCImage);
} else {
// Unknown type of image
Standard_TypeMismatch_Raise_if (Standard_True,
"Attempt to convert a unknown Image_Image type to a GIFAlienData");
}
}
//================================================================
void AlienImage_GIFAlienData::FromPseudoColorImage (
const Handle(Image_PseudoColorImage)& anImage)
{
int width = anImage -> Width ();
int height = anImage -> Height ();
unsigned short x, y, i;
Standard_Real r, g, b;
Aspect_ColorMapEntry entry;
Aspect_IndexPixel index;
Quantity_Color color;
Standard_Integer LowX = anImage -> LowerX();
Standard_Integer LowY = anImage -> LowerY();
BYTE ei;
#ifdef TRACE
OSD_Timer timer;
cout << "AlienImage_GIFAlienData::FromPseudoColorImage () starts" << endl << flush;
timer.Start ();
#endif
if (width*height > 0) {
Handle(Aspect_ColorMap) aColorMap = anImage -> ColorMap ();
// Clear old values if any
Clear ();
myRedColors = STGMGR_ALLOC (COLORS_SIZE);
myGreenColors = STGMGR_ALLOC (COLORS_SIZE);
myBlueColors = STGMGR_ALLOC (COLORS_SIZE);
ZERO_COLORS ();
// Build colors from colormap
for (i = 1; i <= aColorMap -> Size (); i++) {
entry = aColorMap -> Entry (i);
ei = entry.Index ();
color = entry.Color ();
color.Values (r, g, b, Quantity_TOC_RGB);
RED [ei] = (BYTE)(r*255.);
GREEN[ei] = (BYTE)(g*255.);
BLUE [ei] = (BYTE)(b*255.);
}
// Build imagedata from Image_PseudoColorImage
myWidth = width;
myHeight = height;
myData = STGMGR_ALLOC (myWidth*myHeight);
for (y = 0; y < myHeight; y++) {
for (x = 0; x < myWidth; x++) {
index = anImage -> Pixel (LowX + x, LowY + y);
PIXEL[y*myWidth + x] = (BYTE)index.Value ();
}
}
}
#ifdef TRACE
timer.Stop ();
timer.Show (cout);
cout << "AlienImage_GIFAlienData::FromPseudoColorImage () finished\n" << endl << flush;
#endif
}
//================================================================
void AlienImage_GIFAlienData::FromColorImage (
const Handle(Image_ColorImage)& anImage)
{
#ifdef TRACE
OSD_Timer timer;
cout << "AlienImage_GIFAlienData::FromColorImage () starts" << endl << flush;
timer.Start ();
#endif // TRACE
int width = anImage -> Width ();
int height = anImage -> Height ();
int i, x, y, LowX = anImage -> LowerX(), LowY = anImage -> LowerY();
Quantity_Color color;
Standard_Real r, g, b;
if (width*height > 0) {
Aspect_ColorMapEntry entry;
// Clear old values if any
Clear ();
myWidth = width;
myHeight = height;
LPRGBQUAD pColors = (LPRGBQUAD) STGMGR_ALLOC (256*sizeof(RGBQUAD));
PBYTE pBits24 = (PBYTE) STGMGR_ALLOC (width*height*3);
memset (pColors, 0, 256*sizeof(RGBQUAD));
myData = STGMGR_ALLOC (width*height);
myRedColors = STGMGR_ALLOC (COLORS_SIZE);
myGreenColors = STGMGR_ALLOC (COLORS_SIZE);
myBlueColors = STGMGR_ALLOC (COLORS_SIZE);
for (y = 0, i = 0; y < myHeight; y++) {
for (x = 0; x < myWidth; x++) {
color = anImage -> PixelColor (LowX + x, LowY + y);
color.Values (r, g, b, Quantity_TOC_RGB);
pBits24 [i + 0] = (BYTE)(b*255.);
pBits24 [i + 1] = (BYTE)(g*255.);
pBits24 [i + 2] = (BYTE)(r*255.);
i += 3;
}
}
if (_convert24to8 (pColors, pBits24, (PBYTE)myData, myWidth, myHeight)) {
Handle(Aspect_GenericColorMap) aColorMap = new Aspect_GenericColorMap ();
for (i = 0; i < 256; i++) {
r = ((float)pColors[i].rgbRed / 255.);
g = ((float)pColors[i].rgbGreen / 255.);
b = ((float)pColors[i].rgbBlue / 255.);
color.SetValues (r, g, b, Quantity_TOC_RGB);
entry.SetValue (i, color);
aColorMap -> AddEntry (entry);
RED [i] = pColors[i].rgbRed;
GREEN[i] = pColors[i].rgbGreen;
BLUE [i] = pColors[i].rgbBlue;
}
} else {
Image_Convertor aConvertor;
aConvertor.SetDitheringMethod (Image_DM_ErrorDiffusion);
Handle(Aspect_ColorMap) aColorMap = anImage -> ChooseColorMap (256);
Handle(Image_PseudoColorImage) aPImage =
aConvertor.Convert (anImage, aColorMap);
FromPseudoColorImage (aPImage);
}
STGMGR_FREE (pColors, 256*sizeof(RGBQUAD));
STGMGR_FREE (pBits24, width*height*3);
}
#ifdef TRACE
timer.Stop ();
timer.Show (cout);
cout << "AlienImage_GIFAlienData::FromColorImage () finished\n" << endl << flush;
#endif // TRACE
}

View File

@ -1,73 +0,0 @@
-- Created on: 1998-10-20
-- Created by: DCB
-- Copyright (c) 1998-1999 Matra Datavision
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
--
-- The content of this file is subject to the Open CASCADE Technology Public
-- License Version 6.5 (the "License"). You may not use the content of this file
-- except in compliance with the License. Please obtain a copy of the License
-- at http://www.opencascade.org and read it completely before using this file.
--
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
--
-- The Original Code and all software distributed under the License is
-- distributed on an "AS IS" basis, without warranty of any kind, and the
-- Initial Developer hereby disclaims all such warranties, including without
-- limitation, any warranties of merchantability, fitness for a particular
-- purpose or non-infringement. Please see the License for the specific terms
-- and conditions governing the rights and limitations under the License.
class GIFAlienImage from AlienImage inherits AlienUserImage from AlienImage
uses
GIFAlienData from AlienImage,
File from OSD,
AsciiString from TCollection,
Image from Image
is
Create
returns mutable GIFAlienImage from AlienImage;
Clear( me : in out mutable) ;
---Level: Public
---Purpose: Frees memory allocated by GIFAlienImage
---C++: alias ~
SetName( me : in out mutable;
aName : in AsciiString from TCollection) ;
---Level: Public
---Purpose: Set Image name .
Name( me : in immutable ) returns AsciiString from TCollection ;
---C++: return const &
---Level: Public
---Purpose: get Image name .
ToImage( me : in immutable )
returns mutable Image from Image ;
---Level: Public
---Purpose : convert a GIFAlienImage object to a Image object.
FromImage( me : in out mutable ; anImage : in Image from Image ) ;
---Level: Public
---Purpose : convert a Image object to a GIFAlienImage object.
Read ( me : in out mutable; afile : in out File from OSD )
returns Boolean from Standard ;
---Level: Public
---Purpose: Read content of a GIFAlienImage object from a file .
-- Returns True if file is a GIF file .
Write( me : in immutable; afile : in out File from OSD )
returns Boolean from Standard ;
---Level: Public
---Purpose: Write content of a GIFAlienImage object to a file .
fields
myData : GIFAlienData from AlienImage;
end;

View File

@ -1,70 +0,0 @@
// Created by: DCB
// Copyright (c) 1998-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <AlienImage_GIFAlienImage.ixx>
//================================================================
AlienImage_GIFAlienImage::AlienImage_GIFAlienImage ()
{
myData = new AlienImage_GIFAlienData() ;
}
//================================================================
void AlienImage_GIFAlienImage::Clear ()
{
myData->Clear();
}
//================================================================
void AlienImage_GIFAlienImage::SetName (const TCollection_AsciiString& aName)
{
myData->SetName (aName);
}
//================================================================
const TCollection_AsciiString& AlienImage_GIFAlienImage::Name () const
{
return (myData->Name());
}
//================================================================
Standard_Boolean AlienImage_GIFAlienImage::Write (OSD_File& file) const
{
return myData->Write(file);
}
//================================================================
Standard_Boolean AlienImage_GIFAlienImage::Read (OSD_File& file)
{
return myData->Read(file);
}
//================================================================
Handle_Image_Image AlienImage_GIFAlienImage::ToImage () const
{
return myData->ToImage();
}
//================================================================
void AlienImage_GIFAlienImage::FromImage (const Handle_Image_Image& anImage)
{
myData->FromImage(anImage);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,114 +0,0 @@
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
//============================================================================
//==== Titre: AlienImage_GIFLZWDict.hxx
//============================================================================
#ifndef _AlienImage_GIFLZWDict_HeaderFile
#define _AlienImage_GIFLZWDict_HeaderFile
//==== Definition de Type ====================================================
#include <Standard_Type.hxx>
const Handle(Standard_Type)& STANDARD_TYPE(AlienImage_GIFLZWDict);
//============================================================================
#include <OSD_File.hxx>
#ifndef WNT
typedef unsigned int DWORD; // 32-bit signed
typedef int LONG; // 32-bit unsigned
typedef unsigned int ULONG, UINT; // 32-bit signed
typedef unsigned short WORD; // 16-bit unsigned
typedef unsigned char BYTE; // 8-bit unsigned
typedef unsigned int BOOL;
typedef int* PINT;
typedef unsigned char* PBYTE;
typedef void* LPVOID;
#else
#ifdef NOGDI
#undef NOGDI /* we need GDI definitions here... */
#endif
# include <windows.h>
#endif
#if defined(__alpha) || defined(DECOSF1) || defined(WNT)
# define SWAP_WORD(__w) (__w)
# define SWAP_DWORD(__w) (__w)
#else
# define SWAP_WORD(__w) ((((__w)&0xFF) << 8) | (((__w)&0xFF00) >> 8))
# define SWAP_DWORD(__w) ((((__w)&0x000000FF) << 24) | (((__w)&0x0000FF00) << 8) \
| (((__w)&0xFF0000) >> 8) | (((__w)&0xFF000000) >> 24) )
#endif
#define NBITS 12
#define TBL_SIZE 5021
#define MAX_CODE ( ( 1 << NBITS ) - 1 )
#define BUFF_SIZE 255
#define UNUSED -1
#define TRUE 1
#define FALSE 0
//=============================================================================
// Functions and structs to write GIF image to file.
//=============================================================================
extern int _lzw_encode (OSD_File&, const BYTE*, int, int, int);
typedef struct {
char gifID[ 6 ];
WORD scrnWidth;
WORD scrnHeight;
BYTE scrnFlag;
} SCREEN_DESCR;
typedef struct {
WORD imgX;
WORD imgY;
WORD imgWidth;
WORD imgHeight;
BYTE imgFlag;
} IMAGE_DESCR;
typedef struct {
int code;
int prnt;
BYTE byte;
} AlienImage_GIFLZWDict;
//=============================================================================
// Functions to convert from 24 to 8 color image
//=============================================================================
#define PAD(a) ( ( a ) % sizeof ( LONG ) ? \
sizeof ( LONG ) - ( ( a ) % sizeof ( LONG ) ) : 0 )
#define MALLOC(s) calloc ( ( s ), 1 )
#define FREE(p) free ( ( p ) )
#ifndef WNT
typedef struct {
BYTE rgbBlue;
BYTE rgbGreen;
BYTE rgbRed;
BYTE rgbReserved;
} RGBQUAD, *LPRGBQUAD;
#define __fastcall
#endif // WNT
BOOL __fastcall _convert24to8 (LPRGBQUAD, PBYTE, PBYTE, int, int);
#endif // _AlienImage_GIFLZWDict_HeaderFile

View File

@ -1,57 +0,0 @@
-- Created on: 1993-03-23
-- Created by: BBL,JLF
-- Copyright (c) 1993-1999 Matra Datavision
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
--
-- The content of this file is subject to the Open CASCADE Technology Public
-- License Version 6.5 (the "License"). You may not use the content of this file
-- except in compliance with the License. Please obtain a copy of the License
-- at http://www.opencascade.org and read it completely before using this file.
--
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
--
-- The Original Code and all software distributed under the License is
-- distributed on an "AS IS" basis, without warranty of any kind, and the
-- Initial Developer hereby disclaims all such warranties, including without
-- limitation, any warranties of merchantability, fitness for a particular
-- purpose or non-infringement. Please see the License for the specific terms
-- and conditions governing the rights and limitations under the License.
class MemoryOperations from AlienImage
---Version: 0.0
---Level: Public
---Purpose: This class defines class method for
-- memory mangement .
---Keywords:
---Warning:
---References:
--uses
raises
NullObject
is
SwapLong ( myclass ; Data : in Address from Standard
; Size : in Integer from Standard )
---Level: Internal
---Purpose: Swap byte in a long word ( 32 Bit )
-- Size is the number of long word to swap
-- ex : SwapLong( "abcd". 1 ) gives "dcba"
--
raises NullObject;
SwapShort( myclass ; Data : in Address from Standard
; Size : in Integer from Standard )
---Level: Internal
---Purpose: Swap byte in a short word ( 16 Bit )
-- Size is the number of short word to swap
-- ex : SwapShort( "ab". 1 ) gives "ba"
--
raises NullObject;
end MemoryOperations;

View File

@ -1,68 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <Standard_NullObject.hxx>
#include <AlienImage_MemoryOperations.ixx>
void AlienImage_MemoryOperations::SwapLong( const Standard_Address Data,
const Standard_Integer Size )
{
register char c;
register char *bp = ( char * )Data ;
register char *ep = ( char * )Data + Size ;
register char *sp;
if ( Data == NULL)
Standard_NullObject::Raise("AlienImage_MemoryOperations : SwapLong");
while (bp < ep) {
sp = bp + 3;
c = *sp;
*sp = *bp;
*bp++ = c;
sp = bp + 1;
c = *sp;
*sp = *bp;
*bp++ = c;
bp += 2;
}
}
void AlienImage_MemoryOperations::SwapShort( const Standard_Address Data,
const Standard_Integer Size )
{
register char c;
register char *ep = ( char * )Data + Size ;
register char *bp = ( char * )Data ;
if ( Data == NULL)
Standard_NullObject::Raise("AlienImage_MemoryOperations : SwapLong");
while (bp < ep) {
c = *bp;
*bp = *(bp + 1);
bp++;
*bp++ = c;
}
}

View File

@ -1,107 +0,0 @@
-- Created on: 1993-03-23
-- Created by: BBL
-- Copyright (c) 1993-1999 Matra Datavision
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
--
-- The content of this file is subject to the Open CASCADE Technology Public
-- License Version 6.5 (the "License"). You may not use the content of this file
-- except in compliance with the License. Please obtain a copy of the License
-- at http://www.opencascade.org and read it completely before using this file.
--
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
--
-- The Original Code and all software distributed under the License is
-- distributed on an "AS IS" basis, without warranty of any kind, and the
-- Initial Developer hereby disclaims all such warranties, including without
-- limitation, any warranties of merchantability, fitness for a particular
-- purpose or non-infringement. Please see the License for the specific terms
-- and conditions governing the rights and limitations under the License.
class SGIRGBAlienData from AlienImage inherits AlienImageData from AlienImage
---Version: 0.0
---Purpose: This class defines a SGI .rgb Alien image.
---Keywords:
---Warning:
---References:
uses
File from OSD,
AsciiString from TCollection,
ColorImage from Image,
PseudoColorImage from Image,
Image from Image,
X11XColor from AlienImage,
SGIRGBFileHeader from AlienImage
raises
OutOfRange from Standard,
TypeMismatch from Standard
is
Create returns mutable SGIRGBAlienData from AlienImage ;
Clear( me : in out mutable ) ;
---Level: Public
---Purpose: Frees memory allocated by SGIRGBAlienData
---C++: alias ~
Read ( me : in out mutable ; afile : in out File from OSD )
returns Boolean from Standard ;
---Level: Public
---Purpose: Read content of a SGIRGBAlienData object from a file .
-- Returns True if file is a SGI .rgb file .
Write( me : in immutable; afile : in out File from OSD )
returns Boolean from Standard ;
---Level: Public
---Purpose: Write content of a SGIRGBAlienData object to a file .
SetName( me : in out mutable ;
aName : in AsciiString from TCollection)
is redefined;
---Level: Public
---Purpose: Set Image name .
Name( me : in immutable ) returns AsciiString from TCollection
is redefined;
---C++: return const &
---Level: Public
---Purpose: Get Image name .
ToImage( me : in immutable)
returns mutable Image from Image
raises TypeMismatch from Standard ;
---Level: Public
---Purpose : convert a SGIRGBAlienData object to a Image object.
FromImage( me : in out mutable ; anImage : in Image from Image )
raises TypeMismatch from Standard ;
---Level: Public
---Purpose : convert a Image object to a SGIRGBAlienData object.
--
-- Private Method
--
ToPseudoColorImage( me : in immutable)
returns PseudoColorImage from Image is private ;
---Level: Internal
---Purpose : convert a AlienImage object to a Image object.
ToColorImage( me : in immutable)
returns ColorImage from Image is private ;
---Level: Internal
---Purpose : convert a AlienImage object to a Image object.
fields
myHeader : SGIRGBFileHeader from AlienImage is protected ;
myRedData, myGreenData, myBlueData : Address from Standard is protected;
-- ( unsigned short * )
end ;

File diff suppressed because it is too large Load Diff

View File

@ -1,75 +0,0 @@
-- Created on: 1993-03-23
-- Created by: BBL
-- Copyright (c) 1993-1999 Matra Datavision
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
--
-- The content of this file is subject to the Open CASCADE Technology Public
-- License Version 6.5 (the "License"). You may not use the content of this file
-- except in compliance with the License. Please obtain a copy of the License
-- at http://www.opencascade.org and read it completely before using this file.
--
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
--
-- The Original Code and all software distributed under the License is
-- distributed on an "AS IS" basis, without warranty of any kind, and the
-- Initial Developer hereby disclaims all such warranties, including without
-- limitation, any warranties of merchantability, fitness for a particular
-- purpose or non-infringement. Please see the License for the specific terms
-- and conditions governing the rights and limitations under the License.
-- Modified: 02-06-98 : FMN ; Suppression appel Clear (deja fait dans ALienData)
class SGIRGBAlienImage from AlienImage inherits AlienUserImage from AlienImage
---Purpose: Defines an SGI .rgb Alien image, i.e. an image using
-- the image format for Silicon Graphics workstations.
uses
File from OSD,
AsciiString from TCollection,
ColorImage from Image,
PseudoColorImage from Image,
Image from Image,
SGIRGBAlienData from AlienImage
is
Create returns mutable SGIRGBAlienImage from AlienImage;
---Purpose: Constructs an empty SGI .rgb Alien image.
Clear( me : in out mutable) ;
---Level: Public
---Purpose: Frees memory allocated by SGIRGBAlienImage
SetName( me : in out mutable;
aName : in AsciiString from TCollection) ;
---Level: Public
---Purpose: Set Image name .
Name( me : in immutable ) returns AsciiString from TCollection ;
---C++: return const &
---Purpose: Reads the Image name .
ToImage( me : in immutable )
returns mutable Image from Image ;
---Level: Public
---Purpose : Converts a SGIRGBAlienImage object to a Image object.
FromImage( me : in out mutable ; anImage : in Image from Image ) ;
---Level: Public
---Purpose : Converts a Image object to a SGIRGBAlienImage object.
Read ( me : in out mutable; afile : in out File from OSD )
returns Boolean from Standard ;
---Purpose: Reads content of a SGIRGBAlienImage object from a file
-- Returns True if file is a XWD file .
Write( me : in immutable; afile : in out File from OSD )
returns Boolean from Standard ;
---Purpose: Writes content of a SGIRGBAlienImage object to a file
fields
myData : SGIRGBAlienData from AlienImage;
end ;

View File

@ -1,53 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <AlienImage_SGIRGBAlienImage.ixx>
AlienImage_SGIRGBAlienImage::AlienImage_SGIRGBAlienImage()
{ // il faut faire un new si mydata est du type HANDLE
myData = new AlienImage_SGIRGBAlienData() ;
}
void AlienImage_SGIRGBAlienImage::SetName( const TCollection_AsciiString& aName)
{ myData->SetName( aName ) ; }
const TCollection_AsciiString& AlienImage_SGIRGBAlienImage::Name() const
{ return( myData->Name() ) ; }
void AlienImage_SGIRGBAlienImage::Clear()
{ myData->Clear() ; }
Standard_Boolean AlienImage_SGIRGBAlienImage::Write( OSD_File& file ) const
{ return( myData->Write( file ) ) ; }
Standard_Boolean AlienImage_SGIRGBAlienImage::Read( OSD_File& file )
{ return( myData->Read( file ) ) ; }
Handle_Image_Image AlienImage_SGIRGBAlienImage::ToImage() const
{ return( myData->ToImage() ) ; }
void AlienImage_SGIRGBAlienImage::FromImage( const Handle_Image_Image& anImage )
{ myData->FromImage( anImage ) ; }

View File

@ -1,50 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <AlienImage_SGIRGBFileHeader.hxx>
const Handle(Standard_Type)& STANDARD_TYPE(AlienImage_SGIRGBFileHeader)
{
static Handle(Standard_Type) _atype =
new Standard_Type ("AlienImage_SGIRGBFileHeader", sizeof (AlienImage_SGIRGBFileHeader));
return _atype;
}
Standard_Boolean operator == ( const AlienImage_SGIRGBFileHeader& AnObject,
const AlienImage_SGIRGBFileHeader& AnotherObject )
{ Standard_Boolean _result = Standard_True;
return _result;
}
//============================================================================
//==== ShallowDump : Writes a CString value.
//============================================================================
void ShallowDump (const AlienImage_SGIRGBFileHeader& AnObject, Standard_OStream& s)
{
s << "AlienImage_SGIRGBFileHeader\n" ;
}
ostream& operator << ( ostream& s, const AlienImage_SGIRGBFileHeader& c )
{
return( s << "AlienImage_SGIRGBFileHeader " );
}

View File

@ -1,104 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
//============================================================================
//==== Titre: AlienImage_SGIRGBFileHeader.hxx
//==== Role : The header file of primitve type "SGIRGBFileHeader"
//==== Implementation: This is a primitive type implemented with typedef
//==== typedef SGIRGBSGIRGBFileHeader AlienImage_SGIRGBFileHeader;
//============================================================================
#ifndef _AlienImage_SGIRGBFileHeader_HeaderFile
#define _AlienImage_SGIRGBFileHeader_HeaderFile
//==== Definition de Type ====================================================
#include <Standard_Type.hxx>
const Handle(Standard_Type)& STANDARD_TYPE(AlienImage_SGIRGBFileHeader);
//============================================================================
#define IMAGIC 0732
/* colormap of images */
#define CM_NORMAL 0 /* file contains rows of values which
* are either RGB values (zsize == 3)
* or greyramp values (zsize == 1) */
#define CM_DITHERED 1
#define CM_SCREEN 2 /* file contains data which is a screen
* image; getrow returns buffer which
* can be displayed directly with
* writepixels */
#define CM_COLORMAP 3 /* a colormap file */
#define TYPEMASK 0xff00
#define BPPMASK 0x00ff
#define ITYPE_VERBATIM 0x0000
#define ITYPE_RLE 0x0100
#define ISRLE(type) (((type) & 0xff00) == ITYPE_RLE)
#define ISVERBATIM(type) (((type) & 0xff00) == ITYPE_VERBATIM)
#define BPP(type) ((type) & BPPMASK)
#define RLE(bpp) (ITYPE_RLE | (bpp))
#define VERBATIM(bpp) (ITYPE_VERBATIM | (bpp))
#define IBUFSIZE(pixels) ((pixels+(pixels>>6))<<2)
#define RLE_NOP 0x00
#define ierror(p) (((p)->flags&_IOERR)!=0)
#define ifileno(p) ((p)->file)
#define getpix(p) (--(p)->cnt>=0 ? *(p)->ptr++ : ifilbuf(p))
#define putpix(p,x) (--(p)->cnt>=0 \
? ((int)(*(p)->ptr++=(unsigned)(x))) \
: iflsbuf(p,(unsigned)(x)))
typedef struct {
unsigned short imagic; /* stuff saved on disk . . */
unsigned short type;
unsigned short dim;
unsigned short xsize;
unsigned short ysize;
unsigned short zsize;
unsigned int min;
unsigned int max;
unsigned int wastebytes;
char name[80];
unsigned int colormap;
int file; /* stuff used in core only */
unsigned short flags;
short dorev;
short x;
short y;
short z;
short cnt;
unsigned short *ptr;
unsigned short *base;
unsigned short *tmpbuf;
unsigned int offset;
unsigned int rleend; /* for rle images */
unsigned int *rowstart; /* for rle images */
int *rowsize; /* for rle images */
} AlienImage_SGIRGBFileHeader;
AlienImage_SGIRGBFileHeader *iopen();
AlienImage_SGIRGBFileHeader *icreate();
ostream& operator << ( ostream& s, const AlienImage_SGIRGBFileHeader& h );
Standard_Boolean operator==(const AlienImage_SGIRGBFileHeader& AnObject,
const AlienImage_SGIRGBFileHeader& AnotherObject) ;
void ShallowDump (const AlienImage_SGIRGBFileHeader& AnObject,Standard_OStream& S) ;
#endif

View File

@ -1,57 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <AlienImage_SUNRFFileHeader.hxx>
const Handle(Standard_Type)& STANDARD_TYPE(AlienImage_SUNRFFileHeader)
{
static Handle(Standard_Type) _atype =
new Standard_Type ("AlienImage_SUNRFFileHeader", sizeof (AlienImage_SUNRFFileHeader));
return _atype;
}
Standard_Boolean operator == ( const AlienImage_SUNRFFileHeader& AnObject,
const AlienImage_SUNRFFileHeader& AnotherObject )
{ Standard_Boolean _result = Standard_True;
return _result;
}
//============================================================================
//==== ShallowDump : Writes a CString value.
//============================================================================
void ShallowDump (const AlienImage_SUNRFFileHeader& AnObject, Standard_OStream& s)
{
s << AnObject ;
}
ostream& operator << ( ostream& s, const AlienImage_SUNRFFileHeader& c )
{
return( s << "AlienImage_SUNRFFileHeader :"
<< "\n\tmagic :" << c.ras_magic
<< "\n\twidth :" << c.ras_width
<< "\n\theight :" << c.ras_height
<< "\n\tdepth :" << c.ras_depth
<< "\n\tlength :" << c.ras_length
<< "\n\tmaptype :" << c.ras_maptype
<< "\n\tmaplength:" << c.ras_maplength << endl << flush );
}

View File

@ -1,83 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
//============================================================================
//==== Titre: AlienImage_SUNRFFileHeader.hxx
//==== Role : The header file of primitve type "SUNRFFileHeader"
//==== Implementation: This is a primitive type implemented with typedef
//==== typedef SUNRFSUNRFFileHeader AlienImage_SUNRFFileHeader;
//============================================================================
#ifndef _AlienImage_SUNRFFileHeader_HeaderFile
#define _AlienImage_SUNRFFileHeader_HeaderFile
//==== Definition de Type ====================================================
#include <Standard_Type.hxx>
const Handle(Standard_Type)& STANDARD_TYPE(AlienImage_SUNRFFileHeader);
//============================================================================
#define RAS_MAGIC 0x59a66a95
/* Sun supported ras_type's */
#define RT_OLD 0 /* Raw pixrect image in 68000 byte order */
#define RT_STANDARD 1 /* Raw pixrect image in 68000 byte order */
#define RT_BYTE_ENCODED 2 /* Run-length compression of bytes */
#define RT_FORMAT_RGB 3 /* XRGB or RGB instead of XBGR or BGR */
#define RT_FORMAT_TIFF 4 /* tiff <-> standard rasterfile */
#define RT_FORMAT_IFF 5 /* iff (TAAC format) <-> standard rasterfile */
#define RT_EXPERIMENTAL 0xffff /* Reserved for testing */
/* Sun registered ras_maptype's */
#define RMT_RAW 2
/* Sun supported ras_maptype's */
#define RMT_NONE 0 /* ras_maplength is expected to be 0 */
#define RMT_EQUAL_RGB 1 /* red[ras_maplength/3],green[],blue[] */
/*
* NOTES:
* Each line of the image is rounded out to a multiple of 16 bits.
* This corresponds to the rounding convention used by the memory pixrect
* package (/usr/include/pixrect/memvar.h) of the SunWindows system.
* The ras_encoding field (always set to 0 by Sun's supported software)
* was renamed to ras_length in release 2.0. As a result, rasterfiles
* of type 0 generated by the old software claim to have 0 length; for
* compatibility, code reading rasterfiles must be prepared to compute the
* true length from the width, height, and depth fields.
*/
typedef struct {
int ras_magic; /* magic number */
int ras_width; /* width (pixels) of image */
int ras_height; /* height (pixels) of image */
int ras_depth; /* depth (1, 8, or 24 bits) of pixel */
int ras_length; /* length (bytes) of image */
int ras_type; /* type of file; see RT_* below */
int ras_maptype; /* type of colormap; see RMT_* below */
int ras_maplength; /* length (bytes) of following map */
/* color map follows for ras_maplength bytes, followed by image */
} AlienImage_SUNRFFileHeader;
ostream& operator << ( ostream& s, const AlienImage_SUNRFFileHeader& h );
Standard_Boolean operator==(const AlienImage_SUNRFFileHeader& Obj1,
const AlienImage_SUNRFFileHeader& Obj2) ;
void ShallowDump (const AlienImage_SUNRFFileHeader& AnObject,Standard_OStream& S) ;
#endif

View File

@ -1,141 +0,0 @@
-- Created on: 1993-03-23
-- Created by: BBL
-- Copyright (c) 1993-1999 Matra Datavision
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
--
-- The content of this file is subject to the Open CASCADE Technology Public
-- License Version 6.5 (the "License"). You may not use the content of this file
-- except in compliance with the License. Please obtain a copy of the License
-- at http://www.opencascade.org and read it completely before using this file.
--
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
--
-- The Original Code and all software distributed under the License is
-- distributed on an "AS IS" basis, without warranty of any kind, and the
-- Initial Developer hereby disclaims all such warranties, including without
-- limitation, any warranties of merchantability, fitness for a particular
-- purpose or non-infringement. Please see the License for the specific terms
-- and conditions governing the rights and limitations under the License.
class SunRFAlienData from AlienImage inherits AlienImageData from AlienImage
---Version: 0.0
---Level: Public
---Purpose: This class defines a SUN Raster File .rs Alien image.
---Keywords:
---Warning:
---References:
uses
File from OSD,
AsciiString from TCollection,
ColorImage from Image,
PseudoColorImage from Image,
Image from Image,
SUNRFFileHeader from AlienImage,
SUNRFFormat from AlienImage
raises
OutOfRange from Standard,
TypeMismatch from Standard
is
Create returns mutable SunRFAlienData from AlienImage ;
Clear( me : in out mutable ) ;
---Level: Public
---Purpose: Frees memory allocated by SunRFAlienData and
-- reset Object fields.
---C++: alias ~
FreeData( me : in out mutable ) ;
---Level: Public
---Purpose: Frees memory allocated by SunRFAlienData
Read ( me : in out mutable ; afile : in out File from OSD )
returns Boolean from Standard ;
---Level: Public
---Purpose: Read content of a SunRFAlienData object from a file .
-- Returns True if file is a Sun Raster file .
Write( me : in immutable; afile : in out File from OSD )
returns Boolean from Standard ;
---Level: Public
---Purpose: Write content of a SunRFAlienData object to a file .
SetFormat( me : in out mutable ;
aFormat : SUNRFFormat from AlienImage);
---Level: Public
---Purpose: Set SUN Raster File Format for Write method.
Format( me : in immutable )
returns SUNRFFormat from AlienImage ;
---Level: Public
---Purpose: Get SUN Raster File Format .
ToImage( me : in immutable)
returns mutable Image from Image
raises TypeMismatch from Standard ;
---Level: Public
---Purpose : convert a SunRFAlienData object to a Image object.
FromImage( me : in out mutable ; anImage : in Image from Image )
raises TypeMismatch from Standard ;
---Level: Public
---Purpose : convert a Image object to a SunRFAlienData object.
--
-- Private Method
--
ToPseudoColorImage( me : in immutable)
returns PseudoColorImage from Image is private ;
---Level: Internal
---Purpose : convert a AlienImage object to a Image object.
ToColorImage( me : in immutable)
returns ColorImage from Image is private ;
---Level: Internal
---Purpose : convert a AlienImage object to a Image object.
FromPseudoColorImage( me : in out mutable ;
anImage : in PseudoColorImage from Image );
---Level: Internal
---Purpose : convert a Image object to a SunRFAlienData object.
FromColorImage( me : in out mutable ;
anImage : in ColorImage from Image );
---Level: Internal
---Purpose : convert a Image object to a SunRFAlienData object.
ReadPixelRow( me : in out mutable ;
afile : in out File from OSD ;
aAddress : in Address from Standard ;
TheRowSize : in Integer from Standard )
returns Boolean from Standard;
---Level: Internal
---Purpose : Read a Image row from a file and store
-- TheRowSize byte at aAddress
-- returns True if Success.
WritePixelRow( me : in immutable ;
afile : in out File from OSD ;
aAddress : in Address from Standard ;
TheRowSize : in Integer from Standard )
returns Boolean from Standard;
---Level: Internal
---Purpose : Write a Image row to a file from TheRowSize byte at
-- aAddress
-- returns True if Success.
fields
myHeader : SUNRFFileHeader from AlienImage is protected ;
myDataSize : Integer from Standard ;
myData : Address from Standard is protected;
myRedData, myGreenData, myBlueData : Address from Standard is protected;
end ;

View File

@ -1,722 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <Aspect_GenericColorMap.hxx>
#include <Image_PseudoColorImage.hxx>
#include <AlienImage_MemoryOperations.hxx>
#include <AlienImage_SUNRFFormat.hxx>
#include <Image_Convertor.hxx>
#include <AlienImage_SunRFAlienData.ixx>
#include <Aspect_ColorMapEntry.hxx>
#include <Standard_Byte.hxx>
#include <Standard.hxx>
#ifdef TRACE
static int Verbose = 1 ;
#endif
#define RUN_FLAG 0x80
// Each line of the image is rounded out to a multiple of 16 bits
#define ROWBYTES() (((myHeader.ras_width*myHeader.ras_depth + 7 )/8 + 1 ) & ~1 )
AlienImage_SunRFAlienData::AlienImage_SunRFAlienData()
{ Clear() ; }
void AlienImage_SunRFAlienData::SetFormat(
const AlienImage_SUNRFFormat aFormat )
{ switch ( aFormat ) {
case AlienImage_SUNRF_Old :
myHeader.ras_type = RT_OLD ; break ;
case AlienImage_SUNRF_Standard :
myHeader.ras_type = RT_STANDARD ; break ;
case AlienImage_SUNRF_ByteEncoded :
myHeader.ras_type = RT_BYTE_ENCODED ; break ;
case AlienImage_SUNRF_RGB :
myHeader.ras_type = RT_FORMAT_RGB ; break ;
default :
cout << "SunRFAlienData : Unknown or Unsuported Format\n" ;
break ;
}
}
AlienImage_SUNRFFormat AlienImage_SunRFAlienData::Format() const
{ AlienImage_SUNRFFormat ret = AlienImage_SUNRF_Unknown ;
switch ( myHeader.ras_type ) {
case RT_OLD :
ret = AlienImage_SUNRF_Old ; break ;
case RT_STANDARD :
ret = AlienImage_SUNRF_Standard ; break ;
case RT_BYTE_ENCODED :
ret = AlienImage_SUNRF_ByteEncoded ; break ;
case RT_FORMAT_RGB :
ret = AlienImage_SUNRF_RGB ; break ;
}
return ret ;
}
void AlienImage_SunRFAlienData::FreeData()
{
if ( myData && myDataSize ) {
//Free all allocated memory
Standard::Free(myData) ;
myData = NULL ;
myDataSize = 0 ;
}
if ( myRedData && myHeader.ras_maplength ) {
//Free all allocated memory
Standard::Free( myRedData) ;
myRedData = NULL ;
}
if ( myGreenData && myHeader.ras_maplength ) {
//Free all allocated memory
Standard::Free(myGreenData) ;
myRedData = NULL ;
}
if ( myBlueData && myHeader.ras_maplength ) {
//Free all allocated memory
Standard::Free(myBlueData) ;
myRedData = NULL ;
}
}
void AlienImage_SunRFAlienData::Clear()
{ FreeData() ;
myHeader.ras_magic = RAS_MAGIC ;
myHeader.ras_width = 0 ;
myHeader.ras_height = 0 ;
myHeader.ras_length = 0 ;
myHeader.ras_type = RT_STANDARD ;
myHeader.ras_maptype = RMT_NONE ;
myHeader.ras_maplength = 0 ;
}
Standard_Boolean AlienImage_SunRFAlienData::Write( OSD_File& file ) const
{ Standard_Integer size;
AlienImage_SUNRFFileHeader TheHeader = myHeader ;
// Write out TheHeader information
if ( myData && myDataSize &&
myHeader.ras_type == RT_FORMAT_RGB &&
myHeader.ras_depth == 8 ) {
// Convert PseudoColorImage to TrueColor
Handle(Image_Image) aImage = ToImage() ;
if ( aImage->IsKind( STANDARD_TYPE(Image_PseudoColorImage) ) ) {
Image_Convertor Convertor;
Handle(Image_ColorImage) aCImage =
Convertor.Convert(Handle(Image_PseudoColorImage)::DownCast(aImage));
Handle(AlienImage_SunRFAlienData) newThis =
new AlienImage_SunRFAlienData() ;
newThis->FromImage( aCImage ) ;
newThis->SetFormat( AlienImage_SUNRF_RGB ) ;
return newThis->Write( file ) ;
}
}
size = ( Standard_Integer ) sizeof( TheHeader ) ;
const Standard_Address pHeader = ( Standard_Address ) &TheHeader ;
file.Write( pHeader, sizeof( TheHeader ) ) ;
if ( file.Failed() ) {
// ERROR
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ;
}
// write out the color map buffer
if ( TheHeader.ras_maplength ) {
file.Write( myRedData, myHeader.ras_maplength/3 ) ;
file.Write( myGreenData, myHeader.ras_maplength/3 ) ;
file.Write( myBlueData, myHeader.ras_maplength/3 ) ;
if ( file.Failed() ) {
// ERROR
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ;
}
}
Standard_Integer rwbytes ;
rwbytes = ROWBYTES() ;
if ( myData && myDataSize ) {
if ( myHeader.ras_type == RT_OLD ||
myHeader.ras_type == RT_STANDARD ||
myHeader.ras_type == RT_FORMAT_RGB ) {
if ( myHeader.ras_type == RT_FORMAT_RGB ) {
// Swap Sun Default BGR Format to RGB
Standard_Byte *p = ( Standard_Byte * )myData ;
Standard_Byte tmp, *pix ;
Standard_Integer j, i ;
if ( myHeader.ras_depth == 24 || myHeader.ras_depth == 32 ) {
for ( i = 0 ;i < myHeader.ras_height ; i++, p += rwbytes ) {
for ( j = 0, pix=p; j < myHeader.ras_width ; j++,pix+=3) {
if ( myHeader.ras_depth == 32 ) pix++ ;
tmp = *pix ;
*pix = *(pix+2) ;
*(pix+2) = tmp ;
}
}
}
else if ( myHeader.ras_depth == 8 ) {
// ERROR
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ;
}
}
file.Write( myData, myDataSize ) ;
if ( file.Failed() ) {
// ERROR
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ;
}
if ( myHeader.ras_type == RT_FORMAT_RGB &&
( myHeader.ras_depth == 24 || myHeader.ras_depth == 32 ) ) {
// Swap RGB Format to Sun Default
Standard_Byte *p = ( Standard_Byte * )myData ;
Standard_Byte tmp, *pix ;
Standard_Integer j, i ;
for ( i = 0 ;i < myHeader.ras_height ; i++, p += rwbytes ) {
for ( j = 0, pix=p; j < myHeader.ras_width ; j++,pix+=3) {
if ( myHeader.ras_depth == 32 ) pix++ ;
tmp = *pix ;
*pix = *(pix+2) ;
*(pix+2) = tmp ;
}
}
}
}
else if ( myHeader.ras_type == RT_BYTE_ENCODED ) {
Standard_Byte *p = ( Standard_Byte * )myData ;
Standard_Integer i ;
for ( i = 0 ; i < myHeader.ras_height ; i++, p += rwbytes ) {
if ( WritePixelRow( file, ( Standard_Address) p, rwbytes ) ==
Standard_False ) {
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ;
}
}
}
}
return( Standard_True ) ;
}
Standard_Boolean AlienImage_SunRFAlienData::Read( OSD_File& file )
{ Standard_Integer bblcount, size ;
Standard_Address pheader = ( Standard_Address ) &myHeader ;
// Read in myHeader information
file.Read( pheader, sizeof( myHeader ), bblcount ) ;
if ( file.Failed() || ( bblcount != sizeof( myHeader ) ) ) {
// ERROR
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ;
}
// check to see if the dump file is in the proper format */
if (myHeader.ras_magic != RAS_MAGIC) {
// ERROR "XWD file format version mismatch."
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ;
}
#ifdef TRACE
if ( Verbose ) cout << myHeader << endl << flush ;
#endif
// read in the color map buffer
if ( myHeader.ras_maplength ) {
size = myHeader.ras_maplength / 3 ;
myRedData = Standard::Allocate( size ) ;
myGreenData = Standard::Allocate( size ) ;
myBlueData = Standard::Allocate( size ) ;
file.Read( myRedData, size, bblcount ) ;
file.Read( myGreenData, size, bblcount ) ;
file.Read( myBlueData, size, bblcount ) ;
if ( file.Failed() || ( bblcount != size ) ) {
// ERROR
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ;
}
#ifdef TRACE
if ( Verbose ) {
Standard_Byte *r = ( Standard_Byte * )myRedData ;
Standard_Byte *g = ( Standard_Byte * )myGreenData ;
Standard_Byte *b = ( Standard_Byte * )myBlueData ;
for (i = 0 ; i < myHeader.ncolors; i++,p++) {
cout << "(" << r << "," << g << "," << b << ")\n" << flush ;
}
}
#endif
}
if ( myHeader.ras_width && myHeader.ras_height && myHeader.ras_depth ) {
Standard_Integer rwbytes ;
rwbytes = ROWBYTES() ;
myDataSize = rwbytes * myHeader.ras_height ;
myData = Standard::Allocate( myDataSize ) ;
if ( myHeader.ras_type == RT_OLD ||
myHeader.ras_type == RT_STANDARD ||
myHeader.ras_type == RT_FORMAT_RGB ) {
file.Read( myData, myDataSize, bblcount ) ;
if ( file.Failed() || ( bblcount != myDataSize ) ) {
// ERROR
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ;
}
if ( myHeader.ras_type == RT_FORMAT_RGB &&
( myHeader.ras_depth == 24 || myHeader.ras_depth == 32 )) {
// Swap RGB to Sun Default BGR Format
Standard_Byte *p = ( Standard_Byte * )myData ;
Standard_Byte tmp, *pix ;
Standard_Integer i, j ;
for ( i = 0 ; i < myHeader.ras_height ; i++, p += rwbytes ) {
for ( j = 0, pix = p; j < myHeader.ras_width ; j++,pix+=3) {
if ( myHeader.ras_depth == 32 ) pix++ ;
tmp = *pix ;
*pix = *(pix+2) ;
*(pix+2) = tmp ;
}
}
}
}
else if ( myHeader.ras_type == RT_BYTE_ENCODED ) {
Standard_Byte *p = ( Standard_Byte * )myData ;
Standard_Integer i ;
for ( i = 0 ; i < myHeader.ras_height ; i++, p += rwbytes ) {
if ( ReadPixelRow( file, ( Standard_Address) p, rwbytes ) ==
Standard_False ) {
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ;
}
}
}
}
return( Standard_True ) ;
}
Handle_Image_Image AlienImage_SunRFAlienData::ToImage() const
{ if ( myHeader.ras_depth <= 8 &&
myHeader.ras_maplength ) {
return( ToPseudoColorImage() ) ;
}
else if ( myHeader.ras_depth == 24 || myHeader.ras_depth == 32 ) {
return( ToColorImage() ) ;
}
else {
Standard_TypeMismatch_Raise_if( Standard_True,
"Attempt to convert a SunRFAlienData to a unknown Image_Image type");
return( NULL ) ;
}
}
void AlienImage_SunRFAlienData::FromImage( const Handle_Image_Image& anImage )
{ if ( anImage->Type() == Image_TOI_PseudoColorImage ) {
Handle(Image_PseudoColorImage) aPImage =
Handle(Image_PseudoColorImage)::DownCast(anImage) ;
FromPseudoColorImage( aPImage ) ;
}
else if ( anImage->Type() == Image_TOI_ColorImage ) {
Handle(Image_ColorImage) aCImage =
Handle(Image_ColorImage)::DownCast(anImage) ;
FromColorImage( aCImage ) ;
}
else {
Standard_TypeMismatch_Raise_if( Standard_True,
"Attempt to convert a unknown Image_Image type to a SunRFAlienData");
}
}
//------------------------------------------------------------------------------
// Private Method
//------------------------------------------------------------------------------
Standard_Boolean AlienImage_SunRFAlienData::ReadPixelRow(
OSD_File& file,
const Standard_Address pdata,
const Standard_Integer rwbytes)
{ Standard_Byte *p = ( Standard_Byte * )pdata ;
Standard_Byte byte, val ;
Standard_Integer RLEcnt, PixelCount, i, bblcount ;
Standard_Address pb = ( Standard_Address ) &byte ;
PixelCount = 0 ;
while ( PixelCount < myHeader.ras_width ) {
file.Read( pb, 1, bblcount ) ;
if ( file.Failed() || ( bblcount != 1 ) ) {
// ERROR
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ;
}
if ( byte != RUN_FLAG ) {
// Get a single pixel byte
RLEcnt = 1 , val = byte ;
}
else { // RLE Flag
file.Read( pb, 1, bblcount ) ;
if ( file.Failed() || ( bblcount != 1 ) ) {
// ERROR
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ;
}
if ( byte == 0 ) {
RLEcnt = 1 , val = RUN_FLAG ;
}
else {
RLEcnt = byte ;
file.Read( pb, 1, bblcount ) ;
if ( file.Failed() || ( bblcount != 1 ) ) {
// ERROR
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ;
}
val = byte ;
}
for ( i = 0 ; i < RLEcnt ; i++, PixelCount++, p++ ) *p = val ;
}
}
return( Standard_True ) ;
}
Standard_Boolean AlienImage_SunRFAlienData::WritePixelRow(
OSD_File& file,
const Standard_Address pdata,
const Standard_Integer rwbytes ) const
{ Standard_Integer n, n1, n2 = 0;
Standard_Byte *scanln = ( Standard_Byte * ) pdata ;
Standard_Byte b ;
while ( n2 < rwbytes ) {
n1 = n2 ;
n2 = n1 + 1 ;
while( ( n2 < rwbytes ) && ( scanln[n1] == scanln[n2] ) ) n2++ ;
n = n2 - n1 ;
if ( n == 1 ) {
b = scanln[n1]; file.Write( ( Standard_Address ) &b, 1 ) ;
if ( scanln[n1] == RUN_FLAG ) {
b = 0 ; file.Write( ( Standard_Address ) &b, 1 ) ;
}
if ( file.Failed() ) {
// ERROR
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ;
}
}
else {
while ( n > 256 ) {
b = RUN_FLAG ; file.Write( ( Standard_Address ) &b, 1) ;
b = 255 ; file.Write( ( Standard_Address ) &b, 1) ;
b = scanln[n1];file.Write( ( Standard_Address ) &b, 1) ;
n -= 256 ;
if ( file.Failed() ) {
// ERROR
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ;
}
}
b = RUN_FLAG ; file.Write( ( Standard_Address ) &b, 1 ) ;
b = n-1 ; file.Write( ( Standard_Address ) &b, 1 ) ;
b = scanln[n1];file.Write( ( Standard_Address ) &b, 1 ) ;
}
}
return( Standard_True ) ;
}
void AlienImage_SunRFAlienData::FromPseudoColorImage(
const Handle(Image_PseudoColorImage)& TheImage)
{ Standard_Integer rowbytes,i ;
Standard_Integer x, y, pix;
Handle(Image_PseudoColorImage)anImage =
TheImage->Squeeze(Aspect_IndexPixel( 0 )) ;
Handle(Aspect_ColorMap) Cmap = anImage->ColorMap() ;
Aspect_ColorMapEntry aEntry ;
FreeData() ;
myHeader.ras_magic = RAS_MAGIC ;
myHeader.ras_width = anImage->Width() ;
myHeader.ras_height = anImage->Height() ;
myHeader.ras_depth = 8 ;
rowbytes = ROWBYTES() ;
myDataSize = myHeader.ras_height * rowbytes ;
myData = Standard::Allocate( myDataSize ) ;
myHeader.ras_length = myDataSize ;
myHeader.ras_maptype = RMT_EQUAL_RGB ;
myHeader.ras_maplength = Cmap->Size() ;
myRedData = Standard::Allocate( myHeader.ras_maplength ) ;
myGreenData = Standard::Allocate( myHeader.ras_maplength ) ;
myBlueData = Standard::Allocate( myHeader.ras_maplength ) ;
Standard_Byte *pr = ( Standard_Byte * ) myRedData ;
Standard_Byte *pg = ( Standard_Byte * ) myGreenData ;
Standard_Byte *pb = ( Standard_Byte * ) myBlueData ;
for ( i = 0 ; i < myHeader.ras_maplength ; i++, pr++, pg++, pb++ ) {
aEntry = Cmap->FindEntry( i ) ;
*pr = ( Standard_Byte ) ( aEntry.Color().Red() * 255. + 0.5 ) ;
*pg = ( Standard_Byte ) ( aEntry.Color().Green() * 255. + 0.5 ) ;
*pb = ( Standard_Byte ) ( aEntry.Color().Blue() * 255. + 0.5 ) ;
}
myHeader.ras_maplength *= 3 ;
if ( myData != NULL ) {
Standard_Byte *pr = ( Standard_Byte * ) myData ;
Standard_Byte *p ;
for ( y = 0 ; y < myHeader.ras_height ; y++, pr += rowbytes ) {
for ( x = 0, p = pr ; x < myHeader.ras_width ; x++ ) {
pix = anImage->Pixel( anImage->LowerX()+x ,
anImage->LowerY()+y ).Value() ;
*p = ( Standard_Byte ) pix ; p++ ;
}
}
}
}
void AlienImage_SunRFAlienData::FromColorImage(
const Handle_Image_ColorImage& anImage)
{ Standard_Integer rowbytes ;
Standard_Integer x, y;
Quantity_Color col ;
Standard_Real r,g,b ;
FreeData() ;
myHeader.ras_magic = RAS_MAGIC ;
myHeader.ras_width = anImage->Width() ;
myHeader.ras_height = anImage->Height() ;
myHeader.ras_depth = 24 ;
rowbytes = ROWBYTES() ;
myDataSize = myHeader.ras_height * rowbytes ;
myData = Standard::Allocate( myDataSize ) ;
myHeader.ras_length = myDataSize ;
myHeader.ras_maptype = RMT_NONE ;
myHeader.ras_maplength = 0 ;
if ( myData != NULL ) {
Standard_Byte *pr = ( Standard_Byte * ) myData ;
Standard_Byte *p ;
for ( y = 0 ; y < myHeader.ras_height ; y++, pr += rowbytes ) {
for ( x = 0, p = pr ; x < myHeader.ras_width ; x++ ) {
col = anImage->Pixel( anImage->LowerX()+x ,
anImage->LowerY()+y ).Value() ;
r = ( Standard_Integer ) ( col.Red() * 255. + 0.5 );
g = ( Standard_Integer ) ( col.Green() * 255. + 0.5 );
b = ( Standard_Integer ) ( col.Blue() * 255. + 0.5 );
*p = ( Standard_Byte ) b ; p++ ;
*p = ( Standard_Byte ) g ; p++ ;
*p = ( Standard_Byte ) r ; p++ ;
}
}
}
}
Handle_Image_ColorImage AlienImage_SunRFAlienData::ToColorImage() const
{ Aspect_ColorPixel CPixel ;
Quantity_Color acolor ;
Handle(Image_ColorImage) ret_image = NULL ;
Standard_Integer x,y, rowbytes ;
Standard_Real r,g,b ;
Standard_Byte *pr = ( Standard_Byte * ) myData ;
Standard_Byte *p ;
if ( myHeader.ras_depth == 24 || myHeader.ras_depth == 32 ) {
ret_image = new Image_ColorImage( 0,0,
(Standard_Integer)myHeader.ras_width,
(Standard_Integer)myHeader.ras_height ) ;
rowbytes = ROWBYTES() ;
for ( y = 0 ; y < myHeader.ras_height ; y++, pr += rowbytes ) {
for ( x = 0, p = pr ; x < myHeader.ras_width ; x++ ) {
if ( myHeader.ras_depth == 32 ) p++ ; // Skeep Alpha
b = ( Standard_Real ) *p / 255. ; p++ ;
g = ( Standard_Real ) *p / 255. ; p++ ;
r = ( Standard_Real ) *p / 255. ; p++ ;
acolor.SetValues( r,g,b, Quantity_TOC_RGB ) ;
CPixel.SetValue ( acolor ) ;
ret_image->SetPixel( ret_image->LowerX()+x ,
ret_image->LowerY()+y, CPixel ) ;
}
}
}
return( ret_image ) ;
}
Handle_Image_PseudoColorImage AlienImage_SunRFAlienData::ToPseudoColorImage()
const
{ Standard_Real r,g,b ;
Standard_Integer x, y ;
Handle(Image_PseudoColorImage) ret_image = NULL ;
if ( myHeader.ras_depth <= 8 &&
myHeader.ras_maplength ) {
Standard_Integer i,rowbytes ;
Aspect_ColorMapEntry Centry ;
Quantity_Color color ;
Aspect_IndexPixel IPixel ;
Standard_Byte *red = ( Standard_Byte * ) myRedData ;
Standard_Byte *green = ( Standard_Byte * ) myGreenData ;
Standard_Byte *blue = ( Standard_Byte * ) myBlueData ;
Standard_Byte *p ;
Standard_Byte *pr = ( Standard_Byte * ) myData ;
Handle(Aspect_GenericColorMap) colormap =
new Aspect_GenericColorMap();
for ( i = 0 ; i < myHeader.ras_maplength/3 ; i++, red++, green++, blue++ ) {
r = ( Standard_Real ) *red / 255. ;
g = ( Standard_Real ) *green / 255. ;
b = ( Standard_Real ) *blue / 255. ;
color.SetValues( r,g,b, Quantity_TOC_RGB );
Centry.SetValue( i, color ) ;
colormap->AddEntry( Centry ) ;
}
ret_image = new Image_PseudoColorImage( 0,0,
Standard_Integer(myHeader.ras_width),
Standard_Integer(myHeader.ras_height),
colormap ) ;
rowbytes = ROWBYTES() ;
for ( y = 0 ; y < myHeader.ras_height ; y++, pr += rowbytes ) {
for ( x = 0, p = pr ; x < myHeader.ras_width ; x++, p++ ) {
IPixel.SetValue( Standard_Integer( *p ) ) ;
ret_image->SetPixel( ret_image->LowerX()+x ,
ret_image->LowerY()+y, IPixel ) ;
}
}
}
return ret_image ;
}

View File

@ -1,77 +0,0 @@
-- Created on: 1993-03-23
-- Created by: BBL
-- Copyright (c) 1993-1999 Matra Datavision
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
--
-- The content of this file is subject to the Open CASCADE Technology Public
-- License Version 6.5 (the "License"). You may not use the content of this file
-- except in compliance with the License. Please obtain a copy of the License
-- at http://www.opencascade.org and read it completely before using this file.
--
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
--
-- The Original Code and all software distributed under the License is
-- distributed on an "AS IS" basis, without warranty of any kind, and the
-- Initial Developer hereby disclaims all such warranties, including without
-- limitation, any warranties of merchantability, fitness for a particular
-- purpose or non-infringement. Please see the License for the specific terms
-- and conditions governing the rights and limitations under the License.
-- Modified: 02-06-98 : FMN ; Suppression appel Clear (deja fait dans ALienData)
class SunRFAlienImage from AlienImage inherits AlienUserImage from AlienImage
---Purpose: Defines a SunRF Alien image, i.e. an image using the
-- image format for SUN workstations.
uses
File from OSD,
AsciiString from TCollection,
ColorImage from Image,
PseudoColorImage from Image,
Image from Image,
SunRFAlienData from AlienImage,
SUNRFFormat from AlienImage
is
Create returns mutable SunRFAlienImage from AlienImage;
---Purpose: Constructs an empty SunRF alien image.
Clear( me : in out mutable) ;
---Level: Public
---Purpose: Frees memory allocated by SunRFAlienImage
ToImage( me : in immutable )
returns mutable Image from Image ;
---Level: Public
---Purpose : Converts a SunRFAlienImage object to a Image object.
FromImage( me : in out mutable ; anImage : in Image from Image ) ;
---Level: Public
---Purpose : Converts an Image object to a SunRFAlienImage object.
Read ( me : in out mutable; afile : in out File from OSD )
returns Boolean from Standard ;
---Level: Public
---Purpose: Reads the content of a SunRFAlienImage object from a file
-- Returns True if file is a XWD file .
Write( me : in immutable; afile : in out File from OSD )
returns Boolean from Standard ;
---Purpose: Writes content of a SunRFAlienImage object to a file
SetFormat( me : in out mutable ;
aFormat : SUNRFFormat from AlienImage);
---Purpose: Sets the SUN Raster File Format for Write method.
Format( me : in immutable )
returns SUNRFFormat from AlienImage ;
---Purpose: Returns the SUN Raster File Format .
fields
myData : SunRFAlienData from AlienImage ;
end ;

View File

@ -1,55 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <AlienImage_SunRFAlienImage.ixx>
AlienImage_SunRFAlienImage::AlienImage_SunRFAlienImage()
{ // il faut faire un new si mydata est du type HANDLE
myData = new AlienImage_SunRFAlienData() ;
}
void AlienImage_SunRFAlienImage::Clear()
{ myData->Clear() ; }
Standard_Boolean AlienImage_SunRFAlienImage::Write( OSD_File& file ) const
{ return( myData->Write( file ) ) ; }
Standard_Boolean AlienImage_SunRFAlienImage::Read( OSD_File& file )
{ return( myData->Read( file ) ) ; }
Handle_Image_Image AlienImage_SunRFAlienImage::ToImage() const
{ return( myData->ToImage() ) ; }
void AlienImage_SunRFAlienImage::FromImage( const Handle_Image_Image& anImage )
{ myData->FromImage( anImage ) ; }
void AlienImage_SunRFAlienImage::SetFormat(
const AlienImage_SUNRFFormat aFormat )
{ myData->SetFormat( aFormat ) ; }
AlienImage_SUNRFFormat AlienImage_SunRFAlienImage::Format() const
{ return myData->Format( ) ; }

View File

@ -1,66 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <AlienImage_X11XColor.hxx>
const Handle(Standard_Type)& STANDARD_TYPE(AlienImage_X11XColor)
{
static Handle(Standard_Type) _atype = new Standard_Type ("AlienImage_X11XColor", sizeof (AlienImage_X11XColor));
return _atype;
}
Standard_Boolean operator == ( const AlienImage_X11XColor& AnObject,
const AlienImage_X11XColor& AnotherObject )
{ Standard_Boolean _result = Standard_True;
_result = _result && (AnObject.pixel==AnotherObject.pixel) ;
_result = _result && (AnObject.red ==AnotherObject.red) ;
_result = _result && (AnObject.green==AnotherObject.green) ;
_result = _result && (AnObject.blue ==AnotherObject.blue) ;
_result = _result && (AnObject.flags==AnotherObject.flags) ;
return _result;
}
//============================================================================
//==== ShallowDump : Writes a CString value.
//============================================================================
void ShallowDump (const AlienImage_X11XColor& AnObject, Standard_OStream& s)
{
s << "AlienImage_X11XColor\n" ;
s << "\tpixel :" << AnObject.pixel << "\n";
s << "\tred/green/blue :" << AnObject.red << "/"
<< AnObject.green << "/"
<< AnObject.blue<< "\n";
s << "\tflags :" << AnObject.flags << "\n" << flush ;
}
ostream& operator << ( ostream& s, const AlienImage_X11XColor& c )
{
return( s << "(" << c.pixel
<< ",(" << c.red << ","
<< c.green <<","
<< c.blue
<< "),"
<< hex << c.flags
<< ")" ) ;
}

View File

@ -1,63 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
//============================================================================
//==== Titre: AlienImage_X11XColor.hxx
//==== Role : The header file of primitve type "X11XColor" from package
//==== "AlienImage"
//====
//==== Implementation: This is a primitive type implemented with typedef
//==== typedef XColor AlienImage_X11XColor;
//============================================================================
#ifndef AlienImage_X11XColor_HeaderFile
#define AlienImage_X11XColor_HeaderFile
/*
* Data structure used by color operations from <X11/Xlib.h>
*/
//==== Definition de Type ====================================================
#include <Standard_Type.hxx>
extern const Handle_Standard_Type AlienImage_X11XColorType;
inline Handle(Standard_Type) AlienImage_X11XColorType_Type_() {return 0;}
//============================================================================
/*
invalide car unsigned long = 32 ou 64 !
#include <X11/Xlib.h>
typedef XColor AlienImage_X11XColor ;
*/
/*
* Data structure used by color operations
*/
typedef struct {
unsigned int pixel;
unsigned short red, green, blue;
char flags; /* do_red, do_green, do_blue */
char pad;
} AlienImage_X11XColor;
ostream& operator << ( ostream& s, const AlienImage_X11XColor& color );
Standard_Boolean operator == (const AlienImage_X11XColor& AnObject,
const AlienImage_X11XColor& AnotherObject);
void ShallowDump (const AlienImage_X11XColor& AnObject, Standard_OStream& S);
#endif

View File

@ -1,154 +0,0 @@
-- Created on: 1993-03-23
-- Created by: BBL
-- Copyright (c) 1993-1999 Matra Datavision
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
--
-- The content of this file is subject to the Open CASCADE Technology Public
-- License Version 6.5 (the "License"). You may not use the content of this file
-- except in compliance with the License. Please obtain a copy of the License
-- at http://www.opencascade.org and read it completely before using this file.
--
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
--
-- The Original Code and all software distributed under the License is
-- distributed on an "AS IS" basis, without warranty of any kind, and the
-- Initial Developer hereby disclaims all such warranties, including without
-- limitation, any warranties of merchantability, fitness for a particular
-- purpose or non-infringement. Please see the License for the specific terms
-- and conditions governing the rights and limitations under the License.
class X11XWDAlienData from AlienImage inherits AlienImageData from AlienImage
---Version: 0.0
---Purpose: This class defines a X11 Alien image.
---Keywords:
---Warning:
---References:
uses
File from OSD,
AsciiString from TCollection,
ColorImage from Image,
PseudoColorImage from Image,
Image from Image,
X11XColor from AlienImage,
X11XWDFileHeader from AlienImage
raises
OutOfRange from Standard,
TypeMismatch from Standard
is
Create returns mutable X11XWDAlienData from AlienImage ;
Clear( me : in out mutable ) ;
---Level: Public
---Purpose: Frees memory allocated by X11XWDAlienData
---C++: alias ~
Read ( me : in out mutable ; afile : in out File from OSD )
returns Boolean from Standard ;
---Level: Public
---Purpose: Read content of a X11XWDAlienData object from a file
-- Returns True if file is a XWD file .
Write( me : in immutable; afile : in out File from OSD )
returns Boolean from Standard ;
---Level: Public
---Purpose: Write content of a X11XWDAlienData object to a file
SetName( me : in out mutable ;
aName : in AsciiString from TCollection)
is redefined;
---Level: Public
---Purpose: Set Image name .
Name( me : in immutable ) returns AsciiString from TCollection
is redefined;
---C++: return const &
---Level: Public
---Purpose: Get Image name .
ToImage( me : in immutable)
returns mutable Image from Image
raises TypeMismatch from Standard ;
---Level: Public
---Purpose : convert a X11XWDAlienData object to a Image object.
FromImage( me : in out mutable ; anImage : in Image from Image )
raises TypeMismatch from Standard ;
---Level: Public
---Purpose : convert a Image object to a X11XWDAlienData object.
--
-- Private Method
--
Pixel ( me : in immutable ; X,Y : in Integer from Standard )
returns Integer from Standard
raises OutOfRange from Standard is private ;
---Level: Internal
SetPixel( me : in out mutable; X,Y : in Integer from Standard ;
Value : in Integer from Standard )
raises OutOfRange from Standard is private ;
---Level: Internal
DataSize( me : in immutable)
returns Integer from Standard is private ;
---Level: Internal
---Purpose: Compute the imaga data size in byte
-- from header information
RedShift( me : in immutable) returns Integer from Standard
raises TypeMismatch from Standard is private ;
---Purpose: Compute the red shift for TrueColor X11XWDImage
GreenShift( me : in immutable) returns Integer from Standard
raises TypeMismatch from Standard is private ;
---Level: Internal
---Purpose: Compute the red shift for TrueColor X11XWDImage
BlueShift( me : in immutable) returns Integer from Standard
raises TypeMismatch from Standard is private ;
---Level: Internal
---Purpose: Compute the red shift for TrueColor X11XWDImage
ToPseudoColorImage( me : in immutable)
returns PseudoColorImage from Image is private ;
---Level: Internal
---Purpose : convert a Image object to a AlienImage object.
ToColorImage( me : in immutable)
returns ColorImage from Image is private ;
---Level: Internal
---Purpose : convert a Image object to a AlienImage object.
FromPseudoColorImage( me : in out mutable;
anImage : in PseudoColorImage from Image )
is private ;
---Level: Internal
---Purpose : convert a Image object to a X11XWDAlienData object.
FromColorImage( me : in out mutable;
anImage : in ColorImage from Image)
is private ;
---Level: Internal
---Purpose : convert a Image object to a X11XWDAlienData object.
fields
myHeader : X11XWDFileHeader from AlienImage is protected ;
myColors : Address from Standard is protected ;
-- XColors definition
myData : Address from Standard is protected ;
-- my is a ( unsigned char * ) for 8 bit image ,
-- ( unsigned int * ) for 24 bit image .
end ;

View File

@ -1,841 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#define PRO9517 //GG_010997
// 1) Le swap ne fonctionne pas correctement sur DEC
// car X11XColor.pixel est int et non long (::Read(),::Write()).
// 2) Initialiser la table des couleurs avant d'ecrire
// le fichier temporaire (::Write())
#define K4 //GG_110398
// Ne pas initialiser una AsciiString avec '\0' dans le
// constructeur de AlienImage_X11XWDAlienData sinon RAISE !
#define TEST //GG_140699
// Check file extension, must be ".xwd".
#if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
# include <X11/Xlib.h>
#endif // WNT
#include <Aspect_GenericColorMap.hxx>
#include <Image_PseudoColorImage.hxx>
#include <AlienImage_MemoryOperations.hxx>
#include <AlienImage_X11XColor.hxx>
#include <AlienImage_X11XWDAlienData.ixx>
#include <Aspect_ColorMapEntry.hxx>
#include <Standard.hxx>
#ifdef TRACE
static int Verbose = 0 ;
#endif
AlienImage_X11XWDAlienData::AlienImage_X11XWDAlienData()
{ myData = NULL ;
myColors = NULL ;
}
void AlienImage_X11XWDAlienData::SetName( const TCollection_AsciiString& aName)
{ myName = aName + TCollection_AsciiString( "\0" ) ;
myHeader.header_size = sizeof( myHeader ) + myName.Length() ;
}
const TCollection_AsciiString& AlienImage_X11XWDAlienData::Name() const
{ return ( myName ) ; }
void AlienImage_X11XWDAlienData::Clear()
{ Standard_Integer size ;
myHeader.header_size = sizeof( myHeader ) ;
/* Size of the entire file header (bytes).*/
myHeader.file_version = 0 ; /* XWD_FILE_VERSION */
myHeader.pixmap_format= 0; /* Pixmap format */
myHeader.pixmap_depth = 0 ; /* Pixmap depth */
myHeader.pixmap_width = 0 ; /* Pixmap width */
myHeader.pixmap_height= 0 ; /* Pixmap height */
myHeader.xoffset = 0 ; /* Bitmap x offset */
myHeader.byte_order = 0; /* MSBFirst, LSBFirst */
myHeader.bitmap_unit = 0 ; /* Bitmap unit */
myHeader.bitmap_bit_order = 0; /* MSBFirst, LSBFirst */
myHeader.bitmap_pad = 0 ; /* Bitmap scanline pad */
myHeader.bits_per_pixel = 0 ; /* Bits per pixel */
myHeader.bytes_per_line =0 ; /* Bytes per scanline */
myHeader.visual_class = 0 ; /* Class of colormap */
myHeader.red_mask = 0 ; /* Z red mask */
myHeader.green_mask = 0 ; /* Z green mask */
myHeader.blue_mask = 0 ; /* Z blue mask */
myHeader.bits_per_rgb = 0 ; /* Log2 of distinct color values */
myHeader.colormap_entries = 0 ; /* Number of entries in colormap */
myHeader.ncolors = 0 ; /* Number of Color structures */
myHeader.window_width = 0 ; /* Window width */
myHeader.window_height= 0 ; /* Window height */
myHeader.window_x = 0 ; /* Window upper left X coordinate */
myHeader.window_y = 0 ; /* Window upper left Y coordinate */
myHeader.window_bdrwidth =0 ; /* Window border width */
myName.Clear() ;
if ( myData ) {
//Free all allocated memory
Standard::Free(myData) ;
myData = NULL ;
}
if ( myColors ) {
size = ( Standard_Integer )
myHeader.ncolors * sizeof( AlienImage_X11XColor ) ;
//Free all allocated memory
Standard::Free(myColors);
myColors = NULL ;
}
}
Standard_Boolean AlienImage_X11XWDAlienData::Write( OSD_File& file ) const
{ Standard_Integer size, i ;
unsigned long swaptest = 1;
AlienImage_X11XWDFileHeader TheHeader = myHeader ;
if ( myData == NULL ) return( Standard_False ) ;
if ( TheHeader.ncolors &&
myColors == NULL ) return( Standard_False ) ;
// Write out TheHeader information
size = ( Standard_Integer ) TheHeader.header_size - sizeof( TheHeader ) ;
if ( size ) {
// Add '\0' at the end of name
TheHeader.header_size++ ;
}
if (*(char *) &swaptest) {
AlienImage_X11XWDFileHeader SwapHeader = TheHeader ;
AlienImage_MemoryOperations::SwapLong( ( Standard_Address ) &SwapHeader,
sizeof(SwapHeader));
file.Write( &SwapHeader , sizeof( SwapHeader ) ) ;
}
else {
const Standard_Address pHeader = ( Standard_Address ) &TheHeader ;
file.Write( pHeader, sizeof( TheHeader ) ) ;
}
if ( file.Failed() ) {
// ERROR
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ;
}
size = ( Standard_Integer ) TheHeader.header_size - sizeof( TheHeader ) ;
if ( size ) {
char end = '\0' ;
Standard_Address pend = Standard_Address( &end ) ;
file.Write( myName, myName.Length() ) ;
file.Write( pend, 1 ) ;
}
if ( file.Failed() ) {
// ERROR
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ;
}
// write out the color map buffer
if ( TheHeader.ncolors ) {
size = ( Standard_Integer ) TheHeader.ncolors
* sizeof( AlienImage_X11XColor ) ;
if (*(char *) &swaptest) {
Standard_Address palloc =
Standard::Allocate( size ) ;
#ifdef PRO9517
const AlienImage_X11XColor *p = ( AlienImage_X11XColor * ) myColors ;
AlienImage_X11XColor *pp = ( AlienImage_X11XColor * ) palloc ;
for (i = 0 ; (unsigned int ) i < TheHeader.ncolors; i++,p++,pp++) {
pp->pixel = p->pixel;
pp->red = p->red;
pp->green = p->green;
pp->blue = p->blue;
pp->flags = p->flags;
AlienImage_MemoryOperations::SwapLong (
(Standard_Address) &(pp->pixel), sizeof(int));
AlienImage_MemoryOperations::SwapShort(
(Standard_Address) &(pp->red) , 3 * sizeof(short));
}
#else
const AlienImage_X11XColor *p = ( AlienImage_X11XColor * ) palloc ;
for (i = 0 ; i < TheHeader.ncolors; i++,p++) {
AlienImage_MemoryOperations::SwapLong (
(Standard_Address) &(p->pixel), sizeof(long));
AlienImage_MemoryOperations::SwapShort(
(Standard_Address) &(p->red) , 3 * sizeof(short));
}
#endif
file.Write( palloc, size ) ;
//Free all allocated memory
Standard::Free(palloc) ;
}
else {
file.Write( myColors, size ) ;
}
if ( file.Failed() ) {
// ERROR
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ;
}
}
if ( DataSize() ) {
file.Write( myData, DataSize() ) ;
if ( file.Failed() ) {
// ERROR
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ;
}
}
return( Standard_True ) ;
}
Standard_Boolean AlienImage_X11XWDAlienData::Read( OSD_File& file )
{ Standard_Integer bblcount, i, size ;
unsigned long swaptest = 1;
Standard_Address pheader = ( Standard_Address ) &myHeader ;
#ifdef TEST
OSD_Path path; file.Path(path);
TCollection_AsciiString ext = path.Extension(); ext.LowerCase();
if( ext != ".xwd" ) {
TCollection_AsciiString sysname; path.SystemName(sysname);
#ifdef TRACE
cout << " *** AlienImage_X11XWDAlienData::Read('" << sysname << "'). must have an '.xwd' extension" << endl;
#endif
return Standard_False;
}
#endif
// Read in myHeader information
file.Read( pheader, sizeof( myHeader ), bblcount ) ;
if ( file.Failed() || ( bblcount != sizeof( myHeader ) ) ) {
// ERROR
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ;
}
if (*(char *) &swaptest)
AlienImage_MemoryOperations::SwapLong( ( Standard_Address ) &myHeader,
sizeof(myHeader));
// check to see if the dump file is in the proper format */
if (myHeader.file_version != XWD_FILE_VERSION) {
// ERROR "XWD file format version mismatch."
if (*(char *) &swaptest)
AlienImage_MemoryOperations::SwapLong( ( Standard_Address ) &myHeader,
sizeof(myHeader));
if (myHeader.file_version != XWD_FILE_VERSION) {
// ERROR "XWD file format version mismatch."
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ;
}
else {
// Data come from a swaped computer ??
swaptest = 0 ;
}
}
if (myHeader.header_size < sizeof(myHeader)) {
// ERROR "XWD header size is too small."
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ;
}
#ifdef TRACE
if ( Verbose ) cout << myHeader << endl << flush ;
#endif
// read in window name
size = ( Standard_Integer ) myHeader.header_size - sizeof( myHeader ) ;
if ( size > 0 ) {
#ifdef K4
TCollection_AsciiString name( bblcount ) ;
#else
TCollection_AsciiString name( bblcount , '\0') ;
#endif
file.Read( name, size ) ; bblcount = name.Length() ;
#ifdef WNT
--size;
#endif // WNT
if ( file.Failed() || ( bblcount != size ) ) {
// ERROR
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ;
}
myName = name ;
#ifdef TRACE
if ( Verbose ) cout << myName << endl << flush ;
#endif
}
// read in the color map buffer
if ( myHeader.ncolors ) {
size = ( Standard_Integer ) myHeader.ncolors
* sizeof( AlienImage_X11XColor ) ;
myColors = Standard::Allocate( size ) ;
file.Read( myColors, size, bblcount ) ;
if ( file.Failed() || ( bblcount != size ) ) {
// ERROR
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ;
}
if ( *(char *) &swaptest ) {
AlienImage_X11XColor *p
= ( AlienImage_X11XColor * )myColors ;
for (i = 0 ; (unsigned int ) i < myHeader.ncolors; i++,p++) {
#ifdef PRO9517
AlienImage_MemoryOperations::SwapLong (
(Standard_Address) &(p->pixel), sizeof(int));
#else
AlienImage_MemoryOperations::SwapLong (
(Standard_Address) &(p->pixel), sizeof(long));
#endif
AlienImage_MemoryOperations::SwapShort(
(Standard_Address) &(p->red) , 3 * sizeof(short));
}
}
#ifdef TRACE
if ( Verbose ) {
AlienImage_X11XColor *p = ( AlienImage_X11XColor * )myColors;
for (i = 0 ; i < myHeader.ncolors; i++,p++) {
cout << *p << endl << flush ;
}
}
#endif
}
if ( DataSize() ) {
myData = Standard::Allocate( DataSize() ) ;
file.Read( myData, DataSize(), bblcount ) ;
if ( file.Failed() || ( bblcount != DataSize() ) ) {
// ERROR
file.Seek( 0, OSD_FromBeginning ) ;
return( Standard_False ) ;
}
}
return( Standard_True ) ;
}
Handle_Image_Image AlienImage_X11XWDAlienData::ToImage() const
{ if ( myHeader.pixmap_depth <= 8 &&
myHeader.ncolors &&
myHeader.pixmap_format == ZPixmap) {
return( ToPseudoColorImage() ) ;
}
else if ( myHeader.visual_class == TrueColor &&
myHeader.pixmap_format == ZPixmap) {
return( ToColorImage() ) ;
}
else {
Standard_TypeMismatch_Raise_if( Standard_True,
"Attempt to convert a X11XWDAlienData to a unknown Image_Image type");
return( NULL ) ;
}
}
void AlienImage_X11XWDAlienData::FromImage( const Handle_Image_Image& anImage )
{ if ( anImage->Type() == Image_TOI_PseudoColorImage ) {
Handle(Image_PseudoColorImage) aPImage =
Handle(Image_PseudoColorImage)::DownCast(anImage) ;
FromPseudoColorImage( aPImage ) ;
}
else if ( anImage->Type() == Image_TOI_ColorImage ) {
Handle(Image_ColorImage) aCImage =
Handle(Image_ColorImage)::DownCast(anImage) ;
FromColorImage( aCImage ) ;
}
else {
Standard_TypeMismatch_Raise_if( Standard_True,
"Attempt to convert a unknown Image_Image type to a X11XWDAlienData");
}
}
//------------------------------------------------------------------------------
// Private Method
//------------------------------------------------------------------------------
void AlienImage_X11XWDAlienData::FromPseudoColorImage(
const Handle_Image_PseudoColorImage& anImage)
{ Standard_Integer size, i ;
/* Size of the entire file header (bytes).*/
myHeader.header_size = sizeof(myHeader) + myName.Length() ;
myHeader.file_version = XWD_FILE_VERSION ; /* XWD_FILE_VERSION */
myHeader.pixmap_format = ZPixmap ; /* Pixmap format */
myHeader.pixmap_depth = 8 ; /* Pixmap depth */
myHeader.pixmap_width = anImage->Width() ;/* Pixmap width */
myHeader.pixmap_height = anImage->Height() ;/* Pixmap height */
myHeader.xoffset = 0 ; /* Bitmap x offset */
myHeader.byte_order = MSBFirst; /* MSBFirst, LSBFirst */
myHeader.bitmap_unit = 32 ; /* Bitmap unit */
myHeader.bitmap_bit_order = MSBFirst; /* MSBFirst, LSBFirst */
myHeader.bitmap_pad = 32 ; /* Bitmap scanline pad */
myHeader.bits_per_pixel = 8 ; /* Bits per pixel */
/* Bytes per scanline */
size = ( Standard_Integer ) ( anImage->Width() * myHeader.bits_per_pixel );
myHeader.bytes_per_line = size / myHeader.bitmap_unit ;
if ( size % myHeader.bitmap_pad ) myHeader.bytes_per_line += 1 ;
myHeader.bytes_per_line *= ( myHeader.bitmap_unit / 8 ) ;
myHeader.visual_class = PseudoColor ; /* Class of colormap */
myHeader.red_mask = 0 ; /* Z red mask */
myHeader.green_mask = 0 ; /* Z green mask */
myHeader.blue_mask = 0 ; /* Z blue mask */
myHeader.bits_per_rgb = 8 ; /* Log2 of distinct color values */
myHeader.colormap_entries = 256 ; /* Number of entries in colormap */
myHeader.ncolors = (anImage->ColorMap())->Size() ;
/* Number of Color structures */
myHeader.window_width = anImage->Width() ; /* Window width */
myHeader.window_height = anImage->Height() ; /* Window height */
myHeader.window_x = 0 ; /* Window upper left X coordinate */
myHeader.window_y = 0 ; /* Window upper left Y coordinate */
myHeader.window_bdrwidth = 0 ; /* Window border width */
size = ( Standard_Integer ) myHeader.ncolors
* sizeof( AlienImage_X11XColor ) ;
myColors = Standard::Allocate( size ) ;
AlienImage_X11XColor *p = ( AlienImage_X11XColor * )myColors ;
Aspect_ColorMapEntry aCentry ;
for ( i = 1 ; (unsigned int ) i <= myHeader.ncolors ; i++, p++ ) {
p->pixel = 0 ;
p->red = p->green = p->blue = 0 ;
p->flags = 0 ;
aCentry = (anImage->ColorMap())->Entry( i ) ;
if ( aCentry.IsAllocated() == Standard_True ) {
p->flags = DoRed | DoGreen | DoBlue ;
p->pixel = aCentry.Index() ;
p->red = ( unsigned short )
( (aCentry.Color()).Red() * 0xffff + 0.5 ) ;
p->green = ( unsigned short )
( (aCentry.Color()).Green() * 0xffff + 0.5 ) ;
p->blue = ( unsigned short )
( (aCentry.Color()).Blue() * 0xffff + 0.5 ) ;
}
}
if ( anImage->Size() ) {
Standard_Integer x, y ;
myData = Standard::Allocate( DataSize() ) ;
for ( y = 0 ; (unsigned int ) y < myHeader.pixmap_height ; y++ ) {
for ( x = 0 ; (unsigned int ) x < myHeader.pixmap_width ; x++ ) {
SetPixel( x, y,
( anImage->Pixel( anImage->LowerX()+x ,
anImage->LowerY()+y )).Value() ) ;
}
}
}
}
void AlienImage_X11XWDAlienData::FromColorImage(
const Handle_Image_ColorImage& anImage)
{ long int size ;;
/* Size of the entire file header (bytes).*/
myHeader.header_size = sizeof(myHeader) + myName.Length() ;
myHeader.file_version = XWD_FILE_VERSION ; /* XWD_FILE_VERSION */
myHeader.pixmap_format = ZPixmap ; /* Pixmap format */
myHeader.pixmap_depth = 24 ; /* Pixmap depth */
myHeader.pixmap_width = anImage->Width() ;/* Pixmap width */
myHeader.pixmap_height = anImage->Height() ;/* Pixmap height */
myHeader.xoffset = 0 ; /* Bitmap x offset */
myHeader.byte_order = MSBFirst; /* MSBFirst, LSBFirst */
myHeader.bitmap_unit = 32 ; /* Bitmap unit */
myHeader.bitmap_bit_order = MSBFirst; /* MSBFirst, LSBFirst */
myHeader.bitmap_pad = 32 ; /* Bitmap scanline pad */
myHeader.bits_per_pixel = 32 ; /* Bits per pixel */
/* Bytes per scanline */
size = anImage->Width() * myHeader.bits_per_pixel ;
myHeader.bytes_per_line = size / myHeader.bitmap_unit ;
if ( size % myHeader.bitmap_pad ) myHeader.bytes_per_line += 1 ;
myHeader.bytes_per_line *= ( myHeader.bitmap_unit / 8 ) ;
myHeader.visual_class = TrueColor ; /* Class of colormap */
myHeader.red_mask = 0xff ; /* Z red mask */
myHeader.green_mask = 0xff00 ; /* Z green mask */
myHeader.blue_mask = 0xff0000 ; /* Z blue mask */
myHeader.bits_per_rgb = 8 ; /* Log2 of distinct color values */
myHeader.colormap_entries = 256 ; /* Number of entries in colormap */
myHeader.ncolors = 0 ; /* Number of Color structures */
myHeader.window_width = anImage->Width() ; /* Window width */
myHeader.window_height = anImage->Height() ; /* Window height */
myHeader.window_x = 0 ; /* Window upper left X coordinate */
myHeader.window_y = 0 ; /* Window upper left Y coordinate */
myHeader.window_bdrwidth = 0 ; /* Window border width */
myColors = NULL ;
if ( anImage->Size() ) {
Standard_Integer x, y, pix, c ;
const Standard_Integer rs = RedShift() ;
const Standard_Integer gs = GreenShift() ;
const Standard_Integer bs = BlueShift() ;
const Standard_Integer ColorRange =
Standard_Integer( ( 1 << myHeader.bits_per_rgb ) - 1 );
Quantity_Color col ;
myData = Standard::Allocate( DataSize() ) ;
for ( y = 0 ; (unsigned int ) y < myHeader.pixmap_height ; y++ ) {
for ( x = 0 ; (unsigned int ) x < myHeader.pixmap_width ; x++ ) {
col = anImage->Pixel( anImage->LowerX()+x ,
anImage->LowerY()+y ).Value() ;
pix = 0 ;
c = ( Standard_Integer ) ( col.Red() * ColorRange + 0.5 );
c = ( Standard_Integer ) (( c << rs ) & myHeader.red_mask) ;
pix |= c ;
c = ( Standard_Integer ) ( col.Green() * ColorRange + 0.5 );
c = ( Standard_Integer ) (( c << gs ) & myHeader.green_mask) ;
pix |= c ;
c = ( Standard_Integer ) ( col.Blue() * ColorRange + 0.5 );
c = ( Standard_Integer ) (( c << bs ) & myHeader.blue_mask) ;
pix |= c ;
SetPixel( x, y, pix ) ;
}
}
}
}
Handle_Image_ColorImage AlienImage_X11XWDAlienData::ToColorImage() const
{ Aspect_ColorPixel CPixel ;
Quantity_Color acolor ;
Handle(Image_ColorImage) ret_image = NULL ;
Standard_Integer pix,x,y ;
Standard_Real r,g,b, maxcol ;
if ( myHeader.visual_class == TrueColor &&
myHeader.pixmap_format == ZPixmap) {
ret_image = new Image_ColorImage( 0,0,
(Standard_Integer)myHeader.pixmap_width,
(Standard_Integer)myHeader.pixmap_height ) ;
maxcol = ( 1 << myHeader.bits_per_rgb ) - 1 ;
for ( y = 0 ; (unsigned int ) y < myHeader.pixmap_height ; y++ ) {
for ( x = 0 ; (unsigned int ) x < myHeader.pixmap_width ; x++ ) {
pix = Pixel( x, y ) ;
r = ( ( pix & myHeader.red_mask ) >> RedShift() ) / maxcol ;
g = ( ( pix & myHeader.green_mask ) >> GreenShift() ) / maxcol ;
b = ( ( pix & myHeader.blue_mask ) >> BlueShift() ) / maxcol ;
acolor.SetValues( r,g,b, Quantity_TOC_RGB ) ;
CPixel.SetValue ( acolor ) ;
ret_image->SetPixel( ret_image->LowerX()+x ,
ret_image->LowerY()+y, CPixel ) ;
}
}
}
return( ret_image ) ;
}
Handle_Image_PseudoColorImage AlienImage_X11XWDAlienData::ToPseudoColorImage()
const
{ Standard_Real r,g,b ;
Standard_Integer x, y ;
const Standard_Real XRange = Standard_Real( Standard_Integer(0xffff) );
const Standard_Integer newColorSize =
Standard_Integer(myHeader.colormap_entries*sizeof(AlienImage_X11XColor));
Handle(Image_PseudoColorImage) ret_image = NULL ;
if ( myHeader.pixmap_depth <= 8 &&
myHeader.ncolors &&
myHeader.pixmap_format == ZPixmap) {
// unsigned long int i, j, ncol ;
unsigned long int i, ncol ;
Aspect_ColorMapEntry Centry ;
Quantity_Color color ;
AlienImage_X11XColor *p ;
AlienImage_X11XColor *newColor ;
Standard_Address palloc ;
Aspect_IndexPixel IPixel ;
palloc = Standard::Allocate( newColorSize ) ;
newColor = ( AlienImage_X11XColor * ) palloc ;
p = ( AlienImage_X11XColor * )myColors;
for ( i = 0 ; i < myHeader.ncolors ; i++, p++ ) newColor[p->pixel] = *p;
for ( i = 0 ; i < myHeader.colormap_entries ; i++ ) newColor[i].flags = 0 ;
for ( y = 0 ; (unsigned int ) y < myHeader.pixmap_height ; y++ ) {
for ( x = 0 ; (unsigned int ) x < myHeader.pixmap_width ; x++ ) {
newColor[ Pixel( x, y ) ].flags = DoRed | DoGreen | DoBlue ;
}
}
for ( i = ncol = 0 ; i < myHeader.colormap_entries ; i++ ) {
if ( newColor[i].flags ) ncol++ ;
}
Handle(Aspect_GenericColorMap) colormap =
new Aspect_GenericColorMap();
for ( i = 0 ; i < myHeader.colormap_entries ; i++ ) {
if ( newColor[i].flags ) {
r = ( Standard_Real ) newColor[i].red / XRange ;
g = ( Standard_Real ) newColor[i].green / XRange ;
b = ( Standard_Real ) newColor[i].blue / XRange ;
color.SetValues( r,g,b, Quantity_TOC_RGB );
Centry.SetValue( Standard_Integer(newColor[i].pixel), color ) ;
colormap->AddEntry( Centry ) ;
}
}
ret_image = new Image_PseudoColorImage( 0,0,
Standard_Integer(myHeader.pixmap_width),
Standard_Integer(myHeader.pixmap_height),
colormap ) ;
for ( y = 0 ; (unsigned int ) y < myHeader.pixmap_height ; y++ ) {
for ( x = 0 ; (unsigned int ) x < myHeader.pixmap_width ; x++ ) {
IPixel.SetValue( Pixel( x, y ) ) ;
ret_image->SetPixel( ret_image->LowerX()+x ,
ret_image->LowerY()+y, IPixel ) ;
}
}
//Free all allocated memory
Standard::Free(palloc);
}
return ret_image ;
}
Standard_Integer AlienImage_X11XWDAlienData::DataSize() const
{
if ( myHeader.pixmap_format != ZPixmap)
return( myHeader.bytes_per_line * myHeader.pixmap_height
* myHeader.pixmap_depth );
return( myHeader.bytes_per_line * myHeader.pixmap_height);
}
void AlienImage_X11XWDAlienData::SetPixel(
const Standard_Integer x,
const Standard_Integer y,
const Standard_Integer value )
{ unsigned char *p ;
unsigned long int pixel_size ;
Standard_OutOfRange_Raise_if(
( x < 0 || (unsigned int ) x >= myHeader.pixmap_width ||
y < 0 || (unsigned int ) y >= myHeader.pixmap_height ),
"Index out of range in X11XWDAlienData::Pixel");
pixel_size = ( unsigned long int ) myHeader.bytes_per_line /
myHeader.pixmap_width;
p = ( unsigned char * ) myData ;
p += y * myHeader.bytes_per_line + x * pixel_size ;
if ( pixel_size == 1 ) {
*p = ( unsigned char ) value ;
}
else if ( pixel_size == 2 ) {
*( ( unsigned short int * ) p ) = ( unsigned short int ) value ;
}
else if ( pixel_size == 4 ) {
*( ( unsigned long int * ) p ) = ( unsigned long int ) value ;
}
}
Standard_Integer AlienImage_X11XWDAlienData::Pixel(
const Standard_Integer x, const Standard_Integer y ) const
{ unsigned char *p ;
unsigned long int pixel_size ;
unsigned long int pix ;
Standard_Integer ret ;
Standard_OutOfRange_Raise_if(
( x < 0 || (unsigned int ) x >= myHeader.pixmap_width ||
y < 0 || (unsigned int ) y >= myHeader.pixmap_height ),
"Index out of range in X11XWDAlienData::Pixel");
pixel_size = ( unsigned long int ) myHeader.bytes_per_line /
myHeader.pixmap_width;
p = ( unsigned char * ) myData ;
p += y * myHeader.bytes_per_line + x * pixel_size ;
if ( pixel_size == 1 ) {
pix = ( unsigned long int ) *p ;
}
else if ( pixel_size == 2 ) {
pix = *( ( unsigned short int * ) p ) ;
}
else {
pix = *( ( unsigned long int * ) p ) ;
}
ret = Standard_Integer ( pix );
return( ret ) ;
}
Standard_Integer AlienImage_X11XWDAlienData::RedShift() const
{ Standard_Integer shift = 0 ;
Standard_TypeMismatch_Raise_if( myHeader.visual_class != TrueColor ,
"Attempt to get RedShift from a non TrueColor X11XWDImage" ) ;
if ( ( myHeader.red_mask >> myHeader.bits_per_rgb ) == 0 ) {
shift = 0 ;
}
else if ( ( myHeader.red_mask >> ( 2 * myHeader.bits_per_rgb ) ) == 0 ) {
shift = Standard_Integer( myHeader.bits_per_rgb ) ;
}
else {
shift = Standard_Integer( 2 * myHeader.bits_per_rgb );
}
return shift ;
}
Standard_Integer AlienImage_X11XWDAlienData::GreenShift() const
{ Standard_Integer shift = 0 ;
Standard_TypeMismatch_Raise_if( myHeader.visual_class != TrueColor ,
"Attempt to get GreenShift from a non TrueColor X11XWDImage" ) ;
if ( ( myHeader.green_mask >> myHeader.bits_per_rgb ) == 0 ) {
shift = 0 ;
}
else if ( ( myHeader.green_mask >> ( 2 * myHeader.bits_per_rgb ) ) == 0 ) {
shift = Standard_Integer( myHeader.bits_per_rgb ) ;
}
else {
shift = Standard_Integer( 2 * myHeader.bits_per_rgb ) ;
}
return shift ;
}
Standard_Integer AlienImage_X11XWDAlienData::BlueShift() const
{ Standard_Integer shift = 0 ;
Standard_TypeMismatch_Raise_if( myHeader.visual_class != TrueColor ,
"Attempt to get BlueShift from a non TrueColor X11XWDImage" ) ;
if ( ( myHeader.blue_mask >> myHeader.bits_per_rgb ) == 0 ) {
shift = 0 ;
}
else if ( ( myHeader.blue_mask >> ( 2 * myHeader.bits_per_rgb ) ) == 0 ) {
shift = Standard_Integer( myHeader.bits_per_rgb ) ;
}
else {
shift = Standard_Integer( 2 * myHeader.bits_per_rgb ) ;
}
return shift ;
}

View File

@ -1,152 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
# include <X11/Xlib.h>
#endif // WNT
#include <AlienImage_X11XWDFileHeader.hxx>
const Handle(Standard_Type)& STANDARD_TYPE(AlienImage_X11XWDFileHeader)
{
static Handle(Standard_Type) _atype =
new Standard_Type ("AlienImage_X11XWDFileHeader", sizeof (AlienImage_X11XWDFileHeader));
return _atype;
}
Standard_Boolean operator == (
const AlienImage_X11XWDFileHeader& AnObject,
const AlienImage_X11XWDFileHeader& AnotherObject)
{ Standard_Boolean _result = Standard_True;
_result = _result && (AnObject.header_size==
AnotherObject.header_size) ;
_result = _result && (AnObject.file_version==
AnotherObject.file_version) ;
_result = _result && (AnObject.pixmap_format==
AnotherObject.pixmap_format) ;
_result = _result && (AnObject.pixmap_depth==
AnotherObject.pixmap_depth) ;
_result = _result && (AnObject.pixmap_width==
AnotherObject.pixmap_width) ;
_result = _result && (AnObject.pixmap_height==
AnotherObject.pixmap_height) ;
_result = _result && (AnObject.xoffset==
AnotherObject.xoffset) ;
_result = _result && (AnObject.byte_order==
AnotherObject.byte_order) ;
_result = _result && (AnObject.bitmap_unit==
AnotherObject.bitmap_unit) ;
_result = _result && (AnObject.bitmap_bit_order==
AnotherObject.bitmap_bit_order) ;
_result = _result && (AnObject.bitmap_pad==
AnotherObject.bitmap_pad) ;
_result = _result && (AnObject.bits_per_pixel==
AnotherObject.bits_per_pixel) ;
_result = _result && (AnObject.bytes_per_line==
AnotherObject.bytes_per_line) ;
_result = _result && (AnObject.visual_class==
AnotherObject.visual_class) ;
_result = _result && (AnObject.red_mask==
AnotherObject.red_mask) ;
_result = _result && (AnObject.green_mask==
AnotherObject.green_mask) ;
_result = _result && (AnObject.blue_mask==
AnotherObject.blue_mask) ;
_result = _result && (AnObject.bits_per_rgb==
AnotherObject.bits_per_rgb) ;
_result = _result && (AnObject.colormap_entries==
AnotherObject.colormap_entries) ;
_result = _result && (AnObject.ncolors==
AnotherObject.ncolors) ;
_result = _result && (AnObject.window_width==
AnotherObject.window_width) ;
_result = _result && (AnObject.window_height==
AnotherObject.window_height) ;
_result = _result && (AnObject.window_x==
AnotherObject.window_x) ;
_result = _result && (AnObject.window_y==
AnotherObject.window_y) ;
_result = _result && (AnObject.window_bdrwidth==
AnotherObject.window_bdrwidth) ;
return _result;
}
//============================================================================
//==== ShallowDump : Writes a CString value.
//============================================================================
void ShallowDump (
const AlienImage_X11XWDFileHeader& AnObject,Standard_OStream& s) {
s << "AlienImage_X11XWDFileHeader" << "\n";
s << "\theader_size\t:" << AnObject.header_size << "\n" ;
s << "\tfile_version\t:" << AnObject.file_version << "\n" ;
s << "\tpixmap_format\t:" ; switch( AnObject.pixmap_format ) {
case XYBitmap :
s << "XYBitmap" ; break ;
case XYPixmap :
s << "XYPixmap" ; break ;
case ZPixmap :
s << "ZPixmap" ; break ;
default :
s << AnObject.pixmap_format ; break ;
} ; s << "\n" ;
s << "\tpixmap_depth\t:" << AnObject.pixmap_depth << "\n" ;
s << "\tpixmap_width\t:" << AnObject.pixmap_width << "\n" ;
s << "\tpixmap_height\t:" << AnObject.pixmap_height << "\n" ;
s << "\txoffset\t:" << AnObject.xoffset << "\n" ;
s << "\tbyte_order\t:" ;
if ( AnObject.byte_order == LSBFirst ) s << "LSBFirst" ;
else s << "MSBFirst" ;
s << "\n" ;
s << "\tbitmap_unit\t:" << AnObject.bitmap_unit << "\n" ;
s << "\tbitmap_bit_order\t:" ;
if ( AnObject.bitmap_bit_order == LSBFirst ) s << "LSBFirst" ;
else s << "MSBFirst" ;
s << "\n" ;
s << "\tbitmap_pad\t:" << AnObject.bitmap_pad << "\n" ;
s << "\tbits_per_pixel\t:" << AnObject.bits_per_pixel << "\n" ;
s << "\tbytes_per_line\t:" << AnObject.bytes_per_line << "\n" ;
s << "\tvisual_class\t:" ; switch( AnObject.visual_class ) {
case StaticGray : s << "StaticGray" ; break ;
case GrayScale : s << "GrayScale" ; break ;
case StaticColor : s << "StaticColor" ; break ;
case PseudoColor : s << "PseudoColor" ; break ;
case TrueColor : s << "TrueColor" ; break ;
case DirectColor : s << "DirectColor" ; break ;
default : s << AnObject.visual_class ; break ;
} ; s << "\n" ;
s << "\tred_mask\t:" << AnObject.red_mask << "\n" ;
s << "\tgreen_mask\t:" << AnObject.green_mask << "\n" ;
s << "\tblue_mask\t:" << AnObject.blue_mask << "\n" ;
s << "\tbits_per_rgb\t:" << AnObject.bits_per_rgb << "\n" ;
s << "\tcolormap_entries\t:" << AnObject.colormap_entries << "\n" ;
s << "\tncolors\t:" << AnObject.ncolors << "\n" ;
s << "\twindow_width\t:" << AnObject.window_width << "\n" ;
s << "\twindow_height\t:" << AnObject.window_height << "\n" ;
s << "\twindow_x\t:" << AnObject.window_x << "\n" ;
s << "\twindow_y\t:" << AnObject.window_y << "\n" ;
s << "\twindow_bdrwidth\t:" << AnObject.window_bdrwidth << "\n" << flush ;
}
ostream& operator << ( ostream& s, const AlienImage_X11XWDFileHeader& h )
{ ::ShallowDump( h, s ) ;
return( s ) ;
}

View File

@ -1,49 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
//============================================================================
//==== Titre: AlienImage_X11XWDFileHeader.hxx
//==== Role : The header file of primitve type "XWDFileHeader" from package //==== "X11"
//====
//==== Implementation: This is a primitive type implemented with typedef
//==== typedef XColor AlienImage_X11XWDFileHeader;
//============================================================================
#ifndef _AlienImage_X11XWDFileHeader_HeaderFile
#define _AlienImage_X11XWDFileHeader_HeaderFile
/*
* Data structure used by color operations from <X11/XWDFile.h>
*/
//==== Definition de Type ====================================================
#include <Standard_Type.hxx>
const Handle(Standard_Type)& STANDARD_TYPE(AlienImage_X11XWDFileHeader);
//============================================================================
#include <Aspect_XWD.hxx>
typedef XWDFileHeader AlienImage_X11XWDFileHeader ;
ostream& operator << ( ostream& s, const AlienImage_X11XWDFileHeader& h );
Standard_Boolean operator==(const AlienImage_X11XWDFileHeader& AnObject,
const AlienImage_X11XWDFileHeader& AnotherObject);
void ShallowDump (const AlienImage_X11XWDFileHeader& AnObject,Standard_OStream& S) ;
#endif

View File

@ -1,75 +0,0 @@
-- Created on: 1993-03-23
-- Created by: BBL
-- Copyright (c) 1993-1999 Matra Datavision
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
--
-- The content of this file is subject to the Open CASCADE Technology Public
-- License Version 6.5 (the "License"). You may not use the content of this file
-- except in compliance with the License. Please obtain a copy of the License
-- at http://www.opencascade.org and read it completely before using this file.
--
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
--
-- The Original Code and all software distributed under the License is
-- distributed on an "AS IS" basis, without warranty of any kind, and the
-- Initial Developer hereby disclaims all such warranties, including without
-- limitation, any warranties of merchantability, fitness for a particular
-- purpose or non-infringement. Please see the License for the specific terms
-- and conditions governing the rights and limitations under the License.
class XAlienImage from AlienImage inherits AlienUserImage from AlienImage
---Purpose: Defines an X11 Alien image, i.e. an image file to be
-- used with X11 xwd utility.
uses
File from OSD,
AsciiString from TCollection,
ColorImage from Image,
PseudoColorImage from Image,
Image from Image,
X11XWDAlienData from AlienImage
is
Create returns mutable XAlienImage from AlienImage;
---Purpose: Constructs an empty X11 alien image.
Clear( me : in out mutable) ;
---Level: Public
---Purpose: Frees memory allocated by XAlienImage
---C++: alias ~
SetName( me : in out mutable;
aName : in AsciiString from TCollection) ;
---Purpose: Sets the Image name for the Name function.
Name( me : in immutable ) returns AsciiString from TCollection ;
---C++: return const &
---Purpose: Returns the Image name.
ToImage( me : in immutable )
returns mutable Image from Image ;
---Level: Public
---Purpose : Converts an XAlienImage object to a Image object.
FromImage( me : in out mutable ; anImage : in Image from Image ) ;
---Level: Public
---Purpose : Converts an Image object to a XAlienImage object.
Read ( me : in out mutable; afile : in out File from OSD )
returns Boolean from Standard ;
---Level: Public
---Purpose: Reads the content of a XAlienImage object from a file .
-- Returns True if file is a XWD file .
Write( me : in immutable; afile : in out File from OSD )
returns Boolean from Standard ;
---Level: Public
---Purpose: Writes the content of a XAlienImage object to a file .
fields
myData : X11XWDAlienData from AlienImage;
end ;

View File

@ -1,53 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <AlienImage_XAlienImage.ixx>
AlienImage_XAlienImage::AlienImage_XAlienImage()
{ // il faut faire un new si mydata est du type HANDLE
myData = new AlienImage_X11XWDAlienData() ;
}
void AlienImage_XAlienImage::SetName( const TCollection_AsciiString& aName)
{ myData->SetName( aName ) ; }
const TCollection_AsciiString& AlienImage_XAlienImage::Name() const
{ return( myData->Name() ) ; }
void AlienImage_XAlienImage::Clear()
{ myData->Clear() ; }
Standard_Boolean AlienImage_XAlienImage::Write( OSD_File& file ) const
{ return( myData->Write( file ) ) ; }
Standard_Boolean AlienImage_XAlienImage::Read( OSD_File& file )
{ return( myData->Read( file ) ) ; }
Handle_Image_Image AlienImage_XAlienImage::ToImage() const
{ return( myData->ToImage() ) ; }
void AlienImage_XAlienImage::FromImage( const Handle_Image_Image& anImage )
{ myData->FromImage( anImage ) ; }

View File

@ -1,13 +0,0 @@
AlienImage_X11XColor.hxx
AlienImage_X11XColor.cxx
AlienImage_X11XWDFileHeader.hxx
AlienImage_X11XWDFileHeader.cxx
AlienImage_SGIRGBFileHeader.hxx
AlienImage_SGIRGBFileHeader.cxx
AlienImage_SUNRFFileHeader.hxx
AlienImage_SUNRFFileHeader.cxx
AlienImage_GIFLZWDict.hxx
AlienImage_GIFLZWDict.cxx
AlienImage_BMPHeader.hxx
AlienImage_BMPHeader.cxx

View File

@ -76,7 +76,6 @@ uses
MMgt,
WNT,
Image,
AlienImage,
gp,
Font
is

View File

@ -46,7 +46,6 @@ uses
PlaneAngle from Quantity,
AlienImage from AlienImage,
PixMap from Image,
Array1OfEdge from Aspect,

View File

@ -1,11 +1,4 @@
EXTERNLIB
Image_GImage.gxx
Image_GPixelField.gxx
Image_GPixelField.lxx
Image_PixelAddress.cxx
Image_PixelAddress.hxx
Image.edl
Image_CMPLRS.edl
Image_PixMap.hxx
Image_PixMap.cxx
Image_PixMap_Handle.hxx

View File

@ -18,184 +18,29 @@
-- purpose or non-infringement. Please see the License for the specific terms
-- and conditions governing the rights and limitations under the License.
package Image
---Purpose: The package Image provide PseudoColorImage and ColorImage
-- definition and a set of key functions from the fields
-- of image.
---Purpose: The package Image provides image manipulation classes.
uses
TCollection,
TColStd,
Aspect,
Quantity,
gp,
MMgt
TCollection,
TColStd,
Aspect,
Quantity,
gp,
MMgt
is
------------------------
---Category: The classes
------------------------
deferred class Image;
-----------------------------
---Category: Imported types:
-----------------------------
class PixelInterpolation;
class AveragePixelInterpolation;
class BalancedPixelInterpolation;
class PlanarPixelInterpolation;
class BilinearPixelInterpolation;
---Purpose : Several methods to compute Pixel on non-integer Image
-- coordinate.
private generic class GPixelField;
---Purpose : Generic Image definition .
deferred generic class GImage, PixelRow, PixelField;
---Purpose : Generic Image definition .
deferred class DColorImage
instantiates GImage from Image (ColorPixel from Aspect);
---Purpose : instantiates GImage for ColorImage definition .
deferred class DIndexedImage
instantiates GImage from Image (IndexPixel from Aspect);
---Purpose : instantiates GImage for PseudoColorImage definition .
class PseudoColorImage;
---Purpose : PseudoColorImage definition .
class ColorImage;
---Purpose : ColorImage definition .
class Convertor;
---Purpose: converts aPseudoColorImage to a ColorImage and vice-versa.
class ColorPixelMapHasher instantiates
MapHasher from TCollection( ColorPixel from Aspect );
class ColorPixelDataMap instantiates
DataMap from TCollection ( ColorPixel from Aspect,
Integer from Standard,
ColorPixelMapHasher from Image ) ;
class IndexPixelMapHasher instantiates
MapHasher from TCollection( IndexPixel from Aspect );
class LookupTable instantiates
DataMap from TCollection( IndexPixel from Aspect,
IndexPixel from Aspect,
IndexPixelMapHasher );
-----------------------------
---Category: Imported types:
-----------------------------
imported PixelAddress;
imported PixMap;
imported AlienPixMap;
imported PixMap_Handle;
imported AlienPixMap_Handle;
imported Diff;
-----------------------------
---Category: The Enumerations
-----------------------------
enumeration FlipType is FT_HORIZONTAL,
FT_VERTICAL,
FT_MAINDIAGONAL,
FT_ANTIDIAGONAL,
FT_CENTER,
FT_90,
FT_180,
FT_270
end FlipType ;
---Purpose: Type of orientation in a symmetry.
-- - FT_HORIZONTAL : symmetry with respect to an horizontal axis.
-- - FT_VERTICAL : symmetry with respect to a vertical axis.
-- - FT_MAINDIAGONAL : symmetry with respect to a
-- diagonal oriented at 45 degrees.
-- - FT_ANTIDIAGONAL : symmetry with respect to a
-- diagonal oriented at -45 degrees.
-- - FT_CENTER :
-- - FT_90 : rotation of 90 degrees.
-- - FT_180 : rotation of 180 degrees.
-- - FT_270 : rotation of -90 degrees.
enumeration DitheringMethod is DM_NearestColor,
DM_ErrorDiffusion
end DitheringMethod ;
---Purpose: Type of dithering method.
enumeration TypeOfImage is TOI_ColorImage,
TOI_PseudoColorImage
end TypeOfImage ;
Zoom ( aImage : mutable Image from Image ;
aInterpolation : PixelInterpolation from Image;
aCoefX,aCoefY : in Real from Standard ) ;
---Purpose : Zoom an Image with a specific PixelInterpolation method.
Zoom ( aImage : mutable Image from Image ;
aCoefX,aCoefY : in Real from Standard ) ;
---Purpose : Zoom an Image with the default PixelInterpolation method.
Rotate ( aImage : mutable Image from Image ;
aInterpolation : PixelInterpolation from Image;
aAngle : in PlaneAngle from Quantity ) ;
---Purpose : Rotate an Image with a specific PixelInterpolation method.
Rotate ( aImage : mutable Image from Image ;
aAngle : in PlaneAngle from Quantity ) ;
---Purpose : Rotate an Image with the default PixelInterpolation method.
Translate( aImage : mutable Image from Image ;
aInterpolation : PixelInterpolation from Image;
DX, DY : in Real from Standard ) ;
---Purpose : Translate an Image with a specific PixelInterpolation
-- method.
Translate( aImage : mutable Image from Image ;
DX, DY : in Real from Standard ) ;
---Purpose : Translate an Image with the default PixelInterpolation
-- method.
Affine( aImage : mutable Image from Image ;
aInterpolation : PixelInterpolation from Image;
Trsf : in GTrsf2d from gp ) ;
---Purpose : General transformation of an Image with a specific
-- PixelInterpolation method.
-- Warning:
-- Raises an exception if the matrix of the transformation
-- is not inversible.
Affine( aImage : mutable Image from Image ;
Trsf : in GTrsf2d from gp ) ;
---Purpose : General transformation of an Image with the default
-- PixelInterpolation method.
-- Warning:
-- Raises an exception if the matrix of the transformation
-- is not inversible.
Affine( aImage : mutable Image from Image ;
aInterpolation : PixelInterpolation from Image;
Trsf : in Trsf from gp ) ;
---Purpose : General transformation of an Image with a specific
-- PixelInterpolation method.
-- Warning:
-- Raises an exception if the matrix of the transformation
-- is not inversible.
Affine( aImage : mutable Image from Image ;
Trsf : in Trsf from gp ) ;
---Purpose : General transformation of an Image with the default
-- PixelInterpolation method.
-- Warning:
-- Raises an exception if the matrix of the transformation
-- is not inversible.
imported PixMap;
imported AlienPixMap;
imported PixMap_Handle;
imported AlienPixMap_Handle;
imported Diff;
end Image;

View File

@ -1,184 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
// Modified 27/12/98 : FMN ; PERF: OPTIMISATION LOADER (LOPTIM)
#include <Image_DIndexedImage.hxx>
#include <Image_DColorImage.hxx>
#include <Image_PixelInterpolation.hxx>
#include <Image.ixx>
#define LOPTIM
#ifndef LOPTIM
static Image_PixelInterpolation DefaultPixelInterpolation ;
#else
static Image_PixelInterpolation& _DefaultPixelInterpolation() {
static Image_PixelInterpolation DefaultPixelInterpolation ;
return DefaultPixelInterpolation;
}
#define DefaultPixelInterpolation _DefaultPixelInterpolation()
#endif // LOPTIM
//------------------------------- Image::Zoom --------------------------------
void Image::Zoom( const Handle(Image_Image)& aImage,
const Standard_Real CoefX, const Standard_Real CoefY )
{ if ( aImage->IsKind(STANDARD_TYPE(Image_DIndexedImage))) {
(Handle(Image_DIndexedImage)::DownCast( aImage ))->Zoom(
DefaultPixelInterpolation, CoefX, CoefY ) ;
}
else if ( aImage->IsKind(STANDARD_TYPE(Image_DColorImage))) {
(Handle(Image_DColorImage)::DownCast( aImage ))->Zoom(
DefaultPixelInterpolation, CoefX, CoefY ) ;
}
}
void Image::Zoom( const Handle(Image_Image)& aImage,
const Image_PixelInterpolation& aInterpolation,
const Standard_Real CoefX, const Standard_Real CoefY )
{
if ( aImage->IsKind(STANDARD_TYPE(Image_DIndexedImage))) {
(Handle(Image_DIndexedImage)::DownCast( aImage ))->Zoom(
aInterpolation, CoefX, CoefY ) ;
}
else if ( aImage->IsKind(STANDARD_TYPE(Image_DColorImage))) {
(Handle(Image_DColorImage)::DownCast( aImage ))->Zoom(
aInterpolation, CoefX, CoefY ) ;
}
}
//------------------------------- Image::Translate ---------------------------
void Image::Translate( const Handle(Image_Image)& aImage,
const Standard_Real DX, const Standard_Real DY )
{ if ( aImage->IsKind(STANDARD_TYPE(Image_DIndexedImage))) {
(Handle(Image_DIndexedImage)::DownCast( aImage ))->Translate(
DefaultPixelInterpolation, DX, DY ) ;
}
else if ( aImage->IsKind(STANDARD_TYPE(Image_DColorImage))) {
(Handle(Image_DColorImage)::DownCast( aImage ))->Translate(
DefaultPixelInterpolation, DX, DY ) ;
}
}
void Image::Translate( const Handle(Image_Image)& aImage,
const Image_PixelInterpolation& aInterpolation,
const Standard_Real DX, const Standard_Real DY )
{
if ( aImage->IsKind(STANDARD_TYPE(Image_DIndexedImage))) {
(Handle(Image_DIndexedImage)::DownCast( aImage ))->Translate(
aInterpolation, DX, DY ) ;
}
else if ( aImage->IsKind(STANDARD_TYPE(Image_DColorImage))) {
(Handle(Image_DColorImage)::DownCast( aImage ))->Translate(
aInterpolation, DX, DY ) ;
}
}
//------------------------------- Image::Rotate ------------------------------
void Image::Rotate( const Handle(Image_Image)& aImage,
const Quantity_PlaneAngle aAngle )
{ if ( aImage->IsKind(STANDARD_TYPE(Image_DIndexedImage))) {
(Handle(Image_DIndexedImage)::DownCast( aImage ))->Rotate(
DefaultPixelInterpolation, aAngle ) ;
}
else if ( aImage->IsKind(STANDARD_TYPE(Image_DColorImage))) {
(Handle(Image_DColorImage)::DownCast( aImage ))->Rotate(
DefaultPixelInterpolation, aAngle ) ;
}
}
void Image::Rotate( const Handle(Image_Image)& aImage,
const Image_PixelInterpolation& aInterpolation,
const Quantity_PlaneAngle aAngle )
{
if ( aImage->IsKind(STANDARD_TYPE(Image_DIndexedImage))) {
(Handle(Image_DIndexedImage)::DownCast( aImage ))->Rotate(
aInterpolation,aAngle ) ;
}
else if ( aImage->IsKind(STANDARD_TYPE(Image_DColorImage))) {
(Handle(Image_DColorImage)::DownCast( aImage ))->Rotate(
aInterpolation,aAngle ) ;
}
}
//------------------------------- Image::Affine ------------------------------
void Image::Affine( const Handle(Image_Image)& aImage,
const gp_GTrsf2d& aTrsf )
{ if ( aImage->IsKind(STANDARD_TYPE(Image_DIndexedImage))) {
(Handle(Image_DIndexedImage)::DownCast( aImage ))->Affine(
DefaultPixelInterpolation, aTrsf ) ;
}
else if ( aImage->IsKind(STANDARD_TYPE(Image_DColorImage))) {
(Handle(Image_DColorImage)::DownCast( aImage ))->Affine(
DefaultPixelInterpolation, aTrsf ) ;
}
}
void Image::Affine( const Handle(Image_Image)& aImage,
const Image_PixelInterpolation& aInterpolation,
const gp_GTrsf2d& aTrsf )
{
if ( aImage->IsKind(STANDARD_TYPE(Image_DIndexedImage))) {
(Handle(Image_DIndexedImage)::DownCast( aImage ))->Affine(
aInterpolation,aTrsf ) ;
}
else if ( aImage->IsKind(STANDARD_TYPE(Image_DColorImage))) {
(Handle(Image_DColorImage)::DownCast( aImage ))->Affine(
aInterpolation,aTrsf ) ;
}
}
void Image::Affine( const Handle(Image_Image)& aImage,
const gp_Trsf& aTrsf )
{ if ( aImage->IsKind(STANDARD_TYPE(Image_DIndexedImage))) {
(Handle(Image_DIndexedImage)::DownCast( aImage ))->Affine(
DefaultPixelInterpolation, aTrsf ) ;
}
else if ( aImage->IsKind(STANDARD_TYPE(Image_DColorImage))) {
(Handle(Image_DColorImage)::DownCast( aImage ))->Affine(
DefaultPixelInterpolation, aTrsf ) ;
}
}
void Image::Affine( const Handle(Image_Image)& aImage,
const Image_PixelInterpolation& aInterpolation,
const gp_Trsf& aTrsf )
{
if ( aImage->IsKind(STANDARD_TYPE(Image_DIndexedImage))) {
(Handle(Image_DIndexedImage)::DownCast( aImage ))->Affine(
aInterpolation,aTrsf ) ;
}
else if ( aImage->IsKind(STANDARD_TYPE(Image_DColorImage))) {
(Handle(Image_DColorImage)::DownCast( aImage ))->Affine(
aInterpolation,aTrsf ) ;
}
}

View File

@ -1,24 +0,0 @@
-- Created on: 1996-10-03
-- Created by: Jean GAUTIER
-- Copyright (c) 1996-1999 Matra Datavision
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
--
-- The content of this file is subject to the Open CASCADE Technology Public
-- License Version 6.5 (the "License"). You may not use the content of this file
-- except in compliance with the License. Please obtain a copy of the License
-- at http://www.opencascade.org and read it completely before using this file.
--
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
--
-- The Original Code and all software distributed under the License is
-- distributed on an "AS IS" basis, without warranty of any kind, and the
-- Initial Developer hereby disclaims all such warranties, including without
-- limitation, any warranties of merchantability, fitness for a particular
-- purpose or non-infringement. Please see the License for the specific terms
-- and conditions governing the rights and limitations under the License.
@ifnotdefined ( %Image_EDL) then
@set %Image_EDL = "";
@endif;

View File

@ -21,7 +21,6 @@
#define _Image_AlienPixMap_H__
#include <Image_PixMap.hxx>
#include <Image_TypeOfImage.hxx>
class TCollection_AsciiString;
struct FIBITMAP;

View File

@ -1,91 +0,0 @@
-- Created on: 1993-07-27
-- Created by: Jean Louis FRENKEL
-- Copyright (c) 1993-1999 Matra Datavision
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
--
-- The content of this file is subject to the Open CASCADE Technology Public
-- License Version 6.5 (the "License"). You may not use the content of this file
-- except in compliance with the License. Please obtain a copy of the License
-- at http://www.opencascade.org and read it completely before using this file.
--
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
--
-- The Original Code and all software distributed under the License is
-- distributed on an "AS IS" basis, without warranty of any kind, and the
-- Initial Developer hereby disclaims all such warranties, including without
-- limitation, any warranties of merchantability, fitness for a particular
-- purpose or non-infringement. Please see the License for the specific terms
-- and conditions governing the rights and limitations under the License.
class AveragePixelInterpolation from Image inherits PixelInterpolation from Image
---Purpose: The class AveragePixelInterpolation is used to compute a SubPixel
-- value on non integer Image coordinate
-- AveragePixelInterpolation redefined a new method to compute a
-- SubPixel value .
-- SubPixel value is the average of the three nearest Pixel in
-- the Image .
-- If V1, V2, V3, V4 is the value of the three nearest Image
-- Pixel V = ( V1+V2+V3 ) / 3 is the Image SubPixel value
-- on non integer coordinate (FX,FY)
uses
Image from Image,
Pixel from Aspect,
ColorPixel from Aspect,
IndexPixel from Aspect,
DColorImage from Image,
DIndexedImage from Image
is
Create returns AveragePixelInterpolation from Image ;
---Level: Public
---Purpose: Create a AveragePixelInterpolation object.
Interpolate( me ; aImage : Image from Image ;
FX,FY : Real from Standard ;
LowerX,LowerY,UpperX,UpperY : Integer from Standard ;
RetPixel : in out Pixel from Aspect )
returns Boolean from Standard is redefined ;
---Level: Public
---Purpose: Redefined the method to compute SubPixel's value
-- on non integer Image coordinate.
-- LowerX,LowerY,UpperX,UpperY is the Image Min Max, it's use
-- check if the SubPixel coordinate FX,FY is outside of image.
-- Return True if Interpolation Succes.
-- Return False if the SubPixel is out from Image.
Interpolate( me ; aImage : DColorImage from Image ;
FX,FY : Real from Standard ;
LowerX,LowerY,UpperX,UpperY : Integer from Standard ;
RetPixel : in out ColorPixel from Aspect )
returns Boolean from Standard is redefined;
---Level: Public
---Purpose: Compute SubPixel's value on non integer Image coordinate for
-- DColorImage and ColorPixel.
-- LowerX,LowerY,UpperX,UpperY is the Image Min Max, it's use
-- check if the SubPixel coordinate FX,FY is outside of image.
-- Return True if Interpolation Succes.
-- Return False if the SubPixel is out from Image.
Interpolate( me ; aImage : DIndexedImage from Image ;
FX,FY : Real from Standard ;
LowerX,LowerY,UpperX,UpperY : Integer from Standard ;
RetPixel : in out IndexPixel from Aspect )
returns Boolean from Standard is redefined;
---Level: Public
---Purpose: Compute SubPixel's value on non integer Image coordinate for
-- DIndexedImage and IndexPixel.
-- LowerX,LowerY,UpperX,UpperY is the Image Min Max, it's use
-- check if the SubPixel coordinate X,Y is outside of image.
-- Return True if Interpolation Succes.
-- Return False if the SubPixel is out from Image.
end AveragePixelInterpolation from Image;

View File

@ -1,351 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <Image_AveragePixelInterpolation.ixx>
Image_AveragePixelInterpolation::Image_AveragePixelInterpolation() {}
Standard_Boolean Image_AveragePixelInterpolation::Interpolate(
const Handle(Image_Image)& aImage,
const Standard_Real FX, const Standard_Real FY,
const Standard_Integer LowX,
const Standard_Integer LowY,
const Standard_Integer UpX,
const Standard_Integer UpY,
Aspect_Pixel& aPixel ) const
{
if ( aImage->IsKind(STANDARD_TYPE(Image_DIndexedImage))) {
return Interpolate( Handle(Image_DIndexedImage)::DownCast( aImage ),
FX,FY,LowX,LowY,UpX,UpY,(Aspect_IndexPixel &)aPixel ) ;
}
else if ( aImage->IsKind(STANDARD_TYPE(Image_DColorImage))) {
return Interpolate( Handle(Image_DColorImage)::DownCast( aImage ),
FX,FY,LowX,LowY,UpX,UpY,(Aspect_ColorPixel &)aPixel ) ;
}
else {
return Image_PixelInterpolation::Interpolate( aImage,
FX,FY,LowX,LowY,UpX,UpY,aPixel ) ;
}
}
Standard_Boolean Image_AveragePixelInterpolation::Interpolate(
const Handle(Image_DColorImage)& aImage,
const Standard_Real FX, const Standard_Real FY,
const Standard_Integer LowX,
const Standard_Integer LowY,
const Standard_Integer UpX,
const Standard_Integer UpY,
Aspect_ColorPixel& aPixel ) const
{ Standard_Integer NX[3], NY[3] ;
Standard_Real NZ[3] ;
Standard_Real R,G,B ;
static Quantity_Color Col ;
Standard_Boolean SamePixels = 1 ;
if ( FX < 0. ) NX[0] = Standard_Integer(FX-0.5) ;
else NX[0] = Standard_Integer(FX+0.5) ;
if ( FY < 0. ) NY[0] = Standard_Integer(FY-0.5) ;
else NY[0] = Standard_Integer(FY+0.5) ;
if ( NX[0] < LowX || NX[0] > UpX ||
NY[0] < LowY || NY[0] > UpY ) {
return Standard_False ;
}
else if ( ( FX-NX[0] ) == 0. && ( FY-NY[0] ) == 0. ) {
aImage->Pixel( NX[0], NY[0], aPixel );
return Standard_True ;
}
else {
if ( ( FX-NX[0] ) >= 0. ) { NX[1] = NX[0]+1 ; NY[1] = NY[0] ; }
else { NX[1] = NX[0]-1 ; NY[1] = NY[0] ; }
if ( ( FY-NY[0] ) >= 0. ) { NX[2] = NX[0] ; NY[2] = NY[0]+1 ; }
else { NX[2] = NX[0] ; NY[2] = NY[0]-1 ; }
if ( NX[1] < LowX || NX[1] > UpX || NY[1] < LowY || NY[1] > UpY ||
NX[2] < LowX || NX[2] > UpX || NY[2] < LowY || NY[2] > UpY ) {
aImage->Pixel( NX[0], NY[0], aPixel );
}
else {
NZ[0] = aImage->Pixel( NX[0],NY[0] ).Value().Red() ;
NZ[1] = aImage->Pixel( NX[1],NY[1] ).Value().Red() ;
NZ[2] = aImage->Pixel( NX[2],NY[2] ).Value().Red() ;
if ( NZ[0] == NZ[1] && NZ[0] == NZ[2] ) {
R = NZ[0] ;
}
else {
R = ( NZ[0] + NZ[1] + NZ[2] ) / 3. ;
SamePixels = 0 ;
}
NZ[0] = aImage->Pixel( NX[0],NY[0] ).Value().Green() ;
NZ[1] = aImage->Pixel( NX[1],NY[1] ).Value().Green() ;
NZ[2] = aImage->Pixel( NX[2],NY[2] ).Value().Green() ;
if ( NZ[0] == NZ[1] && NZ[0] == NZ[2] ) {
G = NZ[0] ;
}
else {
G = ( NZ[0] + NZ[1] + NZ[2] ) / 3. ;
SamePixels = 0 ;
}
NZ[0] = aImage->Pixel( NX[0],NY[0] ).Value().Blue() ;
NZ[1] = aImage->Pixel( NX[1],NY[1] ).Value().Blue() ;
NZ[2] = aImage->Pixel( NX[2],NY[2] ).Value().Blue() ;
if ( NZ[0] == NZ[1] && NZ[0] == NZ[2] ) {
B = NZ[0] ;
}
else {
B = ( NZ[0] + NZ[1] + NZ[2] ) / 3. ;
SamePixels = 0 ;
}
if ( SamePixels ) {
aPixel.SetValue( aImage->Pixel( NX[0],NY[0] ).Value() );
}
else {
Col.SetValues( R, G, B, Quantity_TOC_RGB ) ;
aPixel.SetValue( Col ) ;
}
}
return Standard_True ;
}
}
Standard_Boolean Image_AveragePixelInterpolation::Interpolate(
const Handle(Image_DIndexedImage)& aImage,
const Standard_Real FX, const Standard_Real FY,
const Standard_Integer LowX,
const Standard_Integer LowY,
const Standard_Integer UpX,
const Standard_Integer UpY,
Aspect_IndexPixel& aPixel ) const
{ Standard_Integer NX[3], NY[3] ;
Standard_Real NZ[3] ;
if ( FX < 0. ) NX[0] = Standard_Integer(FX-0.5) ;
else NX[0] = Standard_Integer(FX+0.5) ;
if ( FY < 0. ) NY[0] = Standard_Integer(FY-0.5) ;
else NY[0] = Standard_Integer(FY+0.5) ;
if ( NX[0] < LowX || NX[0] > UpX ||
NY[0] < LowY || NY[0] > UpY ) {
return Standard_False ;
}
else if ( ( FX-NX[0] ) == 0. && ( FY-NY[0] ) == 0. ) {
aImage->Pixel( NX[0], NY[0], aPixel );
return Standard_True ;
}
else {
if ( ( FX-NX[0] ) >= 0. ) { NX[1] = NX[0]+1 ; NY[1] = NY[0] ; }
else { NX[1] = NX[0]-1 ; NY[1] = NY[0] ; }
if ( ( FY-NY[0] ) >= 0. ) { NX[2] = NX[0] ; NY[2] = NY[0]+1 ; }
else { NX[2] = NX[0] ; NY[2] = NY[0]-1 ; }
if ( NX[1] < LowX || NX[1] > UpX || NY[1] < LowY || NY[1] > UpY ||
NX[2] < LowX || NX[2] > UpX || NY[2] < LowY || NY[2] > UpY ) {
aImage->Pixel( NX[0], NY[0], aPixel );
}
else {
NZ[0] = aImage->Pixel( NX[0],NY[0] ).Value() ;
NZ[1] = aImage->Pixel( NX[1],NY[1] ).Value() ;
NZ[2] = aImage->Pixel( NX[2],NY[2] ).Value() ;
if ( NZ[0] == NZ[1] && NZ[0] == NZ[2] ) {
aPixel.SetValue( Standard_Integer( NZ[0] ) ) ;
}
else {
aPixel.SetValue( Standard_Integer((NZ[0]+NZ[1]+NZ[2])/3.) ) ;
}
}
return Standard_True ;
}
}
//##############################################################################
#ifdef OLD
Standard_Boolean Image_AveragePixelInterpolation::Interpolate(
const Handle(Image_DColorImage)& aImage,
const Standard_Real FX, const Standard_Real FY,
const Standard_Integer LowX,
const Standard_Integer LowY,
const Standard_Integer UpX,
const Standard_Integer UpY,
Aspect_ColorPixel& aPixel ) const
{ Standard_Integer NX = Standard_Integer(FX) ;
Standard_Integer NY = Standard_Integer(FY) ;
Standard_Integer X,Y ;
Standard_Real SD, SR, SG, SB, R, G, B ;
if ( NX < ( LowX-1 ) || NX > UpX ||
NY < ( LowY-1 ) || NY > UpY ) {
return Standard_False ;
}
else {
if ( FX < 0. ) NX-- ;
if ( FY < 0. ) NY-- ;
SR = SG = SB = SD = 0. ;
// (0,0)
X = NX ; Y = NY ;
if ( !( X < LowX || X > UpX ||
Y < LowY || Y > UpY ) ) {
aImage->Pixel( X,Y ).Value().Values( R, G, B, Quantity_TOC_RGB ) ;
SR += R ; SG += G ; SB += B ; SD += 1. ;
}
// (1,0)
X = NX+1 ; Y = NY ;
if ( !( X < LowX || X > UpX || Y < LowY || Y > UpY ) ) {
aImage->Pixel( X,Y ).Value().Values( R, G, B, Quantity_TOC_RGB ) ;
SR += R ; SG += G ; SB += B ; SD += 1. ;
}
// (0,1)
X = NX ; Y = NY+1 ;
if ( !( X < LowX || X > UpX ||
Y < LowY || Y > UpY ) ) {
aImage->Pixel( X,Y ).Value().Values( R, G, B, Quantity_TOC_RGB ) ;
SR += R ; SG += G ; SB += B ; SD += 1. ;
}
// (1,1)
X = NX+1 ; Y = NY+1 ;
if ( !( X < LowX || X > UpX ||
Y < LowY || Y > UpY ) ) {
aImage->Pixel( X,Y ).Value().Values( R, G, B, Quantity_TOC_RGB ) ;
SR += R ; SG += G ; SB += B ; SD += 1. ;
}
// Result
if ( SD != 0. ) {
SR /= SD ; SG /= SD ; SB /= SD ;
aPixel.SetValue( Quantity_Color( SR, SG, SB, Quantity_TOC_RGB ) ) ;
return Standard_True ;
}
else {
return Standard_False ;
}
}
}
Standard_Boolean Image_AveragePixelInterpolation::Interpolate(
const Handle(Image_DIndexedImage)& aImage,
const Standard_Real FX, const Standard_Real FY,
const Standard_Integer LowX,
const Standard_Integer LowY,
const Standard_Integer UpX,
const Standard_Integer UpY,
Aspect_IndexPixel& aPixel ) const
{ Standard_Integer NX = Standard_Integer(FX) ;
Standard_Integer NY = Standard_Integer(FY) ;
Standard_Integer X,Y ;
Standard_Real SD, SP ;
if ( NX < ( LowX-1 ) || NX > UpX ||
NY < ( LowY-1 ) || NY > UpY ) {
return Standard_False ;
}
else {
if ( FX < 0. ) NX-- ;
if ( FY < 0. ) NY-- ;
SP = SD = 0. ;
// (0,0)
X = NX ; Y = NY ;
if ( !( X < LowX || X > UpX ||
Y < LowY || Y > UpY ) ) {
SP += aImage->Pixel( X,Y ).Value() ; SD += 1. ;
}
// (1,0)
X = NX+1 ; Y = NY ;
if ( !( X < LowX || X > UpX ||
Y < LowY || Y > UpY ) ) {
SP += aImage->Pixel( X,Y ).Value() ; SD += 1. ;
}
// (0,1)
X = NX ; Y = NY+1 ;
if ( !( X < LowX || X > UpX ||
Y < LowY || Y > UpY ) ) {
SP += aImage->Pixel( X,Y ).Value() ; SD += 1. ;
}
// (1,1)
X = NX+1 ; Y = NY+1 ;
if ( !( X < LowX || X > UpX ||
Y < LowY || Y > UpY ) ) {
SP += aImage->Pixel( X,Y ).Value() ; SD += 1. ;
}
// Result
if ( SD != 0. ) {
SP /= SD ;
aPixel.SetValue( Standard_Integer(SP+0.5) ) ;
return Standard_True ;
}
else {
return Standard_False ;
}
}
}
#endif

View File

@ -1,103 +0,0 @@
-- Created on: 1993-07-27
-- Created by: Jean Louis FRENKEL
-- Copyright (c) 1993-1999 Matra Datavision
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
--
-- The content of this file is subject to the Open CASCADE Technology Public
-- License Version 6.5 (the "License"). You may not use the content of this file
-- except in compliance with the License. Please obtain a copy of the License
-- at http://www.opencascade.org and read it completely before using this file.
--
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
--
-- The Original Code and all software distributed under the License is
-- distributed on an "AS IS" basis, without warranty of any kind, and the
-- Initial Developer hereby disclaims all such warranties, including without
-- limitation, any warranties of merchantability, fitness for a particular
-- purpose or non-infringement. Please see the License for the specific terms
-- and conditions governing the rights and limitations under the License.
class BalancedPixelInterpolation from Image inherits PixelInterpolation from Image
---Purpose: The class BalancedPixelInterpolation is used to compute a
-- SubPixel value on non integer Image coordinate
-- BalancedPixelInterpolation redefined a new method to compute
-- a SubPixel value .
-- The value is the proportional to the distance of the
-- four nearest Image Pixel.
-- A B
-- SubPixel
-- C D
-- If VA, VB, VC, VD is the value of the four nearest Image
-- Pixel, if ColDelta and RowDelta is the distance from non
-- integer coordinate (FX,FY) to the upper left nearest Image
-- Pixel , then :
-- ColDelta = FX - XA ;
-- RowDelta = FY - YA ;
-- CAB = ColDelta*( VB - VA ) + VA
-- CCD = ColDelta*( VD - VC ) + VD
-- V = RowDelta*( CCD - CAB ) + CAB
-- is the Image SubPixel value on non integer
-- coordinate (FX,FY).
uses
Image from Image,
Pixel from Aspect,
ColorPixel from Aspect,
IndexPixel from Aspect,
DColorImage from Image,
DIndexedImage from Image
is
Create returns BalancedPixelInterpolation from Image ;
---Level: Public
---Purpose: Create a BalancedPixelInterpolation object.
Interpolate( me ; aImage : Image from Image ;
FX,FY : Real from Standard ;
LowerX,LowerY,UpperX,UpperY : Integer from Standard ;
RetPixel : in out Pixel from Aspect )
returns Boolean from Standard is redefined ;
---Level: Public
---Purpose: Redefined the method to compute SubPixel's value
-- on non integer Image coordinate.
-- LowerX,LowerY,UpperX,UpperY is the Image Min Max, it's used
-- to check if the SubPixel coordinate FX,FY is outside of
-- image.
-- Return True if Interpolation Succes.
-- Return False if the SubPixel is out from Image.
Interpolate( me ; aImage : DColorImage from Image ;
FX,FY : Real from Standard ;
LowerX,LowerY,UpperX,UpperY : Integer from Standard ;
RetPixel : in out ColorPixel from Aspect )
returns Boolean from Standard is redefined;
---Level: Public
---Purpose: Compute SubPixel's value on non integer Image coordinate for
-- DColorImage and ColorPixel.
-- LowerX,LowerY,UpperX,UpperY is the Image Min Max, it's used
-- to check if the SubPixel coordinate FX,FY is outside of
-- image.
-- Return True if Interpolation Succes.
-- Return False if the SubPixel is out from Image.
Interpolate( me ; aImage : DIndexedImage from Image ;
FX,FY : Real from Standard ;
LowerX,LowerY,UpperX,UpperY : Integer from Standard ;
RetPixel : in out IndexPixel from Aspect )
returns Boolean from Standard is redefined;
---Level: Public
---Purpose: Compute SubPixel's value on non integer Image coordinate for
-- DIndexedImage and IndexPixel.
-- LowerX,LowerY,UpperX,UpperY is the Image Min Max, it's used
-- to check if the SubPixel coordinate X,Y is outside of
-- image.
-- Return True if Interpolation Succes.
-- Return False if the SubPixel is out from Image.
end BalancedPixelInterpolation from Image;

View File

@ -1,622 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <Image_BalancedPixelInterpolation.ixx>
Image_BalancedPixelInterpolation::Image_BalancedPixelInterpolation() {}
Standard_Boolean Image_BalancedPixelInterpolation::Interpolate(
const Handle(Image_Image)& aImage,
const Standard_Real FX, const Standard_Real FY,
const Standard_Integer LowX,
const Standard_Integer LowY,
const Standard_Integer UpX,
const Standard_Integer UpY,
Aspect_Pixel& aPixel ) const
{
if ( aImage->IsKind(STANDARD_TYPE(Image_DIndexedImage))) {
return Interpolate( Handle(Image_DIndexedImage)::DownCast( aImage ),
FX,FY,LowX,LowY,UpX,UpY,(Aspect_IndexPixel &)aPixel ) ;
}
else if ( aImage->IsKind(STANDARD_TYPE(Image_DColorImage))) {
return Interpolate( Handle(Image_DColorImage)::DownCast( aImage ),
FX,FY,LowX,LowY,UpX,UpY,(Aspect_ColorPixel &)aPixel ) ;
}
else {
return Image_PixelInterpolation::Interpolate( aImage,
FX,FY,LowX,LowY,UpX,UpY,aPixel ) ;
}
}
Standard_Boolean Image_BalancedPixelInterpolation::Interpolate(
const Handle(Image_DColorImage)& aImage,
const Standard_Real FX, const Standard_Real FY,
const Standard_Integer LowX,
const Standard_Integer LowY,
const Standard_Integer UpX,
const Standard_Integer UpY,
Aspect_ColorPixel& aPixel ) const
{ Standard_Integer NX = Standard_Integer(FX) ;
Standard_Integer NY = Standard_Integer(FY) ;
Standard_Integer X[4],Y[4], i ;
Standard_Real R[4], G[4], B[4];
Standard_Boolean DoV[4], SamePixels = 1 ;
Standard_Real SR, SG, SB;
if ( FX < 0. ) NX-- ;
if ( FY < 0. ) NY-- ;
if ( NX < ( LowX-1 ) || NX > UpX ||
NY < ( LowY-1 ) || NY > UpY ) {
return Standard_False ;
}
else {
for ( i = 0 ; i < 4 ; i++ ) DoV[i] = 0 ;
// (0,0)
i = 0; X[i] = NX ; Y[i] = NY ;
if ( !( X[i] < LowX || X[i] > UpX ||
Y[i] < LowY || Y[i] > UpY ) ) {
aImage->Pixel(X[i],Y[i]).Value().
Values( R[i],G[i],B[i],Quantity_TOC_RGB);
DoV[i] = 1 ;
}
else {
return Standard_False ;
}
// (1,0)
i++ ; X[i] = NX+1 ; Y[i] = NY ;
if ( !( X[i] < LowX || X[i] > UpX ||
Y[i] < LowY || Y[i] > UpY ) ) {
aImage->Pixel(X[i],Y[i]).Value().
Values( R[i],G[i],B[i],Quantity_TOC_RGB);
DoV[i] = 1 ;
}
else {
R[i] = R[0] ; G[i] = G[0] ; B[i] = B[0] ;
}
// (0,1)
i++ ; X[i] = NX ; Y[i] = NY+1 ;
if ( !( X[i] < LowX || X[i] > UpX ||
Y[i] < LowY || Y[i] > UpY ) ) {
aImage->Pixel(X[i],Y[i]).Value().
Values( R[i],G[i],B[i],Quantity_TOC_RGB);
DoV[i] = 1 ;
}
else {
R[i] = R[0] ; G[i] = G[0] ; B[i] = B[0] ;
}
// (1,1)
i++ ; X[i] = NX+1 ; Y[i] = NY+1 ;
if ( !( X[i] < LowX || X[i] > UpX ||
Y[i] < LowY || Y[i] > UpY ) ) {
aImage->Pixel(X[i],Y[i]).Value().
Values( R[i],G[i],B[i],Quantity_TOC_RGB);
DoV[i] = 1 ;
}
else {
R[i] = R[0] ; G[i] = G[0] ; B[i] = B[0] ;
}
// Pixel A [0] Pixel B [1]
// Pixel X
// Pixel C [2] Pixel D [3]
Standard_Boolean First ;
Standard_Integer Ref ;
Standard_Real ColDelta,RowDelta, ContribFromAB, ContribFromCD ;
ColDelta = FX - X[0] ;
RowDelta = FY - Y[0] ;
// Red Componant
for ( i = 0 , First = 1, Ref = -1, SamePixels = 1 ; i < 4 ; i++ ) {
if ( DoV[i] ) {
if ( First ) { Ref = i ; First = 0 ; }
else if ( R[i] != R[Ref] ) { SamePixels = 0 ; break ;}
}
}
if ( Ref == -1 ) {
return Standard_False ;
}
else if ( SamePixels ) {
SR = R[Ref] ;
}
else {
ContribFromAB = ColDelta * ( R[1] - R[0] ) + R[0] ;
ContribFromCD = ColDelta * ( R[3] - R[2] ) + R[2] ;
SR = ContribFromAB +
( ContribFromCD - ContribFromAB ) * RowDelta ;
}
// Green Componant
for ( i = 0 , First = 1, Ref = -1, SamePixels = 1 ; i < 4 ; i++ ) {
if ( DoV[i] ) {
if ( First ) { Ref = i ; First = 0 ; }
else if ( G[i] != G[Ref] ) { SamePixels = 0 ; break ;}
}
}
if ( Ref == -1 ) {
return Standard_False ;
}
else if ( SamePixels ) {
SG = G[Ref] ;
}
else {
ContribFromAB = ColDelta * ( G[1] - G[0] ) + G[0] ;
ContribFromCD = ColDelta * ( G[3] - G[2] ) + G[2] ;
SG = ContribFromAB +
( ContribFromCD - ContribFromAB ) * RowDelta ;
}
// Blue Componant
for ( i = 0 , First = 1, Ref = -1, SamePixels = 1 ; i < 4 ; i++ ) {
if ( DoV[i] ) {
if ( First ) { Ref = i ; First = 0 ; }
else if ( B[i] != B[Ref] ) { SamePixels = 0 ; break ;}
}
}
if ( Ref == -1 ) {
return Standard_False ;
}
else if ( SamePixels ) {
SB = B[Ref] ;
}
else {
ContribFromAB = ColDelta * ( B[1] - B[0] ) + B[0] ;
ContribFromCD = ColDelta * ( B[3] - B[2] ) + B[2] ;
SB = ContribFromAB +
( ContribFromCD - ContribFromAB ) * RowDelta ;
}
// Result
aPixel.SetValue( Quantity_Color( SR, SG, SB, Quantity_TOC_RGB ) ) ;
return Standard_True ;
}
}
Standard_Boolean Image_BalancedPixelInterpolation::Interpolate(
const Handle(Image_DIndexedImage)& aImage,
const Standard_Real FX, const Standard_Real FY,
const Standard_Integer LowX,
const Standard_Integer LowY,
const Standard_Integer UpX,
const Standard_Integer UpY,
Aspect_IndexPixel& aPixel ) const
{ Standard_Integer NX = Standard_Integer(FX) ;
Standard_Integer NY = Standard_Integer(FY) ;
Standard_Integer X[4],Y[4] ;
Standard_Integer V[4], i ;
Standard_Boolean DoV[4], SamePixels = 1 ;
Standard_Real SP ;
if ( FX < 0. ) NX-- ;
if ( FY < 0. ) NY-- ;
if ( NX < ( LowX-1 ) || NX > UpX ||
NY < ( LowY-1 ) || NY > UpY ) {
return Standard_False ;
}
else {
for ( i = 0 ; i < 4 ; i++ ) DoV[i] = 0 ;
i = 0;
// (0,0)
i = 0; X[i] = NX ; Y[i] = NY ;
if ( !( X[i] < LowX || X[i] > UpX ||
Y[i] < LowY || Y[i] > UpY ) ) {
V[i] = aImage->Pixel( X[i],Y[i] ).Value() ; DoV[i] = 1 ;
}
else {
return Standard_False ;
}
// (1,0)
i++ ; X[i] = NX+1 ; Y[i] = NY ;
if ( !( X[i] < LowX || X[i] > UpX ||
Y[i] < LowY || Y[i] > UpY ) ) {
V[i] = aImage->Pixel( X[i],Y[i] ).Value() ; DoV[i] = 1 ;
}
else {
V[i] = V[0] ;
}
// (0,1)
i++ ; X[i] = NX ; Y[i] = NY+1 ;
if ( !( X[i] < LowX || X[i] > UpX ||
Y[i] < LowY || Y[i] > UpY ) ) {
V[i] = aImage->Pixel( X[i],Y[i] ).Value() ; DoV[i] = 1 ;
}
else {
V[i] = V[0] ;
}
// (1,1)
i++ ; X[i] = NX+1 ; Y[i] = NY+1 ;
if ( !( X[i] < LowX || X[i] > UpX ||
Y[i] < LowY || Y[i] > UpY ) ) {
V[i] = aImage->Pixel( X[i],Y[i] ).Value() ; DoV[i] = 1 ;
}
else {
V[i] = V[0] ;
}
// Pixel A [0] Pixel B [1]
// Pixel X
// Pixel C [2] Pixel D [3]
Standard_Boolean First ;
Standard_Integer Ref ;
Standard_Real ColDelta,RowDelta, ContribFromAB, ContribFromCD ;
for ( i = 0 , First = 1, Ref = -1 ; i < 4 ; i++ ) {
if ( DoV[i] ) {
if ( First ) { Ref = i ; First = 0 ; }
else if ( V[i] != V[Ref] ) { SamePixels = 0 ; break ;}
}
}
if ( Ref == -1 ) {
return Standard_False ;
}
else if ( SamePixels ) {
aPixel.SetValue( V[Ref] ) ;
return Standard_True ;
}
else {
ColDelta = FX - X[0] ;
RowDelta = FY - Y[0] ;
ContribFromAB = ColDelta * ( V[1] - V[0] ) + V[0] ;
ContribFromCD = ColDelta * ( V[3] - V[2] ) + V[2] ;
SP = ContribFromAB +
( ContribFromCD - ContribFromAB ) * RowDelta ;
aPixel.SetValue( Standard_Integer(SP+0.5) ) ;
return Standard_True ;
}
}
}
#ifdef OLD
Standard_Boolean Image_BalancedPixelInterpolation::Interpolate(
const Handle(Image_DColorImage)& aImage,
const Standard_Real FX, const Standard_Real FY,
const Standard_Integer LowX,
const Standard_Integer LowY,
const Standard_Integer UpX,
const Standard_Integer UpY,
Aspect_ColorPixel& aPixel ) const
{ Standard_Integer NX = Standard_Integer(FX) ;
Standard_Integer NY = Standard_Integer(FY) ;
Standard_Integer X[4],Y[4], i ;
Standard_Real R[4], G[4], B[4];
Standard_Boolean DoV[4], SamePixels = 1 ;
Standard_Real D[4], SD, SR, SG, SB;
if ( NX < ( LowX-1 ) || NX > UpX ||
NY < ( LowY-1 ) || NY > UpY ) {
return Standard_False ;
}
else {
if ( FX < 0. ) NX-- ;
if ( FY < 0. ) NY-- ;
for ( i = 0 ; i < 4 ; i++ ) DoV[i] = 0 ;
// (0,0)
i = 0; X[i] = NX ; Y[i] = NY ;
if ( !( X[i] < LowX || X[i] > UpX ||
Y[i] < LowY || Y[i] > UpY ) ) {
aImage->Pixel(X[i],Y[i]).Value().
Values( R[i],G[i],B[i],Quantity_TOC_RGB);
DoV[i] = 1 ;
}
// (1,0)
i++ ; X[i] = NX+1 ; Y[i] = NY ;
if ( !( X[i] < LowX || X[i] > UpX ||
Y[i] < LowY || Y[i] > UpY ) ) {
aImage->Pixel(X[i],Y[i]).Value().
Values( R[i],G[i],B[i],Quantity_TOC_RGB);
DoV[i] = 1 ;
}
// (0,1)
i++ ; X[i] = NX ; Y[i] = NY+1 ;
if ( !( X[i] < LowX || X[i] > UpX ||
Y[i] < LowY || Y[i] > UpY ) ) {
aImage->Pixel(X[i],Y[i]).Value().
Values( R[i],G[i],B[i],Quantity_TOC_RGB);
DoV[i] = 1 ;
}
// (1,1)
i++ ; X[i] = NX+1 ; Y[i] = NY+1 ;
if ( !( X[i] < LowX || X[i] > UpX ||
Y[i] < LowY || Y[i] > UpY ) ) {
aImage->Pixel(X[i],Y[i]).Value().
Values( R[i],G[i],B[i],Quantity_TOC_RGB);
DoV[i] = 1 ;
}
Standard_Boolean First, DIsComputed ;
Standard_Integer Ref ;
SR = SG = SB = SD = 0. ;
DIsComputed = 0 ;
// Red Componant
for ( i = 0 , First = 1, Ref = -1, SamePixels = 1 ; i < 4 ; i++ ) {
if ( DoV[i] ) {
if ( First ) { Ref = i ; First = 0 ; }
else if ( R[i] != R[Ref] ) { SamePixels = 0 ; break ;}
}
}
if ( Ref == -1 ) {
return Standard_False ;
}
else if ( SamePixels ) {
SR = R[Ref] ;
}
else {
for ( i = 0 ; i < 4 ; i++ ) {
if ( DoV[i] ) {
D[i] = Sqrt( (X[i]-FX)*(X[i]-FX) + (Y[i]-FY)*(Y[i]-FY) );
SD += D[i] ;
SR += D[i] * R[i] ;
}
}
DIsComputed = 1 ;
if ( SD != 0. ) SR /= SD ;
else {
return Standard_False ;
}
}
// Green Componant
for ( i = 0 , First = 1, Ref = -1, SamePixels = 1 ; i < 4 ; i++ ) {
if ( DoV[i] ) {
if ( First ) { Ref = i ; First = 0 ; }
else if ( G[i] != G[Ref] ) { SamePixels = 0 ; break ;}
}
}
if ( Ref == -1 ) {
return Standard_False ;
}
else if ( SamePixels ) {
SG = G[Ref] ;
}
else {
for ( i = 0 ; i < 4 ; i++ ) {
if ( DoV[i] ) {
if ( !DIsComputed ) {
D[i] = Sqrt( (X[i]-FX)*(X[i]-FX) + (Y[i]-FY)*(Y[i]-FY) );
SD += D[i] ;
}
SG += D[i] * G[i] ;
}
}
DIsComputed = 1 ;
if ( SD != 0. ) SG /= SD ;
else {
return Standard_False ;
}
}
// Blue Componant
for ( i = 0 , First = 1, Ref = -1, SamePixels = 1 ; i < 4 ; i++ ) {
if ( DoV[i] ) {
if ( First ) { Ref = i ; First = 0 ; }
else if ( B[i] != B[Ref] ) { SamePixels = 0 ; break ;}
}
}
if ( Ref == -1 ) {
return Standard_False ;
}
else if ( SamePixels ) {
SB = B[Ref] ;
}
else {
for ( i = 0 ; i < 4 ; i++ ) {
if ( DoV[i] ) {
if ( !DIsComputed ) {
D[i] = Sqrt( (X[i]-FX)*(X[i]-FX) + (Y[i]-FY)*(Y[i]-FY) );
SD += D[i] ;
}
SB += D[i] * B[i] ;
}
}
DIsComputed = 1 ;
if ( SD != 0. ) SB /= SD ;
else {
return Standard_False ;
}
}
// Result
aPixel.SetValue( Quantity_Color( SR, SG, SB, Quantity_TOC_RGB ) ) ;
return Standard_True ;
}
}
Standard_Boolean Image_BalancedPixelInterpolation::Interpolate(
const Handle(Image_DIndexedImage)& aImage,
const Standard_Real FX, const Standard_Real FY,
const Standard_Integer LowX,
const Standard_Integer LowY,
const Standard_Integer UpX,
const Standard_Integer UpY,
Aspect_IndexPixel& aPixel ) const
{ Standard_Integer NX = Standard_Integer(FX) ;
Standard_Integer NY = Standard_Integer(FY) ;
Standard_Integer X[4],Y[4] ;
Standard_Integer V[4], i ;
Standard_Boolean DoV[4], SamePixels = 1 ;
Standard_Real D, SD, SP ;
if ( NX < ( LowX-1 ) || NX > UpX ||
NY < ( LowY-1 ) || NY > UpY ) {
return Standard_False ;
}
else {
if ( FX < 0. ) NX-- ;
if ( FY < 0. ) NY-- ;
SP = SD = 0. ;
for ( i = 0 ; i < 4 ; i++ ) DoV[i] = 0 ;
i = 0;
// (0,0)
i = 0; X[i] = NX ; Y[i] = NY ;
if ( !( X[i] < LowX || X[i] > UpX ||
Y[i] < LowY || Y[i] > UpY ) ) {
V[i] = aImage->Pixel( X[i],Y[i] ).Value() ; DoV[i] = 1 ;
}
// (1,0)
i++ ; X[i] = NX+1 ; Y[i] = NY ;
if ( !( X[i] < LowX || X[i] > UpX ||
Y[i] < LowY || Y[i] > UpY ) ) {
V[i] = aImage->Pixel( X[i],Y[i] ).Value() ; DoV[i] = 1 ;
}
// (0,1)
i++ ; X[i] = NX ; Y[i] = NY+1 ;
if ( !( X[i] < LowX || X[i] > UpX ||
Y[i] < LowY || Y[i] > UpY ) ) {
V[i] = aImage->Pixel( X[i],Y[i] ).Value() ; DoV[i] = 1 ;
}
// (1,1)
i++ ; X[i] = NX+1 ; Y[i] = NY+1 ;
if ( !( X[i] < LowX || X[i] > UpX ||
Y[i] < LowY || Y[i] > UpY ) ) {
V[i] = aImage->Pixel( X[i],Y[i] ).Value() ; DoV[i] = 1 ;
}
Standard_Boolean First ;
Standard_Integer Ref ;
for ( i = 0 , First = 1, Ref = -1 ; i < 4 ; i++ ) {
if ( DoV[i] ) {
if ( First ) { Ref = i ; First = 0 ; }
else if ( V[i] != V[Ref] ) { SamePixels = 0 ; break ;}
}
}
if ( Ref == -1 ) {
return Standard_False ;
}
else if ( SamePixels ) {
aPixel.SetValue( V[Ref] ) ;
return Standard_True ;
}
else {
for ( i = 0 ; i < 4 ; i++ ) {
if ( DoV[i] ) {
D = Sqrt( (X[i]-FX)*(X[i]-FX) + (Y[i]-FY)*(Y[i]-FY) );
SP += D * V[i] ; SD += D ;
}
}
// Result
if ( SD != 0. ) {
SP /= SD ;
aPixel.SetValue( Standard_Integer(SP+0.5) ) ;
return Standard_True ;
}
else {
return Standard_False ;
}
}
}
}
#endif

View File

@ -1,100 +0,0 @@
-- Created on: 1993-07-27
-- Created by: Jean Louis FRENKEL
-- Copyright (c) 1993-1999 Matra Datavision
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
--
-- The content of this file is subject to the Open CASCADE Technology Public
-- License Version 6.5 (the "License"). You may not use the content of this file
-- except in compliance with the License. Please obtain a copy of the License
-- at http://www.opencascade.org and read it completely before using this file.
--
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
--
-- The Original Code and all software distributed under the License is
-- distributed on an "AS IS" basis, without warranty of any kind, and the
-- Initial Developer hereby disclaims all such warranties, including without
-- limitation, any warranties of merchantability, fitness for a particular
-- purpose or non-infringement. Please see the License for the specific terms
-- and conditions governing the rights and limitations under the License.
class BilinearPixelInterpolation from Image inherits PixelInterpolation from Image
---Purpose: The class BilinearPixelInterpolation is used to compute a
-- SubPixel value on non integer Image coordinate
-- BilinearPixelInterpolation redefined a new method to compute
-- a SubPixel value .
-- The value is the bilinear interpolation of the
-- four nearest Image Pixel.
-- If V1, V2, V3, V4 is the value and (X1,Y1) , (X2,Y2),
-- (X3,Y3), (X4,Y4) the coordinates of the four nearest
-- Image Pixel then first we solve :
-- V1 = a*X1 + b*Y1 + c*X1*Y1 + d
-- V2 = a*X2 + b*Y2 + c*X2*Y2 + d
-- V3 = a*X3 + b*Y3 + c*X3*Y3 + d
-- V1 = a*X4 + b*Y4 + c*X4*Y4 + d
--
-- and V = a*FX + b*XY + c*FX*FY + d
-- is the Image SubPixel value on non integer
-- coordinate (FX,FY).
uses
Image from Image,
Pixel from Aspect,
ColorPixel from Aspect,
IndexPixel from Aspect,
DColorImage from Image,
DIndexedImage from Image
is
Create returns BilinearPixelInterpolation from Image ;
---Level: Public
---Purpose: Create a BilinearPixelInterpolation object.
Interpolate( me ; aImage : Image from Image ;
FX,FY : Real from Standard ;
LowerX,LowerY,UpperX,UpperY : Integer from Standard ;
RetPixel : in out Pixel from Aspect )
returns Boolean from Standard is redefined ;
---Level: Public
---Purpose: Redefined the method to compute SubPixel's value
-- on non integer Image coordinate.
-- LowerX,LowerY,UpperX,UpperY is the Image Min Max, it's used
-- to check if the SubPixel coordinate FX,FY is outside of
-- image.
-- Return True if Interpolation Succes.
-- Return False if the SubPixel is out from Image.
Interpolate( me ; aImage : DColorImage from Image ;
FX,FY : Real from Standard ;
LowerX,LowerY,UpperX,UpperY : Integer from Standard ;
RetPixel : in out ColorPixel from Aspect )
returns Boolean from Standard is redefined;
---Level: Public
---Purpose: Compute SubPixel's value on non integer Image coordinate for
-- DColorImage and ColorPixel.
-- LowerX,LowerY,UpperX,UpperY is the Image Min Max, it's used
-- to check if the SubPixel coordinate FX,FY is outside of
-- image.
-- Return True if Interpolation Succes.
-- Return False if the SubPixel is out from Image.
Interpolate( me ; aImage : DIndexedImage from Image ;
FX,FY : Real from Standard ;
LowerX,LowerY,UpperX,UpperY : Integer from Standard ;
RetPixel : in out IndexPixel from Aspect )
returns Boolean from Standard is redefined;
---Level: Public
---Purpose: Compute SubPixel's value on non integer Image coordinate for
-- DIndexedImage and IndexPixel.
-- LowerX,LowerY,UpperX,UpperY is the Image Min Max, it's used
-- to check if the SubPixel coordinate X,Y is outside of
-- image.
-- Return True if Interpolation Succes.
-- Return False if the SubPixel is out from Image.
end BilinearPixelInterpolation from Image;

View File

@ -1,318 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
/***********************************************************************
FONCTION :
----------
Fichier Image_BilinearPixelInterpolation.cxx :
HISTORIQUE DES MODIFICATIONS :
--------------------------------
-------- : BBL ; Creation
31-12-97 : CAL ; Retrait de la dependance avec math. Calcul developpe.
************************************************************************/
/*----------------------------------------------------------------------*/
/*
* Constantes
*/
#ifdef TRACE
static int Verbose = 0 ;
#endif
/*----------------------------------------------------------------------*/
/*
* Includes
*/
#include <Aspect.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColStd_Array2OfReal.hxx>
#include <Image_BilinearPixelInterpolation.ixx>
Image_BilinearPixelInterpolation::Image_BilinearPixelInterpolation() {}
Standard_Boolean Image_BilinearPixelInterpolation::Interpolate(
const Handle(Image_Image)& aImage,
const Standard_Real FX, const Standard_Real FY,
const Standard_Integer LowX,
const Standard_Integer LowY,
const Standard_Integer UpX,
const Standard_Integer UpY,
Aspect_Pixel& aPixel ) const
{
if ( aImage->IsKind(STANDARD_TYPE(Image_DIndexedImage))) {
return Interpolate( Handle(Image_DIndexedImage)::DownCast( aImage ),
FX,FY,LowX,LowY,UpX,UpY,(Aspect_IndexPixel &)aPixel ) ;
}
else if ( aImage->IsKind(STANDARD_TYPE(Image_DColorImage))) {
return Interpolate( Handle(Image_DColorImage)::DownCast( aImage ),
FX,FY,LowX,LowY,UpX,UpY,(Aspect_ColorPixel &)aPixel ) ;
}
else {
return Image_PixelInterpolation::Interpolate( aImage,
FX,FY,LowX,LowY,UpX,UpY,aPixel ) ;
}
}
static Standard_Real DoInterpolation( const TColStd_Array1OfReal& NXF,
const TColStd_Array1OfReal& NYF,
const TColStd_Array1OfReal& NZF,
const Standard_Real FX,
const Standard_Real FY )
{ Standard_Real Result ;
if ( NZF(1) == NZF(2) && NZF(2) == NZF(3) ) {
Result = NZF(1) ;
}
else {
Standard_Integer i;
Standard_Boolean BResult;
TColStd_Array1OfReal V(1,4), R(1,4) ;
TColStd_Array2OfReal M( 1, 4, 1, 4 ) ;
TColStd_Array2OfReal MINV( 1, 4, 1, 4 ) ;
for ( i = 1 ; i <= 4 ; i++ ) {
M(i,1) = NXF(i) ; M( i,2 ) = NYF(i) ; M( i,3 ) = NXF(i)*NYF(i) ;
M(i,4) = 1. ;
V(i) = NZF(i) ;
}
BResult = Aspect::Inverse (M, MINV);
// R = M * V ;
R (1) = M (1, 1) * V (1) + M (1, 2) * V (2)
+ M (1, 3) * V (3) + M (1, 4) * V (4);
R (2) = M (2, 1) * V (1) + M (2, 2) * V (2)
+ M (2, 3) * V (3) + M (2, 4) * V (4);
R (3) = M (3, 1) * V (1) + M (3, 2) * V (2)
+ M (3, 3) * V (3) + M (3, 4) * V (4);
R (4) = M (4, 1) * V (1) + M (4, 2) * V (2)
+ M (4, 3) * V (3) + M (4, 4) * V (4);
Result = R(1)*FX + R(2)*FY + R(3)*FX*FY + R(4) ;
}
return Result ;
}
Standard_Boolean Image_BilinearPixelInterpolation::Interpolate(
const Handle(Image_DColorImage)& aImage,
const Standard_Real FX, const Standard_Real FY,
const Standard_Integer LowX,
const Standard_Integer LowY,
const Standard_Integer UpX,
const Standard_Integer UpY,
Aspect_ColorPixel& aPixel) const
{ Standard_Integer NX = Standard_Integer(FX) ;
Standard_Integer NY = Standard_Integer(FY) ;
Standard_Integer X,Y ;
TColStd_Array1OfReal NXF(1,4), NYF(1,4), NZFR(1,4), NZFG(1,4), NZFB(1,4);
if ( NX < ( LowX-1 ) || NX > UpX ||
NY < ( LowY-1 ) || NY > UpY ) {
return Standard_False ;
}
else {
if ( FX < 0. ) NX-- ;
if ( FY < 0. ) NY-- ;
// (0,0)
X = NX ; Y = NY ;
if ( !( X < LowX || X > UpX ||
Y < LowY || Y > UpY ) ) {
NXF(1) = Standard_Real( X ) ;
NYF(1) = Standard_Real( Y ) ;
NZFR(1) = aImage->Pixel( X, Y ).Value().Red() ;
NZFG(1) = aImage->Pixel( X, Y ).Value().Green() ;
NZFB(1) = aImage->Pixel( X, Y ).Value().Blue() ;
}
else {
return Standard_False ;
}
// (1,0)
X = NX+1 ; Y = NY ;
if ( !( X < LowX || X > UpX ||
Y < LowY || Y > UpY ) ) {
NXF(2) = Standard_Real( X ) ;
NYF(2) = Standard_Real( Y ) ;
NZFR(2) = aImage->Pixel( X, Y ).Value().Red() ;
NZFG(2) = aImage->Pixel( X, Y ).Value().Green() ;
NZFB(2) = aImage->Pixel( X, Y ).Value().Blue() ;
}
else {
return Standard_False ;
}
// (0,1)
X = NX ; Y = NY+1 ;
if ( !( X < LowX || X > UpX ||
Y < LowY || Y > UpY ) ) {
NXF(3) = Standard_Real( X ) ;
NYF(3) = Standard_Real( Y ) ;
NZFR(3) = aImage->Pixel( X, Y ).Value().Red() ;
NZFG(3) = aImage->Pixel( X, Y ).Value().Green() ;
NZFB(3) = aImage->Pixel( X, Y ).Value().Blue() ;
}
else {
return Standard_False ;
}
// (1,1)
X = NX+1 ; Y = NY+1 ;
if ( !( X < LowX || X > UpX ||
Y < LowY || Y > UpY ) ) {
NXF(4) = Standard_Real( X ) ;
NYF(4) = Standard_Real( Y ) ;
NZFR(4) = aImage->Pixel( X, Y ).Value().Red() ;
NZFG(4) = aImage->Pixel( X, Y ).Value().Green() ;
NZFB(4) = aImage->Pixel( X, Y ).Value().Blue() ;
}
else {
return Standard_False ;
}
// Result
Quantity_Color Res;
Standard_Real R,G,B ;
R = DoInterpolation(NXF,NYF,NZFR,FX,FY );
G = DoInterpolation(NXF,NYF,NZFG,FX,FY );
B = DoInterpolation(NXF,NYF,NZFB,FX,FY );
// Some times we get number like -0.3412341234e-14
#ifdef TRACE
if ( Verbose )
if ( R < 0. || R > 1. || G < 0. || G > 1. || B < 0. || B > 1. ) {
cout << "\tError in BilinearPixelInterpolation " <<
R << " " << G << " " << B << endl << flush ;
}
#endif
if ( R < 0. && R > -0.000001 ) R = 0. ;
if ( G < 0. && G > -0.000001 ) G = 0. ;
if ( B < 0. && B > -0.000001 ) B = 0. ;
Res.SetValues( R,G,B, Quantity_TOC_RGB ) ;
aPixel.SetValue( Res );
return Standard_True ;
}
}
Standard_Boolean Image_BilinearPixelInterpolation::Interpolate(
const Handle(Image_DIndexedImage)& aImage,
const Standard_Real FX, const Standard_Real FY,
const Standard_Integer LowX,
const Standard_Integer LowY,
const Standard_Integer UpX,
const Standard_Integer UpY,
Aspect_IndexPixel& aPixel) const
{ Standard_Integer NX = Standard_Integer(FX) ;
Standard_Integer NY = Standard_Integer(FY) ;
Standard_Integer X,Y ;
TColStd_Array1OfReal NXF(1,4), NYF(1,4), NZF(1,4);
if ( NX < ( LowX-1 ) || NX > UpX ||
NY < ( LowY-1 ) || NY > UpY ) {
return Standard_False ;
}
else {
if ( FX < 0. ) NX-- ;
if ( FY < 0. ) NY-- ;
// (0,0)
X = NX ; Y = NY ;
if ( !( X < LowX || X > UpX ||
Y < LowY || Y > UpY ) ) {
NXF(1) = Standard_Real( X ) ;
NYF(1) = Standard_Real( Y ) ;
NZF(1) = Standard_Real( aImage->Pixel( X, Y ).Value() ) ;
}
else {
return Standard_False ;
}
// (1,0)
X = NX+1 ; Y = NY ;
if ( !( X < LowX || X > UpX ||
Y < LowY || Y > UpY ) ) {
NXF(2) = Standard_Real( X ) ;
NYF(2) = Standard_Real( Y ) ;
NZF(2) = Standard_Real( aImage->Pixel( X, Y ).Value() ) ;
}
else {
return Standard_False ;
}
// (0,1)
X = NX ; Y = NY+1 ;
if ( !( X < LowX || X > UpX ||
Y < LowY || Y > UpY ) ) {
NXF(3) = Standard_Real( X ) ;
NYF(3) = Standard_Real( Y ) ;
NZF(3) = Standard_Real( aImage->Pixel( X, Y ).Value() ) ;
}
else {
return Standard_False ;
}
// (1,1)
X = NX+1 ; Y = NY+1 ;
if ( !( X < LowX || X > UpX ||
Y < LowY || Y > UpY ) ) {
NXF(4) = Standard_Real( X ) ;
NYF(4) = Standard_Real( Y ) ;
NZF(4) = Standard_Real( aImage->Pixel( X, Y ).Value() ) ;
}
else {
return Standard_False ;
}
// Result
aPixel.SetValue( Standard_Integer(DoInterpolation(NXF,NYF,NZF,FX,FY )));
return Standard_True ;
}
}

View File

@ -1,40 +0,0 @@
-- Created on: 1996-10-03
-- Created by: Jean GAUTIER
-- Copyright (c) 1996-1999 Matra Datavision
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
--
-- The content of this file is subject to the Open CASCADE Technology Public
-- License Version 6.5 (the "License"). You may not use the content of this file
-- except in compliance with the License. Please obtain a copy of the License
-- at http://www.opencascade.org and read it completely before using this file.
--
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
--
-- The Original Code and all software distributed under the License is
-- distributed on an "AS IS" basis, without warranty of any kind, and the
-- Initial Developer hereby disclaims all such warranties, including without
-- limitation, any warranties of merchantability, fitness for a particular
-- purpose or non-infringement. Please see the License for the specific terms
-- and conditions governing the rights and limitations under the License.
@ifnotdefined ( %Image_CMPLRS_EDL) then
@set %Image_CMPLRS_EDL = "";
--@uses "Image.edl";
@if ( %Station == "sun" ) then
@endif;
@if ( %Station == "sil" ) then
@endif;
@if ( %Station == "ao1" ) then
@endif;
@if ( %Station == "hp" ) then
@endif;
--@string %CMPLRS_CXX_Options = %CMPLRS_CXX_Options " -DSTANDARD_TYPE=TYPE";
@endif;

View File

@ -1,89 +0,0 @@
-- Created on: 1993-07-27
-- Created by: Jean Louis FRENKEL
-- Copyright (c) 1993-1999 Matra Datavision
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
--
-- The content of this file is subject to the Open CASCADE Technology Public
-- License Version 6.5 (the "License"). You may not use the content of this file
-- except in compliance with the License. Please obtain a copy of the License
-- at http://www.opencascade.org and read it completely before using this file.
--
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
--
-- The Original Code and all software distributed under the License is
-- distributed on an "AS IS" basis, without warranty of any kind, and the
-- Initial Developer hereby disclaims all such warranties, including without
-- limitation, any warranties of merchantability, fitness for a particular
-- purpose or non-infringement. Please see the License for the specific terms
-- and conditions governing the rights and limitations under the License.
class ColorImage from Image inherits DColorImage from Image
---Purpose : A ColorImage is a DColorImage with specific method.
-- Each Pixel in the Image ,as a ColorPixel
-- from Aspect, can be use directly as a Color.
-- A ColorImage is also called a "true color image".
uses
Color from Quantity,
ColorPixel from Aspect,
GenericColorMap from Aspect,
Image from Image,
ColorPixelMapHasher from Image,
TypeOfImage from Image
is
Create( x,y,dx,dy : in Integer from Standard )
returns mutable ColorImage from Image;
---Level: Public
---Purpose : Create a ColorImage object.
-- The default Background Pixel is set to Black .
-- All the Image is initialised with Background Pixel
Create( x,y,dx,dy : in Integer from Standard;
BackPixel : ColorPixel from Aspect )
returns mutable ColorImage from Image;
---Level: Public
---Purpose : Create a ColorImage object and set the Background Pixel.
-- All the Image is initialised with Background Pixel
ChooseColorMap( me : immutable ; aSize : Integer from Standard )
returns GenericColorMap from Aspect ;
---Purpose : Create a GenericColorMap object with the best ColorMap
-- of a particular size to use in Dithering method .
-- The best ColorMap is defined to be the one that contains as
-- many as possible of the most frequently used colors.
Type ( me : immutable ) returns TypeOfImage from Image ;
---Level: Public
---Purpose : Returns the Image Type.
PixelColor( me : immutable ; X,Y : in Integer from Standard )
returns Color from Quantity ;
---C++: return const &
---Purpose : Returns the Pixel Color .
Dup ( me : immutable ) returns mutable Image from Image ;
---Purpose : Duplicates a Image.
-- ******************* Redefined method ***************************
-- ShallowCopy (me) returns mutable like me ;
---Level: Public
-- ---Purpose: Returns a copy at the first level of <me>. The objects
-- -- referenced are not copied. Entities copied by
-- -- ShallowCopy are equal.
-- ---C++: function call
-- DeepCopy (me) returns mutable like me ;
---Level: Public
-- ---Purpose: Returns a deep copy of <me>. The objects
-- -- referenced are copied. Entities copied by
-- -- DeepCopy are similar (c.f the Method IsSimilar).
-- ---C++: function call
end ColorImage from Image;

View File

@ -1,163 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <Image_ColorImage.ixx>
#include <Image_ColorPixelDataMap.hxx>
#include <Image_DataMapIteratorOfColorPixelDataMap.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <Quantity_Array1OfColor.hxx>
#include <Aspect_ColorMapEntry.hxx>
#ifdef TRACE
static int Verbose = 0 ;
#endif
Image_ColorImage::Image_ColorImage (
const Standard_Integer x,
const Standard_Integer y,
const Standard_Integer dx,
const Standard_Integer dy)
: Image_DColorImage( x, y, dx, dy,
Aspect_ColorPixel( Quantity_Color(0.,0.,0.,Quantity_TOC_RGB)) )
{
}
Image_ColorImage::Image_ColorImage (
const Standard_Integer x,
const Standard_Integer y,
const Standard_Integer dx,
const Standard_Integer dy,
const Aspect_ColorPixel& BackPixel )
: Image_DColorImage( x, y, dx, dy, BackPixel )
{
}
Handle(Image_Image) Image_ColorImage::Dup() const {
Handle(Image_ColorImage) aImage =
new Image_ColorImage( LowerX(), LowerY(), Width(), Height(),
BackgroundPixel() ) ;
aImage->InternalDup( this ) ;
return aImage ;
}
Image_TypeOfImage Image_ColorImage::Type () const {
return Image_TOI_ColorImage ;
}
const Quantity_Color& Image_ColorImage::PixelColor(
const Standard_Integer x,
const Standard_Integer y ) const
{ return( Pixel( x, y ).Value() ) ;
}
Handle(Aspect_GenericColorMap) Image_ColorImage::ChooseColorMap(
const Standard_Integer aSize ) const
{ Handle(Aspect_GenericColorMap) TheColorMap = new Aspect_GenericColorMap() ;
Standard_Integer x,y,i,bblcount, UpX, UpY ;
Image_ColorPixelDataMap DataMap( 4000 ) ; // a Big DataMap !!!
Aspect_ColorPixel pix ;
UpX = UpperX() ;
UpY = UpperY() ;
for ( y = LowerY() ; y <= UpY ; y++ ) {
for ( x = LowerX() ; x <= UpX ; x++ ) {
pix = Pixel(x,y) ;
if ( !DataMap.IsBound( pix ) ) DataMap.Bind( pix, 1 ) ;
else DataMap( pix )++ ;
}
}
#ifdef TRACE
Standard_Integer CheckSum = 0 ;
if ( Verbose )
cout << "ChooseColorMap : Extent " << DataMap.Extent() << endl << flush ;
#endif
Image_DataMapIteratorOfColorPixelDataMap It( DataMap ) ;
TColStd_Array1OfInteger Tab( 1, aSize ) ; Tab.Init(0) ;
Quantity_Array1OfColor Col( 1, aSize) ; Col.Init(
Quantity_Color( 0.,0.,0., Quantity_TOC_RGB ) ) ;
Standard_Integer MaxOfTab = 0 ;
Standard_Integer MinOfTab = 0 ;
while ( It.More() ) {
bblcount = It.Value() ;
#ifdef TRACE
if ( Verbose ) {
cout << CheckSum << "," << It.Key() << "," << bblcount << endl ;
CheckSum += bblcount ;
}
#endif
if ( bblcount > MinOfTab ) {
for ( i = 1 ; i <= aSize ; i++ ) {
if ( Tab( i ) == MinOfTab ) {
Tab( i ) = bblcount ;
Col( i ) = It.Key().Value() ;
break ;
}
}
for ( i = 1 ; i <= aSize ; i++ ) {
MaxOfTab = Max( MaxOfTab, Tab( i ) ) ;
MinOfTab = Min( MinOfTab, Tab( i ) ) ;
}
}
It.Next() ;
}
Aspect_ColorMapEntry aEntry ;
for ( i = 1, bblcount = 0 ; i <= aSize ; i++ ) {
if ( Tab( i ) != 0 ) {
aEntry.SetValue( bblcount++, Col( i ) ) ;
TheColorMap->AddEntry( aEntry ) ;
}
}
cout << flush ;
return TheColorMap ;
}
#ifdef OLD
Handle(Standard_Transient) Image_ColorImage::ShallowCopy() const {
return DeepCopy() ;
}
Handle(Standard_Transient) Image_ColorImage::DeepCopy() const {
return Dup() ;
}
#endif

View File

@ -1,136 +0,0 @@
-- Created on: 1993-07-28
-- Created by: Jean Louis FRENKEL
-- Copyright (c) 1993-1999 Matra Datavision
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
--
-- The content of this file is subject to the Open CASCADE Technology Public
-- License Version 6.5 (the "License"). You may not use the content of this file
-- except in compliance with the License. Please obtain a copy of the License
-- at http://www.opencascade.org and read it completely before using this file.
--
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
--
-- The Original Code and all software distributed under the License is
-- distributed on an "AS IS" basis, without warranty of any kind, and the
-- Initial Developer hereby disclaims all such warranties, including without
-- limitation, any warranties of merchantability, fitness for a particular
-- purpose or non-infringement. Please see the License for the specific terms
-- and conditions governing the rights and limitations under the License.
class Convertor from Image
---Purpose: This class is used to convert :
-- a PseudoColorImage to a ColorImage
-- a ColorImage to a PseudoColorImage
-- a PseudoColorImage to a PseudoColorImage with a
-- different ColorMap.
--
-- To convert a PseudoColoImage to a ColorImage we use
-- the PseudoColoImage ColorMap to compute the Color of each
-- Image Pixel ( Lookup operation ) , the resulting image
-- look similar as the original image.
--
-- To convert a ColorImage to a PseudoColorImage or
-- a PseudoColorImage to another PseudoColorImage we use
-- Dithering.
--
-- A dither operation is an inverse lookup operation.For
-- example if we want to dither a ColorImage to a
-- PseudoColorImage, for each Pixel in the ColorImage we search
-- in the PseudoColorImage ColorMap the Entry with the nearest
-- Color, then we write the ColorMap Entry Index in to the
-- PseudoColorImage. The result is a PseudoColorImage that when
-- it is displayed using its own ColorMap it will look as much
-- like the original ColorImage as possible.
--
-- This class provides 2 Dithering method.
--
-- DM_NearestColor : this dithering method is the simplest
-- one ,it just finds the nearest entry in the ColorMap.
-- This algorithm provide no provision for eliminating unwanted
-- contours in the dithered image.This algorithm is much
-- faster on ColorRamp and ColorCube than on Generic
-- ColorMap.Indeed on ColorRamp and ColorCube ColorMap the
-- ColorMap Entry Index can be computed by using the ColorMap
-- BasePixel and ColorDimension.
--
-- DM_ErrorDiffusion: In this method the difference ( error )
-- between the original and the dithered image is distribued
-- to the oginal image pixels immediatly to the right of and
-- below the last pixel processed. The ErrorDiffusion method
-- uses a "floyd-steinberg" error-distribution kernel.This
-- algorithm is fairly time-consuming, but can greatly reduce
-- contouring in the dithered image.
--
uses
ColorMap from Aspect,
GenericColorMap from Aspect,
ColorCubeColorMap from Aspect,
ColorRampColorMap from Aspect,
PseudoColorImage from Image,
ColorImage from Image,
DitheringMethod from Image
is
Create returns Convertor from Image;
---Level: Public
---Purpose: Create a Convertor object with the default DitheringMethod
-- ( DM_NearestColor ).
SetDitheringMethod( me : in out ;
aMethod : in DitheringMethod from Image );
---Level: Public
---Purpose: Set DitheringMethod.
Convert (me : in ;aColorImage: ColorImage from Image;
aColorMap : ColorMap from Aspect)
returns mutable PseudoColorImage from Image;
---Level: Public
---Purpose: Dither a ColorImage into a PseudoColorImage using the
-- ColorMap parameter.
Convert (me : in ; aPseudoColorImage: PseudoColorImage from Image;
aColorMap : ColorMap from Aspect)
returns mutable PseudoColorImage from Image;
---Level: Public
---Purpose: Dither a PseudoColorImage into a PseudoColorImage using the
-- ColorMap parameter.
Convert (me : in; aPseudoColorImage: PseudoColorImage from Image)
returns mutable ColorImage from Image;
---Level: Public
---Purpose: Lookup a PseudoColorImage into a ColorImage using the
-- PseudoColorImage ColorMap.
-- ******************* Private Method *******************
NearestDithering(me : in;
aColorImage: ColorImage from Image ;
aColorMap : ColorMap from Aspect)
returns mutable PseudoColorImage from Image is private ;
NearestDithering(me : in;
aPseudoColorImage : PseudoColorImage from Image ;
aColorMap : ColorMap from Aspect)
returns mutable PseudoColorImage from Image is private ;
ErrorDiffusionDithering(me : in;
aColorImage : ColorImage from Image ;
aColorMap : ColorMap from Aspect)
returns mutable PseudoColorImage from Image is private ;
ErrorDiffusionDithering(me : in;
aPseudoColorImage : PseudoColorImage from Image ;
aColorMap : ColorMap from Aspect)
returns mutable PseudoColorImage from Image is private ;
fields
myDitheringMethod : DitheringMethod from Image ;
end Convertor;

View File

@ -1,402 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <Image_Convertor.ixx>
#include <Image_PseudoColorImage.hxx>
#include <Image_ColorImage.hxx>
#include <Image_LookupTable.hxx>
#include <Aspect_ColorMapEntry.hxx>
#ifdef TRACE
static int Verbose = 0 ;
#endif
Image_Convertor::Image_Convertor() { myDitheringMethod = Image_DM_NearestColor;}
void Image_Convertor::SetDitheringMethod( const Image_DitheringMethod Method )
{ myDitheringMethod = Method ; }
Handle(Image_PseudoColorImage) Image_Convertor::Convert(
const Handle(Image_ColorImage)& aImage,
const Handle(Aspect_ColorMap)& aColorMap ) const
{ Handle(Image_PseudoColorImage) ret_image = NULL ;
if ( myDitheringMethod == Image_DM_NearestColor ) {
ret_image = NearestDithering( aImage, aColorMap ) ;
}
else if ( myDitheringMethod == Image_DM_ErrorDiffusion ) {
ret_image = ErrorDiffusionDithering( aImage, aColorMap ) ;
}
return ret_image ;
}
Handle(Image_PseudoColorImage) Image_Convertor::Convert(
const Handle(Image_PseudoColorImage)& aImage,
const Handle(Aspect_ColorMap)& aColorMap ) const
{ Handle(Image_PseudoColorImage) ret_image = NULL ;
if ( myDitheringMethod == Image_DM_NearestColor ) {
ret_image = NearestDithering( aImage, aColorMap ) ;
}
else if ( myDitheringMethod == Image_DM_ErrorDiffusion ) {
ret_image = ErrorDiffusionDithering( aImage, aColorMap ) ;
}
return ret_image ;
}
Handle(Image_ColorImage) Image_Convertor::Convert(
const Handle(Image_PseudoColorImage)& aImage ) const
{ Handle(Image_ColorImage) ret_image = NULL ;
Standard_Integer x, y, val, lastval ;
Quantity_Color aColor ;
Standard_Integer UpX = aImage->UpperX() ;
Standard_Integer UpY = aImage->UpperY() ;
ret_image = new Image_ColorImage( aImage->LowerX(), aImage->LowerY(),
aImage->Width() , aImage->Height() ) ;
lastval = aImage->Pixel(aImage->LowerX(), aImage->LowerY() ).Value() ;
aColor = aImage->ColorMap()->FindEntry(lastval).Color() ;
for ( y = aImage->LowerY() ; y <= UpY ; y++ ) {
for ( x = aImage->LowerX() ; x <= UpX ; x++ ) {
val = aImage->Pixel(x,y).Value() ;
if ( lastval != val ) {
lastval = val ;
aColor = aImage->ColorMap()->FindEntry(lastval).Color() ;
}
ret_image->SetPixel( x, y, aColor );
}
}
return( ret_image ) ;
}
Handle(Image_PseudoColorImage) Image_Convertor::NearestDithering(
const Handle(Image_ColorImage)& aImage,
const Handle(Aspect_ColorMap)& aColorMap ) const
{ Handle(Image_PseudoColorImage) ret_image = NULL ;
Standard_Integer x, y, index ;
Quantity_Color lastval, val ;
Standard_Integer UpX = aImage->UpperX() ;
Standard_Integer UpY = aImage->UpperY() ;
ret_image = new Image_PseudoColorImage( aImage->LowerX(), aImage->LowerY(),
aImage->Width() , aImage->Height(),
aColorMap );
lastval = aImage->PixelColor(aImage->LowerX(),aImage->LowerY()) ;
index = aColorMap->NearestEntry( lastval ).Index() ;
for ( y = aImage->LowerY() ; y <= UpY ; y++ ) {
for ( x = aImage->LowerX() ; x <= UpX ; x++ ) {
val = aImage->PixelColor(x,y) ;
if ( !( val == lastval ) ) {
lastval = val ;
index = aColorMap->NearestEntry( lastval ).Index() ;
}
ret_image->SetPixel( x, y, index ) ;
}
}
return( ret_image ) ;
}
Handle(Image_PseudoColorImage) Image_Convertor::NearestDithering(
const Handle(Image_PseudoColorImage)& aImage,
const Handle(Aspect_ColorMap)& aColorMap ) const
{ Handle(Image_PseudoColorImage) ret_image = NULL ;
Standard_Integer x,y, val, lastval, index ;
Standard_Integer UpX = aImage->UpperX() ;
Standard_Integer UpY = aImage->UpperY() ;
Image_LookupTable ColorMapLookup ;
Aspect_ColorMapEntry aEntry ;
Standard_Integer i, size ;
for ( i = 1 , size = aImage->ColorMap()->Size() ; i <= size ; i++ ) {
aEntry = aImage->ColorMap()->Entry(i) ;
index = aColorMap->NearestEntry( aEntry.Color() ).Index() ;
ColorMapLookup.Bind( aEntry.Index(), index ) ;
}
ret_image = new Image_PseudoColorImage( aImage->LowerX(), aImage->LowerY(),
aImage->Width() , aImage->Height(),
aColorMap );
lastval = aImage->Pixel( aImage->LowerX(), aImage->LowerY() ).Value() ;
index = ColorMapLookup.Find( lastval ).Value() ;
for ( y = aImage->LowerY() ; y <= UpY ; y++ ) {
for ( x = aImage->LowerX() ; x <= UpX ; x++ ) {
val = aImage->Pixel(x,y).Value() ;
if ( val != lastval ) {
lastval = val ;
index = ColorMapLookup.Find( lastval ).Value() ;
}
ret_image->SetPixel( x, y, index ) ;
}
}
return( ret_image ) ;
}
static Standard_Boolean ManageLastKernelError = 1 ;
static struct {
Standard_Real v ;
Standard_Integer dx, dy ;
} Kernel[4] = { { 7./16., 1, 0 },
{ 3./16., -1, 1 },
{ 5./16., 0, 1 },
{ 1./16., 1, 1 } } ;
Handle(Image_PseudoColorImage) Image_Convertor::ErrorDiffusionDithering(
const Handle(Image_PseudoColorImage)& RefImage,
const Handle(Aspect_ColorMap)& aColorMap ) const
{ Handle(Image_PseudoColorImage) ret_image = NULL ;
Standard_Integer UpX = RefImage->UpperX() ;
Standard_Integer UpY = RefImage->UpperY() ;
Standard_Integer LowX = RefImage->LowerX() ;
Standard_Integer LowY = RefImage->LowerY() ;
Standard_Integer x,y, index, i, nx,ny ;
Standard_Integer val, lastval ;
Standard_Integer Error, ErrorDiff, pix, npix, MinIndex, MaxIndex ;
Aspect_IndexPixel aPixel ;
Image_LookupTable ColorMapLookup ;
Aspect_ColorMapEntry aEntry ;
Standard_Integer size ;
MaxIndex = MinIndex = RefImage->ColorMap()->Entry(1).Index() ;
for ( i = 1 , size = RefImage->ColorMap()->Size() ; i <= size ; i++ ) {
aEntry = RefImage->ColorMap()->Entry(i) ;
MinIndex = Min( aEntry.Index(), MinIndex ) ;
MaxIndex = Max( aEntry.Index(), MaxIndex ) ;
index = aColorMap->NearestEntry( aEntry.Color() ).Index() ;
ColorMapLookup.Bind( aEntry.Index(), index ) ;
}
Handle(Image_PseudoColorImage) aImage =
Handle(Image_PseudoColorImage)::DownCast( RefImage->Dup() ) ;
ret_image = new Image_PseudoColorImage( aImage->LowerX(), aImage->LowerY(),
aImage->Width() , aImage->Height(),
aColorMap );
lastval = aImage->Pixel( aImage->LowerX(), aImage->LowerY() ).Value() ;
index = ColorMapLookup.Find( lastval ).Value() ;
for ( y = aImage->LowerY() ; y <= UpY ; y++ ) {
for ( x = aImage->LowerX() ; x <= UpX ; x++ ) {
val = aImage->Pixel(x,y).Value() ;
if ( ! ( val == lastval ) ) {
lastval = val ;
index = ColorMapLookup.Find( lastval ).Value() ;
}
ErrorDiff = Error = val - index ;
#ifdef TRACE
if ( Verbose > 3 )
cout << "ErrorDiffusion : " << Error << endl << flush ;
#endif
if ( Error != 0 ) {
for ( i = 0 ; i < 4 ; i++ ) {
nx = x+Kernel[i].dx ;
ny = y+Kernel[i].dy ;
if ( nx >= LowX && nx <= UpX &&
ny >= LowY && ny <= UpY ) {
aImage->Pixel( nx, ny, aPixel ) ;
pix = aPixel.Value() ;
if ( ManageLastKernelError && i == 3 ) {
// Last one
npix = pix + ErrorDiff ;
}
else {
npix = pix + Standard_Integer( Kernel[i].v * Error ) ;
}
// ErrorDiffusion may produce Pixel out of ColorMap
// Clamp value to min max of ColorMap
npix = Max( npix, MinIndex ) ;
npix = Min( npix, MaxIndex ) ;
ErrorDiff -= ( npix - pix ) ;
#ifdef TRACE
if ( Verbose > 2 && i == 3 ) {
cout << "ErrorDiffusion Last Error: " <<
(ErrorDiff-( Kernel[i].v*Error)) <<endl<<flush ;
}
#endif
aPixel.SetValue( npix ) ;
aImage->SetPixel( nx, ny, aPixel ) ;
}
}
}
ret_image->SetPixel( x, y, index ) ;
}
}
return( ret_image ) ;
}
Handle(Image_PseudoColorImage) Image_Convertor::ErrorDiffusionDithering(
const Handle(Image_ColorImage)& RefImage,
const Handle(Aspect_ColorMap)& aColorMap ) const
{ Handle(Image_PseudoColorImage) ret_image = NULL ;
Standard_Integer UpX = RefImage->UpperX() ;
Standard_Integer UpY = RefImage->UpperY() ;
Standard_Integer LowX = RefImage->LowerX() ;
Standard_Integer LowY = RefImage->LowerY() ;
Standard_Integer x,y, index, i, nx,ny ;
Quantity_Color val, lastval, NewCol ;
Aspect_ColorMapEntry aEntry ;
Aspect_ColorPixel aPixel ;
Standard_Real RedError, GreenError, BlueError, r,g,b,cr,cg,cb ;
Standard_Real RedDiffError, GreenDiffError, BlueDiffError ;
Handle(Image_ColorImage) aImage =
Handle(Image_ColorImage)::DownCast( RefImage->Dup() ) ;
ret_image = new Image_PseudoColorImage( aImage->LowerX(), aImage->LowerY(),
aImage->Width() , aImage->Height(),
aColorMap );
lastval = aImage->PixelColor( aImage->LowerX(), aImage->LowerY() ) ;
aEntry = aColorMap->NearestEntry( lastval ) ;
index = aEntry.Index() ;
for ( y = aImage->LowerY() ; y <= UpY ; y++ ) {
for ( x = aImage->LowerX() ; x <= UpX ; x++ ) {
val = aImage->PixelColor(x,y) ;
if ( ! ( val == lastval ) ) {
lastval = val ;
aEntry = aColorMap->NearestEntry( lastval ) ;
index = aEntry.Index() ;
}
RedDiffError = RedError = val.Red() - aEntry.Color().Red() ;
GreenDiffError = GreenError = val.Green() - aEntry.Color().Green() ;
BlueDiffError = BlueError = val.Blue() - aEntry.Color().Blue() ;
#ifdef TRACE
if ( Verbose > 3 )
cout << "ErrorDiffusion : " << RedError << "," <<
GreenError << "," <<
BlueError << "," << endl << flush ;
#endif
if ( RedError != 0. && GreenError != 0. && BlueError != 0. ) {
for ( i = 0 ; i < 4 ; i++ ) {
nx = x+Kernel[i].dx ;
ny = y+Kernel[i].dy ;
if ( nx >= LowX && nx <= UpX &&
ny >= LowY && ny <= UpY ) {
aImage->Pixel( nx, ny, aPixel ) ;
aPixel.Value().Values( r,g,b, Quantity_TOC_RGB ) ;
if ( ManageLastKernelError && i == 3 ) {
// Last one
cr = r + RedDiffError ;
cg = g + GreenDiffError ;
cb = b + BlueDiffError ;
}
else {
cr = r + ( Kernel[i].v * RedError ) ;
cg = g + ( Kernel[i].v * GreenError ) ;
cb = b + ( Kernel[i].v * BlueError ) ;
}
// ErrorDiffusion may produce Pixel out of ColorMap
// Clamp Color
cr = Max( cr, 0. ) ; cr = Min( cr, 1. ) ;
cg = Max( cg, 0. ) ; cg = Min( cg, 1. ) ;
cb = Max( cb, 0. ) ; cb = Min( cb, 1. ) ;
RedDiffError -= ( cr - r ) ;
GreenDiffError -= ( cg - g ) ;
BlueDiffError -= ( cb - b ) ;
#ifdef TRACE
if ( Verbose > 2 && i == 3 ) {
cout << "ErrorDiffusion Last Error: " <<
RedDiffError << "," <<
GreenDiffError << "," <<
BlueDiffError << "," << endl << flush ;
}
#endif
NewCol.SetValues( cr,cg,cb, Quantity_TOC_RGB ) ;
aPixel.SetValue( NewCol ) ;
aImage->SetPixel( nx, ny, aPixel ) ;
}
}
}
ret_image->SetPixel( x, y, index ) ;
}
}
return( ret_image ) ;
}

View File

@ -1,355 +0,0 @@
-- Created on: 1993-07-27
-- Created by: Jean Louis FRENKEL
-- Copyright (c) 1993-1999 Matra Datavision
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
--
-- The content of this file is subject to the Open CASCADE Technology Public
-- License Version 6.5 (the "License"). You may not use the content of this file
-- except in compliance with the License. Please obtain a copy of the License
-- at http://www.opencascade.org and read it completely before using this file.
--
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
--
-- The Original Code and all software distributed under the License is
-- distributed on an "AS IS" basis, without warranty of any kind, and the
-- Initial Developer hereby disclaims all such warranties, including without
-- limitation, any warranties of merchantability, fitness for a particular
-- purpose or non-infringement. Please see the License for the specific terms
-- and conditions governing the rights and limitations under the License.
deferred generic class GImage from Image (anyPixel as Pixel from Aspect)
inherits Image from Image
---Purpose: Provide genmeric Image method independent from Pixel type.
uses
Pixel from Aspect,
PixelInterpolation from Image,
PixelAddress from Image,
FlipType from Image,
TypeOfImage from Image,
PlaneAngle from Quantity,
Trsf from gp,
GTrsf2d from gp
class PixelRow instantiates Array1 from TCollection (anyPixel);
---Level: Public
---Purpose: Manipulates PixelRow.
class PixelField instantiates GPixelField from Image (anyPixel);
---Level: Public
---Purpose: Resizable Image PixelField.
is
Initialize( x,y,dx,dy : in Integer from Standard ;
BackPixel : in anyPixel ) ;
---Level: Public
---Purpose: GImage constructor ,initialise Image origin, create Image
-- PixelField .
Destroy (me : mutable )
---Level: Public
---Purpose: Frees the allocated area corresponding to the
-- PixelField.
--
---C++: alias ~
is redefined;
SetBackgroundPixel( me : mutable ; aPixel: in anyPixel ) ;
---Level: Public
---Purpose: Sets the Image BackgroundPixel.
BackgroundPixel ( me : immutable ) returns anyPixel ;
---C++: return const &
---Level: Public
---Purpose: Return the Image BackgroundPixel.
Pixel ( me : immutable ; X,Y : in Integer from Standard )
returns anyPixel ;
---C++: return const &
---C++: alias operator()
---Level: Public
---Purpose: Return the Image Pixel Value at X,Y coordinate.
-- The returned Pixel is ReadOnly .
SetPixel( me : mutable ; X,Y : in Integer from Standard ;
aPixel: in anyPixel ) ;
---Level: Public
---Purpose: Sets the Image Pixel at X,Y coordinate with aPixel.
MutPixel ( me : mutable ; X,Y : in Integer from Standard )
returns anyPixel ;
---C++: return &
---C++: alias operator()
---Level: Public
---Purpose: Return the Image Pixel Value at X,Y coordinate.
-- The returned Pixel is ReadWrite .
SetRow ( me : mutable ; X,Y : in Integer from Standard ;
aRow: in PixelRow from Image);
---Level: Public
---Purpose: Sets an Image PixelRow starting at X,Y coordinate with aRow.
Row ( me : immutable ; X,Y : in Integer from Standard ;
aRow: in out PixelRow from Image);
---Level: Public
---Purpose: Get an Image PixelRow starting at X,Y coordinate in aRow.
SwapRow ( me : mutable ; I,J : Integer from Standard);
---Level: Public
---Purpose: Swap row.
SwapCol ( me : mutable ; I,J : Integer from Standard);
---Level: Public
---Purpose: Swap columns.
Zoom ( me : mutable ;
anInterpolation : PixelInterpolation from Image;
aCoefX,aCoefY : in Real from Standard ) ;
---Level: Public
---Purpose: Zoom an Image with a specific PixelInterpolation method.
-- Warning: image size change after a Zoom.
Rotate ( me : mutable ;
anInterpolation : PixelInterpolation from Image;
aAngle : in PlaneAngle from Quantity ) ;
---Level: Public
---Purpose: Rotate an Image with a specific PixelInterpolation method.
Translate( me : mutable ;
anInterpolation : PixelInterpolation from Image;
DX, DY : in Real from Standard ) ;
---Level: Public
---Purpose: Translate an Image with a specific PixelInterpolation method.
Affine( me : mutable ;
anInterpolation : PixelInterpolation from Image;
Trsf : in GTrsf2d from gp ) ;
---Level: Public
---Purpose : General transformation of an Image with the default
-- PixelInterpolation method.
-- Warning:
-- Raised an exception if the matrix of the transformation
-- is not inversible.
Affine( me : mutable ;
anInterpolation : PixelInterpolation from Image;
Trsf : in Trsf from gp ) ;
---Level: Public
---Purpose : General transformation of an Image with the default
-- PixelInterpolation method.
-- Warning:
-- Raised an exception if the matrix of the transformation
-- is not inversible.
InternalDup( me : mutable ; anImage : immutable like me )
is redefined ;
---Level: Public
---Purpose : Duplicate an Image.
-- ******************* Deferred method from Image *******************
SetOrigin ( me : mutable ; x,y : in Integer from Standard ) ;
---Level: Public
---Purpose: Sets Image origin, for Rotation, copy between image ...
-- Image origin is on the TOP LEFT . Y axis goes TOP to
-- DOWN , X axis goes LEFT to RIGHT.
LowerX ( me : immutable ) returns Integer from Standard ;
---Level: Public
---Purpose: Return the lower X Image coordinate ( X Origin ).
UpperX ( me : immutable ) returns Integer from Standard ;
---Level: Public
---Purpose: Return the upper X Image coordinate
-- ( X Origin + Image width - 1 ).
Width ( me : immutable ) returns Integer from Standard ;
---Level: Public
---Purpose: Return the Image width.
LowerY ( me : immutable ) returns Integer from Standard ;
---Level: Public
---Purpose: Return the lower Y Image coordinate ( Y Origin ).
UpperY ( me : immutable ) returns Integer from Standard ;
---Level: Public
---Purpose: Return the upper Y Image coordinate
-- ( Y Origin + Image height - 1 ).
Height ( me : immutable ) returns Integer from Standard ;
---Level: Public
---Purpose: Return the Image height.
Resize( me : mutable ;
XOffset,XScale, YOffset,YScale : Real from Standard ) ;
---Level: Public
---Purpose: Resize an Image. Image Pixel are left unchanged at there
-- absolute positon. Resulting Image can be clipped.
-- newLowerX = LowerX()*XScale + XOffset
-- newLowerY = LowerY()*YScale + YOffset
-- newUpperX = UpperX()*XScale + XOffset
-- newUpperY = UpperY()*YScale + YOffset
-- newWidth = Width() *XScale
-- newHeight = Height()*YScale
Type ( me : immutable ) returns TypeOfImage from Image is deferred ;
---Level: Public
---Purpose: Return the ImageType TOI_ColorImage or TOI_PseudoColorImage
isSamePixel( me : immutable ;
X,Y : in Integer from Standard ;
anotherImage : immutable like me ;
anotherX,anotherY : in Integer from Standard )
returns Boolean from Standard ;
---Level: Public
---Purpose: Returns True if me->Pixel(X,Y) is equal to
-- anotherImage->Pixel(anotherX,anotherY)
Pixel ( me : immutable ; X,Y : in Integer from Standard ;
aPixel : in out Pixel from Aspect ) ;
---Level: Public
---Purpose: Store the Image Pixel Value at X,Y coordinate in aPixel.
-- Warning: aPixel must have the same type than Image Pixel.
SetPixel( me : mutable ; X,Y : in Integer from Standard ;
aPixel : in Pixel from Aspect ) ;
---Level: Public
---Purpose: Store aPixel in the Image at X,Y coordinate .
-- Warning: aPixel must have the same type than Image Pixel.
Pixel ( me : immutable ; X,Y : in Integer from Standard ;
aPixel : in out PixelAddress from Image ) ;
---Level: Public
---Purpose: Store the Image Pixel Value at X,Y coordinate in aPixel.
-- Warning: aPixel must have the same type than Image Pixel.
SetPixel( me : mutable ; X,Y : in Integer from Standard ;
aPixel : in PixelAddress from Image ) ;
---Level: Public
---Purpose: Store aPixel in the Image at X,Y coordinate .
-- Warning: aPixel must have the same type than Image Pixel.
Transpose( me : mutable ; aType : in FlipType from Image ) ;
---Level: Public
---Purpose: Transpose an Image( flipping across horizontal axis or
-- vertical axis, or acroos diagonal... )
-- This geometric transformation preserve all Image Pixels.
-- We don't need to interpolate pixel .
-- Warning : Image size change durring Transpose.
Clip ( me : mutable ; X,Y,Width,Height:in Integer from Standard);
---Level: Public
---Purpose: Extract a SubImage starting at coordinate X,Y
-- to (X+Width-1),(Y+Height-1).
-- Warning : the Image size and origin change, new origine
-- is X,Y ; new size is Width,Height.
Shift ( me : mutable ; XShifth,YShift :in Integer from Standard);
---Level: Public
---Purpose: Translate an Image XShifth pixel Right, YShift Down .
-- Shift parameter are Integer value.
Fill ( me : mutable ; SrcImage : immutable like me ) ;
---Level: Public
---Purpose: Fill me with SrcImage. SrcImage pixel are copied starting
-- at SrcImage->LowerX(),SrcImage->LowerY() in MyPixelField.
-- SrcImage Pixel are clipped outside <me>.
Fill ( me : mutable ; SrcImage : immutable like me ;
SrcX, SrcY, SrcWidth, SrcHeight,
X, Y : in Integer from Standard ) ;
---Level: Public
---Purpose: Fill me with a SubImage of SrcImage starting from
-- SrcX, SrcY to (SrcX+SrcWidth-1),(SrcY+SrcHeight-1) in
-- Src Image coordinate. SrcImage SubImage pixels are copied
-- starting at X,Y in MyPixelField.
-- SrcImage Pixel are clipped outside <me>.
FillRect ( me : mutable ; aPixel : anyPixel ;
X, Y, Width, Height : in Integer from Standard) ;
---Level: Public
---Purpose: Fill a Rectangle in me with a Pixel
-- starting at X,Y to (X+Width-1,Y+Height-1) .
DrawRect ( me : mutable ; aPixel : anyPixel ;
X, Y, Width, Height : in Integer from Standard) ;
---Level: Public
---Purpose: draw a Rectangle in me with a Pixel
-- starting at X,Y to (X+Width-1,Y+Height-1) .
DrawLine ( me : mutable ; aPixel : anyPixel ;
X1, Y1, X2, Y2 : in Integer from Standard) ;
---Level: Public
---Purpose: draw a line in me with a Pixel
-- starting at X1,Y1 to X2,Y2 .
--DrawCircle ( me : mutable ; aPixel : anyPixel ;
--X, Y, R : in Integer from Standard) ;
-- ---Level: Public
-- ---Purpose: draw a circle in me with a Pixel
Clear ( me : mutable ) ;
---Level: Public
---Purpose: Fill the entire Image with the BackgroundPixel.
Dump ( me : immutable ) ;
---Level: Public
---Purpose: Debug
-- ******************* Redefined method ***************************
-- ShallowCopy (me) returns mutable like me is redefined deferred ;
---Level: Public
-- ---Purpose: Returns a copy at the first level of <me>. The objects
-- -- referenced are not copied. Entities copied by
-- -- ShallowCopy are equal.
-- ---C++: function call
-- DeepCopy (me) returns mutable like me is redefined deferred ;
---Level: Public
-- ---Purpose: Returns a deep copy of <me>. The objects
-- -- referenced are copied. Entities copied by
-- -- DeepCopy are similar (c.f the Method IsSimilar).
-- ---C++: function call
-- ******************* Private Method *******************
FlipHorizontal ( me : mutable ) is private ;
FlipVertical ( me : mutable ) is private ;
FlipMainDiagonal( me : mutable ) is private ;
FlipAntiDiagonal( me : mutable ) is private ;
Rotate90 ( me : mutable ) is private ;
Rotate180 ( me : mutable ) is private ;
Rotate270 ( me : mutable ) is private ;
PixelField ( me : immutable )
returns PixelField from Image is private ;
---C++: return const &
PixelFieldCopyTo( me : immutable ;
Dst : in out PixelField from Image ;
LowR,LowC,UpR,UpC,
DstLowR, DstLowC :in Integer from Standard) is private;
PixelFieldCopyFrom( me : mutable ;
Dst : PixelField from Image ;
LowR,LowC,UpR,UpC,
DstLowR, DstLowC :in Integer from Standard) is private;
PixelFieldDestroy( me : mutable ) is private ;
CirclePixels( me : mutable ;
Pixel : anyPixel ;
XCenter, YCenter, x,y : Integer from Standard ;
LowX,LowY,UpX,UpY : Integer from Standard ) is private ;
fields
myX,myY : Integer from Standard ;
myPixelField : Address from Standard ;
myBackgroundPixel : anyPixel;
end GImage from Image;

File diff suppressed because it is too large Load Diff

View File

@ -1,132 +0,0 @@
-- Created on: 1993-12-09
-- Created by: Bertand Lesecq
-- Copyright (c) 1993-1999 Matra Datavision
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
--
-- The content of this file is subject to the Open CASCADE Technology Public
-- License Version 6.5 (the "License"). You may not use the content of this file
-- except in compliance with the License. Please obtain a copy of the License
-- at http://www.opencascade.org and read it completely before using this file.
--
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
--
-- The Original Code and all software distributed under the License is
-- distributed on an "AS IS" basis, without warranty of any kind, and the
-- Initial Developer hereby disclaims all such warranties, including without
-- limitation, any warranties of merchantability, fitness for a particular
-- purpose or non-infringement. Please see the License for the specific terms
-- and conditions governing the rights and limitations under the License.
private generic class GPixelField from Image (Item as any)
---Purpose: The class GPixelField represents bi-dimensionnal arrays
-- The range of the index start from 0 .
raises
RangeError from Standard,
OutOfRange from Standard,
OutOfMemory from Standard,
DimensionMismatch from Standard
is
Create (Width, Height: Integer from Standard)
returns GPixelField from Image
---Level: Public
---Purpose: Creates an array of lower bound <0><0> and upper
-- bound <Width-1><Height-1>. Range from Standard error is
-- raised when <Width-1> is less than <0> or <Height-1> is less
-- than <0>.
raises
RangeError from Standard,
OutOfMemory from Standard;
Create (Width, Height: Integer from Standard; V : Item)
returns GPixelField from Image
---Level: Public
---Purpose: Creates an array of lower bound <0><0> and upper
-- bound <Width-1><Height-1>. Range from Standard error is
-- raised when <Width-1> is less than <0> or <Height-1> is less
-- than <0>. The array is initialized with <V>.
raises
RangeError from Standard,
OutOfMemory from Standard;
Destroy (me : in out )
---Level: Public
---Purpose: Frees the allocated area corresponding to the
-- array. If the array was constructed from a
-- DoubleArray the Destroy doesn't delete the area.
--
---C++: alias ~
is static;
Width (me) returns Integer from Standard
---Level: Public
---Purpose: Return the number of columns of <me>.
--
---C++: inline
is static ;
Height (me) returns Integer from Standard
---Level: Public
---Purpose: Returns the number of rows of <me>.
--
---C++: inline
is static;
UpperX (me) returns Integer from Standard
---Level: Public
---Purpose: Returns the upper column number of the array.
--
---C++: inline
is static ;
UpperY (me) returns Integer from Standard
---Level: Public
---Purpose: Returns the upper row number of the array.
--
---C++: inline
is static ;
SetValue (me : in out; X, Y: Integer from Standard; Value: Item)
---Level: Public
---Purpose: Sets the element of index <X><Y>
-- to <Value>.
---C++: inline
raises OutOfRange from Standard
is static ;
Value (me; X,Y: Integer from Standard) returns any Item
---Level: Public
---Purpose: Returns the value of the element of index
-- <X><Y>
--
---C++: inline
---C++: alias operator()
---C++: return const &
raises OutOfRange from Standard
is static;
ChangeValue (me: in out; X,Y: Integer from Standard) returns any Item
---Level: Public
---Purpose: Returns the value of the element of index
-- <X><Y>
--
---C++: inline
---C++: alias operator()
---C++: return &
raises OutOfRange from Standard
is static;
fields
myWidth : Integer from Standard ;
myHeight : Integer from Standard ;
myDeletable : Boolean;
myData : Address;
end GPixelField ;

View File

@ -1,97 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <Standard_OutOfRange.hxx>
#include <Standard_DimensionMismatch.hxx>
#include <Standard_RangeError.hxx>
#include <Standard_OutOfMemory.hxx>
#ifdef TRACE
static int GPixelFieldCount = 0 ;
#endif
//=======================================================================
//function : Image_GPixelField
//purpose :
//=======================================================================
Image_GPixelField::Image_GPixelField (const Standard_Integer Width,
const Standard_Integer Height) :
myWidth(Width),
myHeight(Height),
myDeletable(Standard_True)
{
Standard_Integer Size = myWidth * myHeight;
Standard_RangeError_Raise_if(( myWidth <= 0 || myHeight <= 0 ),
"Image_GPixelField::Create");
#ifdef TRACE
cout << form("\tCreate a new GPixelField ( Count : %d )\n",++GPixelFieldCount)
<< flush ;
#endif
myData = new Item [Size];
}
//=======================================================================
//function : Image_GPixelField
//purpose :
//=======================================================================
Image_GPixelField::Image_GPixelField (const Standard_Integer Width,
const Standard_Integer Height,
const Item& V) :
myWidth(Width),
myHeight(Height),
myDeletable(Standard_True)
{
Standard_Integer Size = myWidth * myHeight;
Standard_RangeError_Raise_if(( myWidth <= 0 || myHeight <= 0 ),
"Image_GPixelField::Create");
#ifdef TRACE
cout << form("\tCreate a new GPixelField ( Count : %d )\n",++GPixelFieldCount)
<< flush ;
#endif
myData = new Item [Size];
for (Standard_Integer I = 0; I < Size ; I++) ((Item *)myData)[I] = V;
}
//=======================================================================
//function : Destroy
//purpose :
//=======================================================================
void Image_GPixelField::Destroy ()
{
#ifdef TRACE
cout << form("\t\tDelete a GPixelField ( Count : %d )\n", --GPixelFieldCount )
<< flush ;
#endif
if(myDeletable) {
delete [] (Item *) myData;
}
}

View File

@ -1,88 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <Standard_DimensionMismatch.hxx>
#include <Standard_OutOfRange.hxx>
#include Item_hxx
#include <stdio.h>
# ifdef WNT
# include <InterfaceGraphic_wntio.hxx>
# endif // WNT
//static char *ErrorMessag, LocalMessag[255];
static char LocalMessag[255];
inline Standard_Integer Image_GPixelField::Width() const { return myWidth; }
inline Standard_Integer Image_GPixelField::Height() const { return myHeight; }
inline Standard_Integer Image_GPixelField::UpperX() const { return myWidth-1; }
inline Standard_Integer Image_GPixelField::UpperY() const { return myHeight-1; }
//=======================================================================
//function : SetValue
//purpose :
//=======================================================================
inline void Image_GPixelField::SetValue ( const Standard_Integer X,
const Standard_Integer Y,
const Item& Value )
{
if (X < 0 || X > (myWidth -1) || Y < 0 || Y > (myHeight -1)) {
sprintf(LocalMessag,
"Index out of range in PixelField::SetValue(%d,%d)",X,Y);
Standard_OutOfRange::Raise (LocalMessag);
}
((Item *)myData)[(Y)*(myWidth)+X] = Value ;
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
inline const Item& Image_GPixelField::Value(const Standard_Integer X,
const Standard_Integer Y) const
{
if (X < 0 || X > (myWidth -1) || Y < 0 || Y > (myHeight -1)) {
sprintf(LocalMessag,
"Index out of range in PixelField::Value(%d,%d)",X,Y);
Standard_OutOfRange::Raise (LocalMessag);
}
return ((Item *)myData)[(Y)*(myWidth)+X] ;
}
//=======================================================================
//function : ChangeValue
//purpose :
//=======================================================================
inline Item& Image_GPixelField::ChangeValue(const Standard_Integer X,
const Standard_Integer Y)
{
if ((X < 0 || X > (myWidth -1) || Y < 0 || Y > (myHeight -1))) {
sprintf(LocalMessag,
"Index out of range in PixelField::ChangeValue(%d,%d)",X,Y);
Standard_OutOfRange::Raise (LocalMessag);
}
return ((Item *)myData)[(Y)*(myWidth)+X] ;
}

View File

@ -1,217 +0,0 @@
-- Created on: 1993-07-27
-- Created by: Jean Louis FRENKEL
-- Copyright (c) 1993-1999 Matra Datavision
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
--
-- The content of this file is subject to the Open CASCADE Technology Public
-- License Version 6.5 (the "License"). You may not use the content of this file
-- except in compliance with the License. Please obtain a copy of the License
-- at http://www.opencascade.org and read it completely before using this file.
--
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
--
-- The Original Code and all software distributed under the License is
-- distributed on an "AS IS" basis, without warranty of any kind, and the
-- Initial Developer hereby disclaims all such warranties, including without
-- limitation, any warranties of merchantability, fitness for a particular
-- purpose or non-infringement. Please see the License for the specific terms
-- and conditions governing the rights and limitations under the License.
deferred class Image from Image inherits TShared from MMgt
---Purpose: This class defined the general behavior of an Image from
-- Package Image .
uses
PlaneAngle from Quantity,
FlipType from Image,
Color from Quantity,
Array1OfColor from Quantity,
HArray1OfColor from Quantity,
Pixel from Aspect,
PixelAddress from Image,
TypeOfImage from Image,
Type from Standard
is
Initialize( aPixelType : Type from Standard );
---Level: Public
---Purpose: Image constructor ,initialise the Image PixelType.
Destroy( me : mutable )
is virtual ;
---C++: alias ~
---Level: Public
---Purpose: Image destructor.
isSamePixel( me : immutable ;
X,Y : in Integer from Standard ;
anotherImage : immutable like me ;
anotherX,anotherY : in Integer from Standard )
returns Boolean from Standard is deferred ;
---Level: Public
---Purpose: Returns True if me->Pixel(X,Y) is equal to
-- anotherImage->Pixel(anotherX,anotherY)
PixelColor( me : immutable ; X,Y : in Integer from Standard )
returns Color from Quantity is deferred ;
---C++: return const &
---Purpose: Returns the Color of an Image Pixel.
RowColor ( me : immutable ; Y : in Integer from Standard )
returns HArray1OfColor from Quantity is virtual ;
---Purpose: Returns the Color of an Image Pixel Row.
RowColor ( me : immutable ;
Y : in Integer from Standard ;
aArray1 : in out Array1OfColor from Quantity )
is virtual ;
---Purpose: Stores the Color of an Image Pixel Row in aArray1.
PixelType( me : immutable ) returns Type from Standard ;
---Level: Public
---Purpose: Returns the Image Pixel Type.
Size ( me : immutable ) returns Integer from Standard ;
---Purpose: Returns the Image size in Pixel unit ( width*height) .
InternalDup( me : mutable ; anImage : immutable like me )
is deferred ;
---Purpose : Duplicates an Image.
-- ******************* Deferred method of Image *******************
SetOrigin( me : mutable ; x,y : in Integer from Standard )
is deferred ;
---Purpose: Sets Image origin, for Rotation, copy between image ...
-- Image origin is on the TOP LEFT . Y axis goes TOP to
-- DOWN , X axis goes LEFT to RIGHT.
LowerX ( me : immutable ) returns Integer from Standard is deferred ;
---Level: Public
---Purpose: Returns the lower X Image coordinate ( X Origin ).
UpperX ( me : immutable ) returns Integer from Standard is deferred ;
---Level: Public
---Purpose: Returns the upper X Image coordinate
-- ( X Origin + Image width - 1 ).
Width ( me : immutable ) returns Integer from Standard is deferred ;
---Level: Public
---Purpose: Returns the Image width.
LowerY ( me : immutable ) returns Integer from Standard is deferred ;
---Level: Public
---Purpose: Returns the lower Y Image coordinate ( Y Origin ).
UpperY ( me : immutable ) returns Integer from Standard is deferred ;
---Level: Public
---Purpose: Returns the upper Y Image coordinate
-- ( Y Origin + Image height - 1 ).
Height ( me : immutable ) returns Integer from Standard is deferred ;
---Level: Public
---Purpose: Returns the Image height.
Resize( me : mutable ;
XOffset,XScale, YOffset,YScale : Real from Standard ) is deferred ;
---Level: Public
---Purpose: Resize an Image. Image Pixel are left unchanged at there
-- absolute positon. Resulting Image can be clipped.
-- newLowerX = LowerX()*XScale + XOffset
-- newLowerY = LowerY()*YScale + YOffset
-- newUpperX = UpperX()*XScale + XOffset
-- newUpperY = UpperY()*YScale + YOffset
-- newWidth = Width() *XScale
-- newHeight = Height()*YScale
Type ( me : immutable ) returns TypeOfImage from Image is deferred ;
---Level: Public
---Purpose: Returns the ImageType TOI_ColorImage or TOI_PseudoColorImage
Pixel ( me : immutable ; X,Y : in Integer from Standard ;
aPixel : in out Pixel from Aspect )
is deferred ;
---Level: Public
---Purpose: Get the Image Pixel Value at X,Y coordinate in aPixel.
-- Warning: aPixel must have the same type than Image Pixel.
SetPixel( me : mutable ; X,Y : in Integer from Standard ;
aPixel : in Pixel from Aspect )
is deferred ;
---Level: Public
---Purpose: Store aPixel in the Image at X,Y coordinate .
-- Warning: aPixel must have the same type than Image Pixel.
Pixel ( me : immutable ; X,Y : in Integer from Standard ;
aPixel : in out PixelAddress from Image )
is deferred ;
---Level: Public
---Purpose: Get the Image Pixel Value at X,Y coordinate in aPixel.
-- Warning: aPixel must have the same type than Image Pixel.
SetPixel( me : mutable ; X,Y : in Integer from Standard ;
aPixel : in PixelAddress from Image )
is deferred ;
---Level: Public
---Purpose: Store aPixel in the Image at X,Y coordinate .
-- Warning: aPixel must have the same type than Image Pixel.
Transpose ( me : mutable ; aType : in FlipType from Image ) is deferred ;
---Level: Public
---Purpose: Transpose an Image( flipping across horizontal axis or
-- vertical axis, or across diagonal... )
-- This geometric transformation preserves all Image Pixels.
-- We don't need to interpolate pixels .
-- Warning : Image size change during Transpose.
Clip ( me : mutable ; X,Y,Width,Height:in Integer from Standard)
is deferred ;
---Level: Public
---Purpose: Extract a SubImage starting at coordinate X,Y
-- to (X+Width-1),(Y+Height-1).
-- Warning : the Image size and origin change, new origin
-- is X,Y ; new size is Width,Height.
Shift ( me : mutable ; XShift,YShift :in Integer from Standard)
is deferred ;
---Level: Public
---Purpose: Translate an Image XShift pixel Right, YShift Down .
-- Shift parameter are Integer value.
Fill ( me : mutable ; SrcImage : immutable like me ) is deferred ;
---Level: Public
---Purpose: Fill me with SrcImage. SrcImage pixel are copied starting
-- at SrcImage->LowerX(),SrcImage->LowerY() in MyPixelField.
-- SrcImage Pixel are clipped outside <me>.
Fill ( me : mutable ; SrcImage : immutable like me ;
SrcX, SrcY, SrcWidth, SrcHeight,
X, Y : in Integer from Standard ) is deferred ;
---Level: Public
---Purpose: Fill me with a SubImage of SrcImage starting from
-- SrcX, SrcY to (SrcX+SrcWidth-1),(SrcY+SrcHeight-1) in
-- Src Image coordinate. SrcImage SubImage pixels are copied
-- starting at X,Y in MyPixelField.
-- SrcImage Pixel are clipped outside <me>.
Clear ( me : mutable ) is deferred ;
---Level: Public
---Purpose: Fill the entire Image with the BackgroundPixel.
Dup ( me : immutable ) returns mutable Image from Image is deferred;
---Level: Public
---Purpose : Duplicate an Image.
Dump( me : immutable ) is deferred ;
---Level: Public
---Purpose: Debug
fields
myPixelType : Type from Standard ;
end Image from Image;

View File

@ -1,82 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <Image_Image.ixx>
#ifdef TRACE
static int ImageCount = 0 ;
#endif
Image_Image::Image_Image ( const Handle(Standard_Type)& aPixelType )
{
#ifdef TRACE
cout << "\tCreate a new Image ( Count : " << ++ImageCount << " )" << endl
<< flush ;
#endif
myPixelType = aPixelType ;
}
Standard_Integer Image_Image::Size() const {
return ( Width() * Height() ) ;
}
void Image_Image::InternalDup( const Handle(Image_Image)& aImage )
{ // myPixelType is set in Image_Image Constructor
}
Handle(Standard_Type) Image_Image::PixelType() const { return myPixelType ; }
void Image_Image::Destroy ()
{
#ifdef TRACE
cout << "\tDelete an Image ( Count : " << --ImageCount << " )" << endl
<< flush ;
#endif
}
void Image_Image::RowColor( const Standard_Integer Y,
Quantity_Array1OfColor& PR) const {
Standard_Integer TheLength = Min (PR.Length(), Width() );
Standard_Integer L = PR.Lower() ;
Standard_Integer X = LowerX() ;
for (Standard_Integer i=0; i< TheLength; i++) {
PR(L+i) = PixelColor(X+i,Y);
}
}
Handle(Quantity_HArray1OfColor) Image_Image::RowColor(
const Standard_Integer Y ) const {
Standard_Integer TheLength = Width() ;
Standard_Integer X = LowerX() ;
Handle(Quantity_HArray1OfColor) PR =
new Quantity_HArray1OfColor( 0, TheLength-1) ;
for (Standard_Integer i=0; i< TheLength; i++) {
PR->SetValue(i,PixelColor(X+i,Y));
}
return PR ;
}

View File

@ -1,37 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
//============================================================================
//==== Titre: Image_PixelAddress.hxx
//====
//==== Implementation: This is a primitive type implemented with typedef
//============================================================================
#ifndef _Image_PixelAddress_HeaderFile
#define _Image_PixelAddress_HeaderFile
//==== Definition de Type ====================================================
#include <Standard_Type.hxx>
const Handle(Standard_Type)& STANDARD_TYPE(Image_PixelAddress);
//============================================================================
#include <Aspect_Pixel.hxx>
typedef Aspect_Pixel *Image_PixelAddress ;
#endif

View File

@ -1,102 +0,0 @@
-- Created on: 1993-07-27
-- Created by: Jean Louis FRENKEL
-- Copyright (c) 1993-1999 Matra Datavision
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
--
-- The content of this file is subject to the Open CASCADE Technology Public
-- License Version 6.5 (the "License"). You may not use the content of this file
-- except in compliance with the License. Please obtain a copy of the License
-- at http://www.opencascade.org and read it completely before using this file.
--
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
--
-- The Original Code and all software distributed under the License is
-- distributed on an "AS IS" basis, without warranty of any kind, and the
-- Initial Developer hereby disclaims all such warranties, including without
-- limitation, any warranties of merchantability, fitness for a particular
-- purpose or non-infringement. Please see the License for the specific terms
-- and conditions governing the rights and limitations under the License.
class PixelInterpolation from Image
---Purpose: The class PixelInterpolation is used to compute a Pixel
-- value on non-integer Image coordinate. This Pixel type
-- is called SubPixel .
-- PixelInterpolation is the default and is the simplest one,
-- SubPixel value on non-integer Image coordinate is the
-- value of the nearest Pixel at integer coordinate.
-- The user can create a new kind of PixelInterpolation with a
-- new algorithm by creating a new derived PixelInterpolation
-- class and redefined Interpolate() method.
-- If V1 is the value of the nearest Image Pixel
-- V = V1 is the Image SubPixel value on non-integer
-- coordinate (FX,FY)
uses
Pixel from Aspect,
Image from Image,
ColorPixel from Aspect,
IndexPixel from Aspect,
DColorImage from Image,
DIndexedImage from Image
is
Create returns PixelInterpolation from Image ;
---Level: Public
---Purpose: Create a PixelInterpolation object.
Interpolate( me ; aImage : Image from Image ;
X,Y : Real from Standard ;
LowerX,LowerY,UpperX,UpperY : Integer from Standard ;
RetPixel : in out Pixel from Aspect )
returns Boolean from Standard
is virtual ;
---Level: Public
---Purpose: Compute SubPixel's value on non-integer Image coordinate.
-- LowerX,LowerY,UpperX,UpperY is the Image Min Max, it's used
-- to check if the SubPixel coordinate X,Y is outside of image.
-- Return True if Interpolation Succes.
-- Retrun False if the SubPixel is out from Image.
Interpolate( me ; aImage : DColorImage from Image ;
FX,FY : Real from Standard ;
LowerX,LowerY,UpperX,UpperY : Integer from Standard ;
RetPixel : in out ColorPixel from Aspect )
returns Boolean from Standard
is virtual ;
---Level: Public
---Purpose: Compute SubPixel's value on non-integer Image coordinate for
-- DColorImage and ColorPixel.
-- LowerX,LowerY,UpperX,UpperY is the Image Min Max, it's used
-- to check if the SubPixel coordinate FX,FY is outside of
-- image.
-- Return True if Interpolation Succes.
-- Return False if the SubPixel is out from Image.
Interpolate( me ; aImage : DIndexedImage from Image ;
FX,FY : Real from Standard ;
LowerX,LowerY,UpperX,UpperY : Integer from Standard ;
RetPixel : in out IndexPixel from Aspect )
returns Boolean from Standard
is virtual ;
---Level: Public
---Purpose: Compute SubPixel's value on non-integer Image coordinate for
-- DIndexedImage and IndexPixel.
-- LowerX,LowerY,UpperX,UpperY is the Image Min Max, it's use
-- check if the SubPixel coordinate X,Y is outside of image.
-- Return True if Interpolation Succes.
-- Return False if the SubPixel is out from Image.
DoInterpolate( me ; aImage : Image from Image ;
X,Y : Real from Standard ;
LowerX,LowerY,UpperX,UpperY: Integer from Standard ;
RetPixel : in out Pixel from Aspect )
returns Boolean from Standard is static private ;
end PixelInterpolation from Image;

View File

@ -1,83 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <Image_PixelInterpolation.ixx>
Image_PixelInterpolation::Image_PixelInterpolation() {}
Standard_Boolean Image_PixelInterpolation::DoInterpolate(
const Handle(Image_Image)& aImage,
const Standard_Real X, const Standard_Real Y,
const Standard_Integer LowX,
const Standard_Integer LowY,
const Standard_Integer UpX,
const Standard_Integer UpY,
Aspect_Pixel& aPixel ) const
{ Standard_Integer NX ;
Standard_Integer NY ;
if ( X < 0. ) NX = Standard_Integer(X-0.5) ;
else NX = Standard_Integer(X+0.5) ;
if ( Y < 0. ) NY = Standard_Integer(Y-0.5) ;
else NY = Standard_Integer(Y+0.5) ;
if ( NX < LowX || NX > UpX ||
NY < LowY || NY > UpY ) {
return Standard_False ;
}
else {
aImage->Pixel( NX, NY, aPixel );
return Standard_True ;
}
}
Standard_Boolean Image_PixelInterpolation::Interpolate(
const Handle(Image_Image)& aImage,
const Standard_Real FX, const Standard_Real FY,
const Standard_Integer LowX,
const Standard_Integer LowY,
const Standard_Integer UpX,
const Standard_Integer UpY,
Aspect_Pixel& aPixel ) const
{ return DoInterpolate( aImage, FX, FY, LowX, LowY, UpX, UpY, aPixel ) ; }
Standard_Boolean Image_PixelInterpolation::Interpolate(
const Handle(Image_DColorImage)& aImage,
const Standard_Real FX, const Standard_Real FY,
const Standard_Integer LowX,
const Standard_Integer LowY,
const Standard_Integer UpX,
const Standard_Integer UpY,
Aspect_ColorPixel& aPixel ) const
{ return DoInterpolate( aImage, FX, FY, LowX, LowY, UpX, UpY, aPixel ) ; }
Standard_Boolean Image_PixelInterpolation::Interpolate(
const Handle(Image_DIndexedImage)& aImage,
const Standard_Real FX, const Standard_Real FY,
const Standard_Integer LowX,
const Standard_Integer LowY,
const Standard_Integer UpX,
const Standard_Integer UpY,
Aspect_IndexPixel& aPixel ) const
{ return DoInterpolate( aImage, FX, FY, LowX, LowY, UpX, UpY, aPixel ) ; }

View File

@ -1,94 +0,0 @@
-- Created on: 1993-07-27
-- Created by: Jean Louis FRENKEL
-- Copyright (c) 1993-1999 Matra Datavision
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
--
-- The content of this file is subject to the Open CASCADE Technology Public
-- License Version 6.5 (the "License"). You may not use the content of this file
-- except in compliance with the License. Please obtain a copy of the License
-- at http://www.opencascade.org and read it completely before using this file.
--
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
--
-- The Original Code and all software distributed under the License is
-- distributed on an "AS IS" basis, without warranty of any kind, and the
-- Initial Developer hereby disclaims all such warranties, including without
-- limitation, any warranties of merchantability, fitness for a particular
-- purpose or non-infringement. Please see the License for the specific terms
-- and conditions governing the rights and limitations under the License.
class PlanarPixelInterpolation from Image inherits PixelInterpolation from Image
---Purpose: The class PlanarPixelInterpolation is used to compute a
-- SubPixelvalue on non integer Image coordinate
-- PlanarPixelInterpolation redefined a new method to compute a
-- SubPixel value .
-- To compute the value of a Image SubPixel, first we look
-- for the three nearest Image Pixels .
-- Then we compute the plane definition in the 3D space
-- composed by the Image Pixel coordinate and Pixel value
-- on Z axis .
-- The SubPixel value is the Z value of ( FX,FY ) point in the
-- three nearest Image Pixel defined plane .
uses
Image from Image,
Pixel from Aspect,
ColorPixel from Aspect,
IndexPixel from Aspect,
DColorImage from Image,
DIndexedImage from Image
is
Create returns PlanarPixelInterpolation from Image ;
---Level: Public
---Purpose: Create a PlanarPixelInterpolation object.
Interpolate( me ; aImage : Image from Image ;
X,Y : Real from Standard ;
LowerX,LowerY,UpperX,UpperY : Integer from Standard ;
RetPixel : in out Pixel from Aspect )
returns Boolean from Standard is redefined ;
---Level: Public
---Purpose: Redefined the method to compute SubPixel's value
-- on non integer Image coordinate.
-- LowerX,LowerY,UpperX,UpperY is the Image Min Max, it's used
-- to check if the SubPixel coordinate FX,FY is outside of
-- image.
-- Return True if Interpolation Succes.
-- Return False if the SubPixel is out from Image.
Interpolate( me ; aImage : DColorImage from Image ;
X,Y : Real from Standard ;
LowerX,LowerY,UpperX,UpperY : Integer from Standard ;
RetPixel : in out ColorPixel from Aspect )
returns Boolean from Standard is redefined;
---Level: Public
---Purpose: Compute SubPixel's value on non integer Image coordinate for
-- DColorImage and ColorPixel.
-- LowerX,LowerY,UpperX,UpperY is the Image Min Max, it's used
-- to check if the SubPixel coordinate FX,FY is outside of
-- image.
-- Return True if Interpolation Succes.
-- Return False if the SubPixel is out from Image.
Interpolate( me ; aImage : DIndexedImage from Image ;
X,Y : Real from Standard ;
LowerX,LowerY,UpperX,UpperY : Integer from Standard ;
RetPixel : in out IndexPixel from Aspect )
returns Boolean from Standard is redefined ;
---Level: Public
---Purpose: Compute SubPixel's value on non integer Image coordinate for
-- DIndexedImage and IndexPixel.
-- LowerX,LowerY,UpperX,UpperY is the Image Min Max, it's used
-- to check if the SubPixel coordinate X,Y is outside of
-- image.
-- Return True if Interpolation Succes.
-- Return False if the SubPixel is out from Image.
end PlanarPixelInterpolation from Image;

View File

@ -1,283 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <Image_PlanarPixelInterpolation.ixx>
Image_PlanarPixelInterpolation::Image_PlanarPixelInterpolation() {}
Standard_Boolean Image_PlanarPixelInterpolation::Interpolate(
const Handle(Image_Image)& aImage,
const Standard_Real FX, const Standard_Real FY,
const Standard_Integer LowX,
const Standard_Integer LowY,
const Standard_Integer UpX,
const Standard_Integer UpY,
Aspect_Pixel& aPixel ) const
{
if ( aImage->IsKind(STANDARD_TYPE(Image_DIndexedImage))) {
return Interpolate( Handle(Image_DIndexedImage)::DownCast( aImage ),
FX,FY,LowX,LowY,UpX,UpY,(Aspect_IndexPixel &)aPixel ) ;
}
else if ( aImage->IsKind(STANDARD_TYPE(Image_DColorImage))) {
return Interpolate( Handle(Image_DColorImage)::DownCast( aImage ),
FX,FY,LowX,LowY,UpX,UpY,(Aspect_ColorPixel &)aPixel ) ;
}
else {
return Image_PixelInterpolation::Interpolate( aImage,
FX,FY,LowX,LowY,UpX,UpY,aPixel ) ;
}
}
static Standard_Real DoInterpolation( const Standard_Integer NX[3],
const Standard_Integer NY[3],
const Standard_Real NZ[3],
const Standard_Real FX,
const Standard_Real FY )
{ Standard_Real VX[3], VY[3], VZ[3] ;
Standard_Real Result ;
if ( NZ[0] == NZ[1] && NZ[0] == NZ[2] ) {
Result = NZ[0] ;
}
else {
VX[1] = NX[1] - NX[0] ;
VY[1] = NY[1] - NY[0] ;
VZ[1] = NZ[1] - NZ[0] ;
VX[2] = NX[2] - NX[0] ;
VY[2] = NY[2] - NY[0] ;
VZ[2] = NZ[2] - NZ[0] ;
if ( VZ[1] == 0. && VZ[2] == 0. ) {
Result = NZ[0] ;
}
else {
VX[0] = VY[1]*VZ[2] - VY[2]*VZ[1] ;
VY[0] = VZ[1]*VX[2] - VZ[2]*VX[1] ;
VZ[0] = VX[1]*VY[2] - VX[2]*VY[1] ;
if ( VZ[0] != 0. ) {
Result = NZ[0] -
( (FX-NX[0])*VX[0] + (FY-NY[0])*VY[0] ) / VZ[0];
}
else {
Result = NZ[0] ;
}
}
}
return Result ;
}
Standard_Boolean Image_PlanarPixelInterpolation::Interpolate(
const Handle(Image_DColorImage)& aImage,
const Standard_Real FX, const Standard_Real FY,
const Standard_Integer LowX,
const Standard_Integer LowY,
const Standard_Integer UpX,
const Standard_Integer UpY,
Aspect_ColorPixel& aPixel ) const
{ Standard_Integer NX[3], NY[3] ;
Standard_Real NZ[3] ;
Standard_Real R,G,B ;
static Quantity_Color Col ;
if ( FX < 0. ) NX[0] = Standard_Integer(FX-0.5) ;
else NX[0] = Standard_Integer(FX+0.5) ;
if ( FY < 0. ) NY[0] = Standard_Integer(FY-0.5) ;
else NY[0] = Standard_Integer(FY+0.5) ;
if ( NX[0] < LowX || NX[0] > UpX ||
NY[0] < LowY || NY[0] > UpY ) {
return Standard_False ;
}
else if ( ( FX-NX[0] ) == 0. && ( FY-NY[0] ) == 0. ) {
aImage->Pixel( NX[0], NY[0], aPixel );
return Standard_True ;
}
else {
if ( ( FX-NX[0] ) >= 0. ) { NX[1] = NX[0]+1 ; NY[1] = NY[0] ; }
else { NX[1] = NX[0]-1 ; NY[1] = NY[0] ; }
if ( ( FY-NY[0] ) >= 0. ) { NX[2] = NX[0] ; NY[2] = NY[0]+1 ; }
else { NX[2] = NX[0] ; NY[2] = NY[0]-1 ; }
if ( NX[1] < LowX || NX[1] > UpX || NY[1] < LowY || NY[1] > UpY ||
NX[2] < LowX || NX[2] > UpX || NY[2] < LowY || NY[2] > UpY ) {
aImage->Pixel( NX[0], NY[0], aPixel );
}
else {
NZ[0] = aImage->Pixel( NX[0],NY[0] ).Value().Red() ;
NZ[1] = aImage->Pixel( NX[1],NY[1] ).Value().Red() ;
NZ[2] = aImage->Pixel( NX[2],NY[2] ).Value().Red() ;
R = DoInterpolation( NX,NY,NZ, FX,FY ) ;
NZ[0] = aImage->Pixel( NX[0],NY[0] ).Value().Green() ;
NZ[1] = aImage->Pixel( NX[1],NY[1] ).Value().Green() ;
NZ[2] = aImage->Pixel( NX[2],NY[2] ).Value().Green() ;
G = DoInterpolation( NX,NY,NZ, FX,FY ) ;
NZ[0] = aImage->Pixel( NX[0],NY[0] ).Value().Blue() ;
NZ[1] = aImage->Pixel( NX[1],NY[1] ).Value().Blue() ;
NZ[2] = aImage->Pixel( NX[2],NY[2] ).Value().Blue() ;
B = DoInterpolation( NX,NY,NZ, FX,FY ) ;
Col.SetValues( R, G, B, Quantity_TOC_RGB ) ;
aPixel.SetValue( Col ) ;
}
return Standard_True ;
}
}
Standard_Boolean Image_PlanarPixelInterpolation::Interpolate(
const Handle(Image_DIndexedImage)& aImage,
const Standard_Real FX, const Standard_Real FY,
const Standard_Integer LowX,
const Standard_Integer LowY,
const Standard_Integer UpX,
const Standard_Integer UpY,
Aspect_IndexPixel& aPixel ) const
{ Standard_Integer NX[3], NY[3] ;
Standard_Real NZ[3] ;
if ( FX < 0. ) NX[0] = Standard_Integer(FX-0.5) ;
else NX[0] = Standard_Integer(FX+0.5) ;
if ( FY < 0. ) NY[0] = Standard_Integer(FY-0.5) ;
else NY[0] = Standard_Integer(FY+0.5) ;
if ( NX[0] < LowX || NX[0] > UpX ||
NY[0] < LowY || NY[0] > UpY ) {
return Standard_False ;
}
else if ( ( FX-NX[0] ) == 0. && ( FY-NY[0] ) == 0. ) {
aImage->Pixel( NX[0], NY[0], aPixel );
return Standard_True ;
}
else {
if ( ( FX-NX[0] ) >= 0. ) { NX[1] = NX[0]+1 ; NY[1] = NY[0] ; }
else { NX[1] = NX[0]-1 ; NY[1] = NY[0] ; }
if ( ( FY-NY[0] ) >= 0. ) { NX[2] = NX[0] ; NY[2] = NY[0]+1 ; }
else { NX[2] = NX[0] ; NY[2] = NY[0]-1 ; }
if ( NX[1] < LowX || NX[1] > UpX || NY[1] < LowY || NY[1] > UpY ||
NX[2] < LowX || NX[2] > UpX || NY[2] < LowY || NY[2] > UpY ) {
aImage->Pixel( NX[0], NY[0], aPixel );
}
else {
NZ[0] = aImage->Pixel( NX[0],NY[0] ).Value() ;
NZ[1] = aImage->Pixel( NX[1],NY[1] ).Value() ;
NZ[2] = aImage->Pixel( NX[2],NY[2] ).Value() ;
aPixel.SetValue(
Standard_Integer( DoInterpolation( NX,NY,NZ, FX,FY ) )
) ;
}
return Standard_True ;
}
}
//##############################################################################
#ifdef OLD
{ Standard_Integer NX[3], NY[3], NZ[3] ;
Standard_Integer Result ;
Standard_Real VX[3], VY[3], VZ[3], PVALUE ;
NX[0] = Standard_Integer(FX+0.5) ;
NY[0] = Standard_Integer(FY+0.5) ;
if ( NX[0] < LowX || NX[0] > UpX ||
NY[0] < LowY || NY[0] > UpY ) {
return Standard_False ;
}
else if ( ( FX-NX[0] ) == 0. && ( FY-NY[0] ) == 0. ) {
aImage->Pixel( NX[0], NY[0], aPixel );
return Standard_True ;
}
else {
if ( ( FX-NX[0] ) >= 0. ) { NX[1] = NX[0]+1 ; NY[1] = NY[0] ; }
else { NX[1] = NX[0]-1 ; NY[1] = NY[0] ; }
if ( ( FY-NY[0] ) >= 0. ) { NX[2] = NX[0] ; NY[2] = NY[0]+1 ; }
else { NX[2] = NX[0] ; NY[2] = NY[0]-1 ; }
if ( NX[1] < LowX || NX[1] > UpX || NY[1] < LowY || NY[1] > UpY ||
NX[2] < LowX || NX[2] > UpX || NY[2] < LowY || NY[2] > UpY ) {
aImage->Pixel( NX[0], NY[0], aPixel );
}
else {
NZ[0] = aImage->Pixel( NX[0],NY[0] ).Value() ;
NZ[1] = aImage->Pixel( NX[1],NY[1] ).Value() ;
NZ[2] = aImage->Pixel( NX[2],NY[2] ).Value() ;
VX[1] = NX[1] - NX[0] ;
VY[1] = NY[1] - NY[0] ;
VZ[1] = NZ[1] - NZ[0] ;
VX[2] = NX[2] - NX[0] ;
VY[2] = NY[2] - NY[0] ;
VZ[2] = NZ[2] - NZ[0] ;
if ( VZ[1] == 0. && VZ[2] == 0. ) {
Result = NZ[0] ;
}
else {
VX[0] = VY[1]*VZ[2] - VY[2]*VZ[1] ;
VY[0] = VZ[1]*VX[2] - VZ[2]*VX[1] ;
VZ[0] = VX[1]*VY[2] - VX[2]*VY[1] ;
if ( VZ[0] != 0. ) {
PVALUE = NZ[0] -
( (FX-NX[0])*VX[0] + (FY-NY[0])*VY[0] ) / VZ[0];
Result = Standard_Integer( PVALUE ) ;
}
else {
Result = NZ[0] ;
}
}
aPixel.SetValue( Result ) ;
}
return Standard_True ;
}
}
#endif

View File

@ -1,147 +0,0 @@
-- Created on: 1993-07-27
-- Created by: Jean Louis FRENKEL
-- Copyright (c) 1993-1999 Matra Datavision
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
--
-- The content of this file is subject to the Open CASCADE Technology Public
-- License Version 6.5 (the "License"). You may not use the content of this file
-- except in compliance with the License. Please obtain a copy of the License
-- at http://www.opencascade.org and read it completely before using this file.
--
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
--
-- The Original Code and all software distributed under the License is
-- distributed on an "AS IS" basis, without warranty of any kind, and the
-- Initial Developer hereby disclaims all such warranties, including without
-- limitation, any warranties of merchantability, fitness for a particular
-- purpose or non-infringement. Please see the License for the specific terms
-- and conditions governing the rights and limitations under the License.
class PseudoColorImage from Image inherits DIndexedImage from Image
---Purpose : A PseudoColorImage is a DIndexedImage associated with a
-- ColorMap . The ColoMap is set at Creation time and then
-- never be changed. Each Pixel in the Image ,as a IndexPixel
-- from Aspect, match a ColoMap Entry with the same value.
uses
ColorMap from Aspect,
Color from Quantity,
IndexPixel from Aspect ,
Array1OfColor from Quantity,
HArray1OfColor from Quantity,
LookupTable from Image,
Image from Image,
TypeOfImage from Image
is
Create( x,y,dx,dy : in Integer from Standard ;
aColorMap : ColorMap from Aspect )
returns mutable PseudoColorImage from Image;
---Level: Public
---Purpose : Creates a PseudoColorImage object.
-- The default Background Pixel is set to 0 .
-- All the Image is initialised with Background Pixel
Create( x,y,dx,dy : in Integer from Standard ;
aColorMap : ColorMap from Aspect ;
BackPixel : IndexPixel from Aspect )
returns mutable PseudoColorImage from Image;
---Level: Public
---Purpose : Creates a PseudoColorImage object and set the
-- Background Pixel.
-- All the Image is initialised with Background Pixel
Type ( me : immutable ) returns TypeOfImage from Image ;
---Level: Public
---Purpose : Returns the Image Type.
ColorMap( me ) returns immutable ColorMap from Aspect;
---Level: Public
---Purpose : returns the Image ColorMap .
PixelColor( me : immutable ; X,Y : in Integer from Standard )
returns Color from Quantity ;
---C++: return const &
---Level: Public
---Purpose : Returns the Pixel Color .
RowColor ( me : immutable ; Y : in Integer from Standard )
returns HArray1OfColor from Quantity is redefined ;
---Level: Public
---Purpose : Return the PixelRow Color in a HArray1 of Color.
RowColor ( me : immutable ;
Y : in Integer from Standard ;
aArray1 : in out Array1OfColor from Quantity ) is redefined ;
---Level: Public
---Purpose : Stores the PixelRow Color in a Array1 .
Squeeze( me : immutable ;
BasePixel : IndexPixel from Aspect )
returns PseudoColorImage from Image ;
---Level: Public
---Purpose : Creates a new Image with continuous Pixel and a continuous
-- ColorMap whith only used Image color starting from
-- BasePixel .
SqueezedLookupTable(
me : immutable ;
BasePixel : IndexPixel from Aspect ;
aLookup : in out LookupTable from Image ) ;
---Level: Public
---Purpose: Creates a LookupTable that can be used to create a
-- new Image with continuous Pixel and a continuous
-- ColorMap with only used Image color starting
-- from BasePixel .
Lookup( me : mutable ;
aLookup : in LookupTable from Image ) ;
---Level: Public
---Purpose : Pass a PseudoColorImage through a lookupTable
Extrema( me : immutable ; Min, Max : in out IndexPixel from Aspect );
---Level: Public
---Purpose: Find the maximum and minimum Pixel Value of an Image.
Threshold( me : mutable ; Min, Max : IndexPixel from Aspect ;
Map : IndexPixel from Aspect );
---Level: Public
---Purpose: This method changes the value of any Pixel beetwen the
-- range (Min->Max) to the Pixel Map value. All Pixel values
-- outside the range are passed through without changed .
Rescale( me : mutable ; Scale, Offset : Real from Standard ) ;
---Level: Public
---Purpose : Map the Image Pixel Value from one range to another range.
-- This method perform the mapping by multiplying each
-- Pixel Value by Scale and then adding Offset to the result.
Dup ( me : immutable ) returns mutable Image from Image;
---Level: Public
---Purpose : Duplicate a Image.
-- ******************* Redefined method ***************************
-- ShallowCopy (me) returns mutable like me ;
---Level: Public
-- ---Purpose: Returns a copy at the first level of <me>. The objects
-- -- referenced are not copied. Entities copied by
-- -- ShallowCopy are equal.
-- ---C++: function call
-- DeepCopy (me) returns mutable like me ;
---Level: Public
-- ---Purpose: Returns a deep copy of <me>. The objects
-- -- referenced are copied. Entities copied by
-- -- DeepCopy are similar (c.f the Method IsSimilar).
-- ---C++: function call
fields
myColorMap: ColorMap from Aspect;
end PseudoColorImage from Image;

View File

@ -1,322 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <Image_PseudoColorImage.ixx>
#include <Image_LookupTable.hxx>
#include <TColStd_SetIteratorOfSetOfInteger.hxx>
#include <TColStd_SetOfInteger.hxx>
#include <Aspect_GenericColorMap.hxx>
#include <Aspect_ColorMapEntry.hxx>
Image_PseudoColorImage::Image_PseudoColorImage (
const Standard_Integer x,
const Standard_Integer y,
const Standard_Integer dx,
const Standard_Integer dy,
const Handle(Aspect_ColorMap)& aColorMap)
: Image_DIndexedImage( x, y, dx, dy, Aspect_IndexPixel( 0 ) ) ,
myColorMap (aColorMap)
{
}
Image_PseudoColorImage::Image_PseudoColorImage (
const Standard_Integer x,
const Standard_Integer y,
const Standard_Integer dx,
const Standard_Integer dy,
const Handle(Aspect_ColorMap)& aColorMap,
const Aspect_IndexPixel& Back )
: Image_DIndexedImage( x, y, dx, dy, Back ) , myColorMap (aColorMap)
{
}
Handle(Image_Image) Image_PseudoColorImage::Dup() const {
Handle(Image_PseudoColorImage) aImage =
new Image_PseudoColorImage( LowerX(), LowerY(),
Width(), Height(),
myColorMap,
BackgroundPixel() ) ;
aImage->InternalDup( this ) ;
return aImage ;
}
Image_TypeOfImage Image_PseudoColorImage::Type () const {
return Image_TOI_PseudoColorImage ;
}
Handle(Aspect_ColorMap) Image_PseudoColorImage::ColorMap () const {
return myColorMap;
}
const Quantity_Color& Image_PseudoColorImage::PixelColor(
const Standard_Integer x,
const Standard_Integer y ) const
{ return( myColorMap->FindEntry ( Pixel( x, y ).Value()
).Color() ) ;
}
void Image_PseudoColorImage::RowColor( const Standard_Integer Y,
Quantity_Array1OfColor& PR) const {
Standard_Integer TheLength = Min (PR.Length(), Width() );
Standard_Integer L = PR.Lower() ;
Standard_Integer X = LowerX() ;
Standard_Integer NIndex ;
Standard_Integer PIndex = Pixel( X, Y ).Value() ;
Quantity_Color PColor = PixelColor( X, Y ) ;
for (Standard_Integer i=0; i< TheLength; i++) {
NIndex = Pixel(X+i,Y).Value() ;
if ( NIndex != PIndex ) {
PIndex = NIndex ;
PColor = myColorMap->FindEntry( PIndex ).Color() ;
}
PR(L+i) = PColor;
}
}
Handle(Quantity_HArray1OfColor) Image_PseudoColorImage::RowColor(
const Standard_Integer Y ) const {
Standard_Integer TheLength = Width() ;
Standard_Integer X = LowerX() ;
Standard_Integer NIndex ;
Standard_Integer PIndex = Pixel( X, Y ).Value() ;
Quantity_Color PColor = PixelColor( X, Y ) ;
Handle(Quantity_HArray1OfColor) PR =
new Quantity_HArray1OfColor( 0, TheLength-1) ;
for (Standard_Integer i=0; i< TheLength; i++) {
NIndex = Pixel(X+i,Y).Value() ;
if ( NIndex != PIndex ) {
PIndex = NIndex ;
PColor = myColorMap->FindEntry( PIndex ).Color() ;
}
PR->SetValue(i,PColor);
}
return PR ;
}
void Image_PseudoColorImage::SqueezedLookupTable(
const Aspect_IndexPixel& BasePixel,
Image_LookupTable& aLookup ) const
{ TColStd_SetOfInteger PixelSet ;
TColStd_SetIteratorOfSetOfInteger It;
Standard_Integer x, y, i, UpX, UpY ;
// Aspect_IndexPixel aPixel ;
//Image_LookupTable aLookup( 101 ) ;
// Aspect_ColorMapEntry aEntry;
UpX = UpperX() ;
UpY = UpperY() ;
for ( y = LowerY() ; y <= UpY ; y++ ) {
for ( x = LowerX() ; x <= UpX ; x++ ) {
PixelSet.Add( Pixel( x, y ).Value() ) ;
}
}
#ifdef TRACE
cout << "Squeeze() PixelSet Extent :" << PixelSet.Extent() << endl ;
#endif
for (It.Initialize(PixelSet), i = BasePixel.Value() ;
It.More(); It.Next(), i++ ) {
aLookup.Bind( It.Value(), i ) ;
}
// Modif CAL 10/02/95: passage par argument car copie inaccessible.
// return( aLookup ) ;
}
Handle(Image_PseudoColorImage) Image_PseudoColorImage::Squeeze(
const Aspect_IndexPixel& BasePixel ) const
{ Handle(Image_PseudoColorImage) ret_image = NULL ;
Handle(Aspect_GenericColorMap) newcmap = NULL ;
Handle(Aspect_ColorMap) cmap = ColorMap() ;
TColStd_SetOfInteger PixelSet ;
TColStd_SetIteratorOfSetOfInteger It;
Standard_Integer x, y, i, UpX, UpY ;
// Aspect_IndexPixel aPixel ;
Image_LookupTable aLookup( 101 ) ;
Aspect_ColorMapEntry aEntry;
UpX = UpperX() ;
UpY = UpperY() ;
for ( y = LowerY() ; y <= UpY ; y++ ) {
for ( x = LowerX() ; x <= UpX ; x++ ) {
PixelSet.Add( Pixel( x, y ).Value() ) ;
}
}
#ifdef TRACE
cout << "Squeeze() PixelSet Extent :" << PixelSet.Extent() << endl ;
#endif
if ( PixelSet.Extent() != 0 ) {
newcmap = new Aspect_GenericColorMap() ;
for (It.Initialize(PixelSet), i = BasePixel.Value() ;
It.More(); It.Next(), i++ ) {
aLookup.Bind( It.Value(), i ) ;
aEntry.SetValue( i, cmap->FindEntry( It.Value() ).Color() ) ;
newcmap->AddEntry( aEntry ) ;
}
ret_image = new Image_PseudoColorImage( LowerX(), LowerY(),
Width() , Height(),
newcmap );
ret_image->Fill( this ) ;
ret_image->Lookup( aLookup ) ;
}
return( ret_image ) ;
}
void Image_PseudoColorImage::Lookup( const Image_LookupTable& aLookup )
{ Standard_Integer x,y, UpX, UpY;
Aspect_IndexPixel val, lastval, newval;
UpX = UpperX() ;
UpY = UpperY() ;
val = Pixel( LowerX(), LowerY() ) ;
lastval = val ;
newval = aLookup.Find( lastval ) ;
for ( y = LowerY() ; y <= UpY ; y++ ) {
for ( x = LowerX() ; x <= UpX ; x++ ) {
val = Pixel( x, y ) ;
if ( !(val == lastval) ) {
lastval = val ;
newval = aLookup.Find( lastval ) ;
}
SetPixel( x, y , newval ) ;
}
}
}
void Image_PseudoColorImage::Rescale( const Standard_Real Scale,
const Standard_Real Offset )
{ Standard_Real S = Scale ;
Standard_Real O = Offset ;
Standard_Integer x,y, UpX, UpY, val;
UpX = UpperX() ;
UpY = UpperY() ;
for ( y = LowerY() ; y <= UpY ; y++ ) {
for ( x = LowerX() ; x <= UpX ; x++ ) {
val = ( Standard_Integer ) ( Pixel(x, y).Value() * S + O ) ;
MutPixel( x, y ).SetValue( val ) ;
}
}
}
void Image_PseudoColorImage::Extrema( Aspect_IndexPixel& PMin,
Aspect_IndexPixel& PMax ) const
{ Standard_Integer x,y, UpX, UpY, min, max, val, lastval;
// Aspect_IndexPixel aPixel ;
UpX = UpperX() ;
UpY = UpperY() ;
max = IntegerFirst() ;
min = IntegerLast() ;
lastval = Pixel( LowerX(), LowerY() ).Value() ;
max = Max( max, lastval ) ;
min = Min( min, lastval ) ;
for ( y = LowerY() ; y <= UpY ; y++ ) {
for ( x = LowerX() ; x <= UpX ; x++ ) {
val = Pixel( x, y ).Value();
if ( val != lastval ) {
lastval = val ;
max = Max( max, lastval ) ;
min = Min( min, lastval ) ;
}
}
}
PMin.SetValue( min ) ;
PMax.SetValue( max ) ;
}
void Image_PseudoColorImage::Threshold( const Aspect_IndexPixel& PMin,
const Aspect_IndexPixel& PMax,
const Aspect_IndexPixel& PMap )
{ Standard_Integer x,y, UpX, UpY, min, max, val, map ;
Aspect_IndexPixel ThePixel ;
UpX = UpperX() ;
UpY = UpperY() ;
max = PMax.Value() ;
min = PMin.Value() ;
map = PMap.Value() ;
for ( y = LowerY() ; y <= UpY ; y++ ) {
for ( x = LowerX() ; x <= UpX ; x++ ) {
ThePixel = Pixel( x, y ) ;
val = Pixel( x, y ).Value();
if ( val >= min && val <= max ) {
MutPixel( x, y ).SetValue( map ) ;
}
}
}
}
#ifdef OLD
Handle(Standard_Transient) Image_PseudoColorImage::ShallowCopy() const {
return DeepCopy() ;
}
Handle(Standard_Transient) Image_PseudoColorImage::DeepCopy() const {
return Dup() ;
}
#endif

View File

@ -29,7 +29,7 @@ package MeshVS
uses
Quantity, AIS, PrsMgr, Prs3d, SelectMgr, TColStd, SelectBasics,
Graphic3d, gp, TCollection, Bnd, TColgp, Select3D, TopLoc, Aspect, AlienImage
Graphic3d, gp, TCollection, Bnd, TColgp, Select3D, TopLoc, Aspect
is
---Purpose: The integer keys for most useful constants attuning mesh presentation appearence

View File

@ -31,7 +31,6 @@
#include <Handle_TColStd_HArray1OfReal.hxx>
#include <Quantity_PlaneAngle.hxx>
#include <Quantity_NameOfColor.hxx>
#include <Handle_AlienImage_AlienImage.hxx>
#include <Handle_OpenGl_View.hxx>
#include <Handle_OpenGl_Workspace.hxx>
@ -74,7 +73,6 @@ class Quantity_Color;
class Graphic3d_Vertex;
class Aspect_Array1OfEdge;
class TCollection_ExtendedString;
class AlienImage_AlienImage;
class Image_PixMap;
class TColStd_HArray1OfReal;
class Handle(OpenGl_Workspace);

View File

@ -2,7 +2,6 @@ Aspect
InterfaceGraphic
SelectBasics
Xw
AlienImage
Image
WNT
Cocoa

View File

@ -129,7 +129,6 @@ uses
TransientManager from Visual3d,
TypeOfTriedronEcho from Aspect,
TypeOfTriedronPosition from Aspect,
FormatOfSheetPaper from Aspect,
RenderingContext from Aspect,
GraphicCallbackProc from Aspect,
FillMethod from Aspect,