Пример #1
0
/**
Reads a TRofsEntry from the current file position within the core image.

@param aEntry memory to be used for reading the data from the file. This is only valid if the size returned is greater than zero
@return size of the entry read
*/
TInt RCoreImageReader::ReadRofEntry(TRofsEntry& aEntry)
	{
	// need to work out how big entry needs to be from the Struct Size
	// in TRofsEntry
	int itemsRead = fread(&aEntry.iStructSize, sizeof(TUint16), 1, iCoreImage);
	int result = ImageError(itemsRead, 1, "Read Entry Size");
	if (result == KErrNone)
		{
		// read rest of entry excluding the iStructSize
		itemsRead = fread(&aEntry.iUids[0], sizeof(TRofsEntry) -sizeof(TUint16), 
				          1, iCoreImage);
		result = ImageError(itemsRead, 1, "Rest of Entry");
		// return length read - this include includes iStructSize and first char of name
		if (result == KErrNone)
			return sizeof(TRofsEntry);	
		}
	return 0;
	}
Пример #2
0
/** 
Reads the 4 byte image type identifier from the core image file.

@return KErrNone for successful read or error number if failed 
*/
TInt RCoreImageReader::ReadIdentifier()
	{
	int itemsRead = fread(&iIdentifier, sizeof(TUint8), K_ID_SIZE, iCoreImage);
	TInt result = ImageError(itemsRead,  K_ID_SIZE, "Read Identifier");
	if (result != KErrNone)
		{
		iIdentifier[0] = 0;
		}
	return result;
	}
Пример #3
0
/**
Reads a directory entry from the current position in the core image file. This
method does not read the variable length TRofsEntry part of the directory entry.
TRofsEntry does not exist for all directory entries. This is read later by 
other methods

@param aDir memory where the directory entry is read from the file. This is only valid if KErrNone is returned.
@return KErrNone for successful read or error number if failed 
*/
TInt RCoreImageReader::ReadDirEntry(TRofsDir& aDir)
	{
	// read directory without the associated TRofsEntry. The TRofsEntry 
	// is read later when handling subdirectories
	int bytesRead = sizeof(TRofsDir) - sizeof(TRofsEntry);
	int itemsRead = fread (&aDir, bytesRead , 1, iCoreImage);
	if (ImageError(itemsRead, 1, "Read Dir") == KErrNone)
		return bytesRead;
	else
		return 0;
	}
Пример #4
0
/**
Reads the extension header from the image file.

@param aHeader space for the header read from the file. Only valid if KErrNone is returned.
@return KErrNone for successful read or error number if failed 
*/
TInt RCoreImageReader::ReadExtensionHeader(TExtensionRofsHeader& aHeader)
	{
	int itemsRead = fread (&aHeader.iHeaderSize, 
			(sizeof(TExtensionRofsHeader)) - K_ID_SIZE*sizeof(TUint8), 1, iCoreImage);
	TInt result = ImageError(itemsRead, 1, "Read Extension Header");
	if (result == KErrNone)
		{
		// copy the previously read identifier into the header
		for (int i=0; i<K_ID_SIZE; i++)
			aHeader.iIdentifier[i] = iIdentifier[i];
		}
	return result;
	}
Пример #5
0
ImageView<T> ImageView<T>::subImage(const Bounds<int>& bounds) const 
{
    if (!this->_data) throw ImageError("Attempt to make subImage of an undefined image");
    if (!this->_bounds.includes(bounds)) {
        FormatAndThrow<ImageError>() << 
            "Subimage bounds (" << bounds << ") are outside original image bounds (" << 
            this->_bounds << ")";
    }
    T* newdata = this->_data
        + (bounds.getYMin() - this->_bounds.getYMin()) * this->_stride
        + (bounds.getXMin() - this->_bounds.getXMin());
    return ImageView<T>(newdata,this->_owner,this->_stride,bounds,this->_scale);
}
Пример #6
0
Image<T>::Image(int ncol, int nrow, double scale, T init_value) :
    BaseImage<T>(Bounds<int>(1,ncol,1,nrow), scale) 
{
    if (ncol <= 0 || nrow <= 0) {
        std::ostringstream oss(" ");
        if (ncol <= 0) {
            if (nrow <= 0) {
                oss << "Attempt to create an Image with non-positive ncol ("<<
                    ncol<<") and nrow ("<<nrow<<")";
            } else {
                oss << "Attempt to create an Image with non-positive ncol ("<<
                    ncol<<")";
            }
        } else {
            oss << "Attempt to create an Image with non-positive nrow ("<<
                nrow<<")";
        }
        throw ImageError(oss.str());
    }
    fill(init_value);
}
Пример #7
0
/**
Reads a name of the specified length from the core image file.

@param aName memory for the name read from the file. Only valid if KErrNone is returned
@param aLength length of name to be read
@return KErrNone for successful read or error number if failed 
*/
TInt RCoreImageReader::ReadRofEntryName(TUint16* aName, int aLength)
	{
	int itemsRead = fread(aName, sizeof(TUint16), aLength, iCoreImage);
	return ImageError(itemsRead, aLength, "Rof Entry Name");
	}
Пример #8
0
void ImageView<T>::copyFrom(const BaseImage<T>& rhs) const
{
    if (!this->_bounds.isSameShapeAs(rhs.getBounds()))
        throw ImageError("Attempt im1 = im2, but bounds not the same shape");
    transform_pixel(*this, rhs, ReturnSecond<T>());
}
Пример #9
0
const T& Image<T>::at(const int xpos, const int ypos) const
{
    if (!this->_data) throw ImageError("Attempt to access values of an undefined image");
    if (!this->_bounds.includes(xpos, ypos)) throw ImageBoundsError(xpos, ypos, this->_bounds);
    return this->_data[this->addressPixel(xpos, ypos)];
}