Jump to content

  • Log In with Google      Sign In   
  • Create Account

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.

Keyboard input help (C++)

04 September 2010 - 06:29 AM

I'm having a little trouble getting my event system to detect keyboard input.
Basically, I have this which runs once per main loop iteration..

void HVSTInput::CkeyboardTrigger::update()
{
pollKeys();
//keydown events
for(int i = 0; i < 46; i++)
{
if (_keyboard[i]->getKeyState() == 1)
_events[0]->keyStrokesDown.add(_keyboard[i]->getKey());
}

if (_events[0]->keyStrokesDown.count() > 0)
{
try
{
signalHandler(_events[0]);
}
catch (const char * error)
{
//do something..
}
}
}


pollKeys looks like this..

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


aand setKeyState..

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


Pretty much it just isn't picking up any of my keystrokes. I'm assuming it's because I'm not fully understanding how GetKeyState works. Am I using this properly, and if not, what would be the best way to handle this? My last ditch resort is working in WM_KEYDOWN and KEYUP events, but I want to see if there's another way to do it first.

glutKeyboardFunc() problems

26 August 2010 - 09:45 AM

I'm having some problems with this and the parameter, it's not allowing me to pass a function to it.

#include "inputManager.h"

CkeyboardTrigger * CkeyboardTrigger::_singleton;

CkeyboardTrigger::CkeyboardTrigger()
{
CBaseEvent * keyDown = new CBaseEvent();
CBaseEvent * keyUp = new CBaseEvent();
CBaseEvent * mouseClick = new CBaseEvent();
CBaseEvent * mouseRelease = new CBaseEvent();

_addEvent(keyDown);
_addEvent(keyUp);
_addEvent(mouseClick);
_addEvent(mouseRelease);

glutKeyboardFunc(_keyboard);
}

void CkeyboardTrigger::_keyboard(unsigned char key, int x, int y)
{

}

CkeyboardTrigger * CkeyboardTrigger::initialize()
{
if (!_singleton)
_singleton = new CkeyboardTrigger();

return _singleton;
}

CkeyboardTrigger::~CkeyboardTrigger()
{
if (_singleton)
delete _singleton;
}


the constructor and the _keyboard function is the part in question...
The error I'm getting back is

error C3867: 'CkeyboardTrigger::_keyboard': function call missing argument list; use '&CkeyboardTrigger::_keyboard' to create a pointer to member

I tried what it said and put the &CkeyboardTrigger::_keyboard infront of it, but got no luck. Am I missing something here? I looked up the error code as well and found nothing that would compile.

PARTNERS