Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

Oni Sephiroth

Member Since 07 Mar 2006
Offline Last Active Sep 27 2011 06:13 PM
-----

Topics I've Started

[FreeImage] Unable to create FIBITMAP * from memory stream

20 September 2011 - 04:48 PM

I'm trying to create an FIBITMAP from an unsigned char array. I have verified that the data is correct by writing it to a file on the harddrive and opening it with an image viewer. However, for some reason I can't get the bitmap to be created. The memory stream is created, but the bitmap comes out null every time. Here's what I'm working with...

unsigned char * CSpriteX::loadImageFile(CFileData *image, IMAGEFILE *imgFile, GLuint &texture)

{

	FREE_IMAGE_FORMAT fif = FreeImage_GetFIFFromFilename(image->getName().c_str());

	FIMEMORY * stream = 0;

	unsigned char tempRGB;

	GLuint tempTex = 0;

	GLenum errCode;

	bool error = false;



	stream = FreeImage_OpenMemory(image->getData());



	if(FreeImage_FIFSupportsReading(fif))

	imgFile->dib = FreeImage_LoadFromMemory(fif, stream);



	if(!imgFile->dib)

		return NULL;


The rest of the function should be unneeded. The type of image->getData() is unsigned char * and returns a pointer to the first element of my image data. imgFile->dib is type FIBITMAP *.

EDIT: Disregard this, I fixed it.

FreeImage - bitmap from memory C++

22 May 2011 - 10:30 AM

Basically, in a nutshell, I have an archive of resources (not a standard archive, one I wrote myself).  Let's say for example I pull a .png file out of that archive and into a char array.  So, the ENTIRE image file is in that array, including the header.  I need to get the image data into a dib.  I looked around and found this function:

FreeImage_LoadFromHandle(FREE_IMAGE_FORMAT fif, FreeImageIO *io, fi_handle handle, int flags FI_DEFAULT(0));


Could I use this to get what I need?  For example...


Assume that fif, io and image are declared and initialized.  image is the char array of image data.

FIBITMAP* dib = FreeImage_LoadFromHandle(fif, &io, (fi_handle)image, 0);

unsigned char * bits = FreeImage_GetBits(dib);


GetKeyState() problem

01 October 2010 - 04:04 AM

I'm having some trouble getting GetKeyState() to work properly. I need it to detect letters and numbers, which it's not doing. It detects the enter key, caps lock, shift, tab, etc but nothing for letters and numbers. Here's what I'm doing..

void HVSTInput::CkeyboardTrigger::pollKeys()
{
for (int i = 0; i < 128; i++)
{
_keyboard[i]->setKeyState();
}
}


First there's this, which runs from 0 to 127, checking 128 different "keys."

void HVSTInput::CKey::setKeyState()
{
_previousState = _currentState;
_currentState = GetKeyState(_key);
}


Then this just sets the state of the key using GetKeyState, where _key == i from the loop in pollKeys() method. Now I've looked on MSDN which says to use the ascii value for letters and numbers, which is what I thought I was doing here. Yet, only the keys that I mentioned above are actually triggering.

PARTNERS