Oracle8 Server Image Cartridge User's Guide
Release 8.0.3

A50580_2

Library

Product

Contents

Index

Prev Next

3
Image Object Types and Procedures

Oracle8 Server Image Cartridge consists of two object data types:

The cartridge consists of four user-visible procedures as well:

When you are storing or copying images, you must first create an empty BLOB in the table. The examples in this chapter assume that the following table, ordimgtab, has been created to store three images. Three empty rows have been created as follows:

create table ordimgtab(col1 number, col2 ORDSYS.ORDImgB);
grant select, update on ordimgtab to ordsys;
insert into ordimgtab values
(1, ORDSYS.ORDImgB(empty_blob(), NULL, NULL, NULL, NULL, NULL, NULL));
insert into ordimgtab values
(2, ORDSYS.ORDImgB(empty_blob(), NULL, NULL, NULL, NULL, NULL, NULL));
insert into ordimgtab values
(3, ORDSYS.ORDImgB(empty_blob(), NULL, NULL, NULL, NULL, NULL, NULL));
insert into ordimgtab values
commit;

ORDImgB ODT

The ORDImgB object data type (ODT) is used for basic storage and retrieval of image data within an Oracle database. This object data type is defined as follows:

CREATE TYPE ORDImgB AS OBJECT
(
-------------------
-- TYPE ATTRIBUTES
-- 
-- content: Image data
-- height:  Height of the image in pixels 
-- width:   Width of image in pixels
-- contentLength: Size of the "on disk" image file in bytes
-- fileFormat:        File type of image (such as TIFF, JFIF) 
-- contentFormat:     Type of image (such as monochrome, 8-bit gray scale)
-- compressionFormat: Compression type of image 

content             BLOB,
height              INTEGER,  
width               INTEGER,
contentLength       INTEGER,
fileFormat          VARCHAR2(64),
contentFormat       VARCHAR2(64),
compressionFormat   VARCHAR2(64),
----------------
-- METHOD DECLARATION
-- 	
  MEMBER PROCEDURE copyContent(dest IN OUT ORDImgB),
-- Image data processing methods 
  MEMBER PROCEDURE setProperties(SELF IN OUT ORDImgB),	
  MEMBER PROCEDURE process    (SELF    IN OUT ORDImgB,
                               command  IN     VARCHAR2)
  MEMBER PROCEDURE processCopy(command  IN     VARCHAR2,
                               dest     IN OUT BLOB)
);
------- End Type Declaration

ORDImgF ODT

The ORDImgF object data type is used for retrieval of image data stored in external files. BFILE images are assumed to be read-only and this is reflected in the member procedures defined on the object data type.

CREATE TYPE ORDImgF AS OBJECT
(
  -------------------
-- TYPE ATTRIBUTES
-- content: Image data
-- height:            Height of the image in pixels 
-- width:             Width of image in pixels
-- contentLength:     Size of the "on disk" image file in bytes
-- fileFormat:        File type of image (such as TIFF, JFIF) 
-- contentFormat:     Type of image (such as monochrome, 8-bit gray scale)
-- compressionFormat: Compression type of image 
  
content             BFILE,
height              INTEGER,  
width               INTEGER,
contentLength       INTEGER,
fileFormat          VARCHAR2(64),
contentFormat       VARCHAR2(64),
compressionFormat   VARCHAR2(64),

----------------
-- METHOD DECLARATION
-- 	
MEMBER PROCEDURE copyContent(dest IN OUT ORDImgB),
-- Image data processing methods 
MEMBER PROCEDURE setProperties(SELF IN OUT ORDImgF),

MEMBER PROCEDURE processCopy(command IN VARCHAR2,   
                             dest    IN OUT BLOB)
);
------- End Type Declaration

copyContent Procedure

Format

copyContent (dest IN OUT BLOB);

Description

Copy an image without changing it.

Parameters

dest

The destination of the new image.

Usage

Copies the image data into the supplied BLOB.

Example

Create a copy of the image in type image1 into a BLOB called myblob:

image1.copyContent(myblob);


process Procedure

Format

process (command IN VARCHAR2 );

Description

Perform one or more image processing techniques on a BLOB, writing the image back on itself.

Parameters

command

A list of image processing changes to make for the image.

Usage

Change one or more of the image attributes shown in the following table:

Table 3-1 Image Processing Parameters
Parameter Name   Usage   Values  

fileFormat  

file format of the image  

GIFF, TIFF, PCXF, PICT, RASF, CALS, BMPF, TGAF, JFIF  

contentFormat  

imagetype/pixel/data format.  

MONOCHROME, RAW,

4BITGRAYSCALE, 4BITGREYSCALE,

8 BITGRAYSCALE, 8 BITGREYSCALE,

1BITLUT, 2BITLUT, 4 BITLUT, 8BITLUT,

16BITRGB, 24BITRGB, 32BITRGB,

24BITPLANAR  

scale  

scale factor (for example, 0.5 or 2.0)  

<FLOAT> positive  

xscale  

X-axis scale factor (default is 1)  

<FLOAT> positive  

yscale  

Y-axis scale factor (default is 1)  

<FLOAT> positive  

compressionQuality  

compression quality  

MAXCOMPRATIO, MAXINTEGRIT,

LOWCOMP, MEDCOMP, HIGHCOMP  

compressionFormat  

compression type/format  

JPEG, SUNRLE, BMPRLE, TARGARLE, LZW, LZWHDIFF, FAX3, FAX4, HUFFMAN3, Packbits, GIFLZW  

byteOrder  

endian format  

INTEL, MOTOROLA  

bitOrder  

bits number 1-to-N or N-to-1  

LSB, MSB  

bmpOrder  

bitmap order  

NORMAL, INVERSE_DIB  

bmpFormat  

bitmap format  

WINDOWS, OS2  

cut  

Window to cut or crop (origin.x origin.y width height)  

(Integer Integer Integer Integer) limit < 65535  

Note:

When specifying parameter values that include floatingpoint numbers, you must use double quotation marks (" ") around the value. If you do not, this may result in incorrect values being passed and you will get incorrect results.  

Examples

Change the file format of image1 to GIF:

image1.process('fileFormat=GIFF');

Change image1 to use lower quality JPEG compression and double the length of the image along the X-axis:

image1.process('compressionFormat=JPEG, compressionQuality=LOWCOMP, 
xscale="2.0"'); 

processCopy Procedure

Format

processCopy (command IN VARCHAR2,

dest IN OUT BLOB);

Description

Copy an image BLOB to another BLOB.

Function Parameters

command

A list of image processing changes to make for the image in the new copy.

dest

The destination of the new image.

Usage

See Table 3-1, "Image Processing Parameters".

Example

Copy an image, changing the file format, compression format, and data format in the destination image:

create or replace procedure is 
 imgB1     ORDSYS.ORDImgB; 
 imgB4     ORDSYS.ORDImgB; 
 mycommand   VARCHAR2(400); 
begin 
select col2 into imgB1 from ordimgtab  where col1 = 1; 
select col2 into imgB4 from ordimgtab  where col1 = 4 for update; 
command:= 'fileFormat=tiff compressionFormat = packbits 
contentFormat = 8bitlut'; 
imgB1.processcopy(mycommand,imgB4.content); 
imgB4.setproperties;
end; 

setProperties Procedure

Format

setProperties();

Description

Write the characteristics of an image (BLOB or BFILE) into the appropriate attribute fields.

Parameters

None

Usage

After you have copied or stored an image, call this procedure to set the current characteristics of the new content.

This procedure sets the following information about an image:

Example

Select the type, and then set the attributes using the setProperties procedure.

imgB1 ORDSYS.imgB;
.
.
.
select col2 into imgB1 from ordimgtab where col1 = 1 for update;
imgB1.setProperties;
dbms_output.put_line('image width = '|| imgB1.width );
dbms_output.put_line('image height = '|| imgB1.height );
dbms_output.put_line('image size = '|| imgB1.contentLength );
dbms_output.put_line('image file type = '|| imgB1.fileFormat );
dbms_output.put_line('image type = '|| imgB1.contentFormat );
dbms_output.put_line('image compression = '|| imgB1.compressionFormat );

Example output:

image width = 360
image height = 490
image size = 59650
image file type = JFIF
image type = 24BITRGB
image compression = JPEG




Prev

Next
Oracle
Copyright © 1997 Oracle Corporation.

All Rights Reserved.

Library

Product

Index