Click or drag to resize

DbImageSource Class

A DbImageSource is a sub-class of ImageSource that allows you read-only access to images stored in a database.
Inheritance Hierarchy
SystemObject
  Atalasoft.ImagingImageSource
    Atalasoft.ImagingRandomAccessImageSource
      Atalasoft.Imaging.ImageSourcesDbImageSource

Namespace:  Atalasoft.Imaging.ImageSources
Assembly:  Atalasoft.dotImage (in Atalasoft.dotImage.dll) Version: 11.4.0.9.0.377 (.NET 4.5.2, x86)
Syntax
[SerializableAttribute]
public class DbImageSource : RandomAccessImageSource, 
	ISerializable, IImageStreamSource

The DbImageSource type exposes the following members.

Constructors
  NameDescription
Public methodDbImageSource(IDbImageAccessor)
Creates a DbImageSource from a IDbImageAccessor implementor.
Protected methodDbImageSource(SerializationInfo, StreamingContext)
Deserialize this object from the info and context.
Public methodDbImageSource(IDbImageAccessor, Boolean)
Creates a DbImageSource from a IDbImageAccessor implementor.
Top
Properties
  NameDescription
Protected propertyActiveImages
Gets the active images.
(Inherited from ImageSource.)
Public propertyCount
Returns the total number of images in the image source.
(Inherited from RandomAccessImageSource.)
Protected propertyCulledImages
Gets the culled images.
(Inherited from ImageSource.)
Public propertyCurrent
Returns the index of the current image.
(Inherited from ImageSource.)
Public propertyDbAccessor
The accessor used to get to the database. This class supports changing the accessor, but if you change anything about the connected accessor, you are responsible for calling Reset() on the image source.
Public propertyDoAllFrames
Whether to include all of the frames as individual images in the source.
Public propertyImmediateUnload
Determines if an image should be unloaded from memory immediately.
(Inherited from ImageSource.)
Public propertyItem
Acquires the image at location i within the image source and returns it.
(Inherited from RandomAccessImageSource.)
Public propertyMemoryInUse
Returns an estimate of the number of bytes of memory currently in use by images in this ImageSource.
(Inherited from ImageSource.)
Public propertyMemoryLimit
This sets the limit for memory usage for this ImageSource. If memory usage goes beyond this, images will be dropped from memory until memory usage is below the limit.
(Inherited from ImageSource.)
Public propertyTotalImages
Returns the total number of available images in this ImageSource.
(Inherited from ImageSource.)
Public propertyTotalImagesKnown
Gets a value indicating whether or not the total number of images in this image source can be known.
(Inherited from ImageSource.)
Top
Methods
  NameDescription
Public methodAcquire(Int32) Obsolete.
This method has been deprecated. Use ReAcquire(AtalaImage) instead.
(Inherited from ImageSource.)
Public methodAcquire(AtalaImage) Obsolete.
This method has been deprecated. Use ReAcquire(AtalaImage) instead.
(Inherited from ImageSource.)
Public methodAcquireNext
Acquire the next available image from the ImageSource.
(Inherited from ImageSource.)
Protected methodAllImagesAreReleased
Determines if all the images have been released.
(Inherited from ImageSource.)
Protected methodCalculateNumPagesPerImage
Calculates and caches the number of frames per image and the image count.
Public methodContainsImage
Determines whether this ImageSource contains the specified image.
(Inherited from ImageSource.)
Protected methodCullNode
Culls the node from the ImageSource
(Inherited from ImageSource.)
Protected methodCullReleasedImages
Culls all released images.
(Inherited from ImageSource.)
Public methodDispose
Free up resources used by this ImageSource
(Inherited from ImageSource.)
Protected methodDispose(Boolean)
Releases unmanaged and - optionally - managed resources.
(Inherited from ImageSource.)
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Finalizes an instance of the ImageSource class.
(Inherited from ImageSource.)
Protected methodFind
Finds the specified image.
(Inherited from ImageSource.)
Public methodFlush
Flush all released images out of memory.
(Inherited from ImageSource.)
Public methodGetFrameCountInImage
Returns the number of frames in the image that will be served by this image source. If DoAllFrames is false, this function always returns 1.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetImageNumAndFrame
Caclulates the image number and frame number given an image source index.
Public methodGetImageStream
Gets the stream and the frame within that stream that corresponds to the passed in index. The caller is responsible for closing the returned stream.
Public methodGetObjectData
Get the data to serialize for this object.
(Overrides RandomAccessImageSourceGetObjectData(SerializationInfo, StreamingContext).)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodHasMoreImages
Determines if there are more images to load.
(Inherited from ImageSource.)
Protected methodLowLevelAcquire
Acquires the image at the given image source index.
(Overrides RandomAccessImageSourceLowLevelAcquire(Int32).)
Protected methodLowLevelAcquireNextImage
Acquire the next image in the source.
(Overrides ImageSourceLowLevelAcquireNextImage.)
Protected methodLowLevelDispose
Disposes any non-GC objects used by this class.
(Overrides ImageSourceLowLevelDispose.)
Protected methodLowLevelFlushOnReset
Returns true to indicate that a Reset() should flush all images
(Overrides ImageSourceLowLevelFlushOnReset.)
Protected methodLowLevelHasMoreImages
Returns true if AcquireNext would return an image
(Overrides ImageSourceLowLevelHasMoreImages.)
Protected methodLowLevelReplaceImage
Not implemented for this image source. Will throw NotImplementedException.
(Overrides ImageSourceLowLevelReplaceImage(ImageSourceNode, AtalaImage).)
Protected methodLowLevelReset
Empties any cached data about the images
(Overrides ImageSourceLowLevelReset.)
Protected methodLowLevelSkipNextImage
Increments the internal index so that AcquireNext would skip an image
(Overrides ImageSourceLowLevelSkipNextImage.)
Protected methodLowLevelTotalImages
The total number of images in the image source
(Overrides ImageSourceLowLevelTotalImages.)
Protected methodLowLevelTotalImagesKnown
Returns if the total images is known.
(Inherited from RandomAccessImageSource.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodNotifyChangedImage(AtalaImage)
This method is used to inform an ImageSource that one of its current acquired images has changed.
(Inherited from ImageSource.)
Public methodNotifyChangedImage(AtalaImage, AtalaImage)
This method is used to inform an ImageSource that one of its current acquired images has changed.
(Inherited from ImageSource.)
Protected methodOnChangedImage
Raises the [E:ChangedImage] event.
(Inherited from ImageSource.)
Protected methodOnNodeIndexSet
This method is called from the RandomAccessImageSource indexer after it has set the ImageSourceNode.Index value.
(Inherited from RandomAccessImageSource.)
Protected methodOnReleasing
Called when Release(AtalaImage) was performed on an ImageSourceNode.
(Inherited from ImageSource.)
Public methodReAcquire(Int32)
Acquire a previous image by index.
(Inherited from ImageSource.)
Public methodReAcquire(AtalaImage)
Acquire an AtalaImage that has been previously acquired.
(Inherited from ImageSource.)
Public methodRelease
Release a previously acquired image.
(Inherited from ImageSource.)
Public methodReleaseChangedImage(AtalaImage)
Release an image that has changed, notifying other clients that the image has changed.
(Inherited from ImageSource.)
Public methodReleaseChangedImage(AtalaImage, AtalaImage)
Release an image that has changed, notifying other clients that the image has changed.
(Inherited from ImageSource.)
Public methodReset
Resets the ImageSource to start over again.
(Inherited from ImageSource.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Events
  NameDescription
Public eventChangedImage
This event is fired whenever an image has been replaced.
(Inherited from ImageSource.)
Public eventReleasing
Raised when the Release(AtalaImage) method is called on an ImageSourceNode.
(Inherited from ImageSource.)
Top
Examples
Using DbImageSource (C#)
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using Atalasoft.Imaging;
using Atalasoft.Imaging.ImageSources;
using Atalasoft.Imaging.ImageSources.Data;

public class DbImageSourceExample
{
    // Gets a SQL Server specific connection to the image database
    public static IDbConnection GetConn()
    {
       return new SqlConnection("Data Source=DBServer;Integrated security=SSPI;Initial Catalog=ImageDatabase;");
    }

    // create an accessor that uses SQL statements
    public DbCommandImageAccessor CreateSqlImageAccessor()
    {
       Hashtable sqlParams = new Hashtable();
       sqlParams["@lower"] = 2;
       sqlParams["@upper"] = 4;
       return new DbSqlImageAccessor(new GetConnectionCallback(GetConn), false, "imageBlob", "id", "images", "id between 2 and 4", null, null, sqlParams );
    }

    // get an image from the database
    public AtalaImage GetImageFromDb(int i)
    { 
       DbImageSource imgSrc = new DbImageSource(CreateSqlImageAccessor());
       return imgSrc[i];
    }
}
Using DbImageSource (Visual Basic)
Imports System.Data
Imports System.Data.SqlClient
Imports System.Collections
Imports Atalasoft.Imaging
Imports Atalasoft.Imaging.ImageSources
Imports Atalasoft.Imaging.ImageSources.Data

Public Class DbImageSourceExample

    ' Gets a SQL Server specific connection to the image database
    Public Shared Function GetConn() As IDbConnection
        Return New SqlConnection("Data Source=DBServer;Integrated security=SSPI;Initial Catalog=ImageDatabase;")
    End Function

    ' create an accessor that uses SQL statements
    Public Function CreateSqlImageAccessor() As DbCommandImageAccessor
        Dim sqlParams As New Hashtable()
        sqlParams("@lower") = 2
        sqlParams("@upper") = 4
        Return New DbSqlImageAccessor(New GetConnectionCallback(AddressOf GetConn), False, "imageBlob", "id", "images", "id between 2 and 4", _
        Nothing, Nothing, sqlParams)
    End Function

    ' get an image from the database
    Public Function GetImageFromDb(ByVal i As Integer) As AtalaImage
        Dim imgSrc As New DbImageSource(CreateSqlImageAccessor())
        Return imgSrc(i)
    End Function

End Class
See Also