Ejemplo n.º 1
0
static mng_bool MNGPLG_CALLBACK callback_processheader(mng_handle mng,mng_uint32 iWidth,mng_uint32 iHeight)
{
	PluginInstance *This;
	This = (PluginInstance*) mng_get_userdata(mng);

	This->diblinesize = (((iWidth * 24)+31)/32)*4;
	This->dibsize = sizeof(BITMAPINFOHEADER) + This->diblinesize*iHeight;
	This->lpdib = calloc(This->dibsize,1);
	This->lpdibinfo = (LPBITMAPINFOHEADER)This->lpdib;
	This->lpdibbits = &This->lpdib[sizeof(BITMAPINFOHEADER)];
	ZeroMemory((void*)This->lpdib,sizeof(BITMAPINFOHEADER));
	This->lpdibinfo->biSize = sizeof(BITMAPINFOHEADER);
	This->lpdibinfo->biWidth = iWidth;
	This->lpdibinfo->biHeight = iHeight;
	This->lpdibinfo->biPlanes = 1;
	This->lpdibinfo->biBitCount = 24;

	mng_set_canvasstyle (mng, MNG_CANVAS_BGR8);

/*	if(This->fhWnd) {
		if((int)iWidth > This->windowwidth || (int)iHeight > This->windowheight) {
			This->scrolling=1;
		}
	} */

	set_scrollbars(This);
	return MNG_TRUE;
}
Ejemplo n.º 2
0
/*
 * Renders an animation frame to the anim's canvas.
 */
void anim_render_canvas(anim *a)
{
	int ret;
	mng_anim *mng;
	obj *o;

	mng = mng_get_userdata(a->mng);
	mng->wait_msecs = 0;
	memset(&mng->start_time, 0, sizeof(struct timeval));

	/* XXX: This is a workaround for what seems to be a bug in libmng.
	 * Either we clear the canvas ourselves, or parts of the previous frame
	 * will remain in it after rendering the current one. */
	memset(mng->canvas, 0, mng->canvas_h * mng->canvas_w * mng->canvas_bytes_pp);
	ret = mng_render_next(a->mng);
	if (ret == MNG_NOERROR) {
		if (a->flags & F_ANIM_ONCE) {
			a->status = F_ANIM_STATUS_DONE;
		} else {
			mng_display_restart(a->mng);
		}
	}

	if (ret == MNG_NOERROR || ret == MNG_NEEDTIMERWAIT) {
		o = container_of(a);
		o->invalid = true;
	}
}
Ejemplo n.º 3
0
static mng_bool
mng_read_data_callback (mng_handle mng_h,
			mng_ptr buffer,
			mng_uint32 bytes_requested,
        		mng_uint32 * bytes_read)
{
    FUNCTION_ENTRY();
    *bytes_read = 0;
    return MNG_FALSE;
  guint available_mng_food;

  GtkMngView * mng_view = GTK_MNG_VIEW (mng_get_userdata (mng_h));

  available_mng_food = mng_view->bytes_to_eat - mng_view->bytes_eaten;
  if (available_mng_food > 0 && mng_view->mng_food != NULL)
    {
      * bytes_read = (mng_uint32) MIN ((mng_uint32) available_mng_food, bytes_requested);
      memcpy (buffer, mng_view->mng_food + mng_view->bytes_eaten, * bytes_read);
      mng_view->bytes_eaten += * bytes_read;
      FUNCTION_EXIT();
      return MNG_TRUE;
    }
  else {
      FUNCTION_EXIT();
    return MNG_FALSE;
  }
}
Ejemplo n.º 4
0
mng_retcode mng_display_restart(mng_handle mngh)
{
	mng_anim *mng = mng_get_userdata(mngh);

	mng->displayed_first = 0;
	return mng_display_reset(mngh);
}
Ejemplo n.º 5
0
static mng_bool mymngwritestream (mng_handle mng, mng_ptr pBuf, mng_uint32 iSize, mng_uint32 *iWritten)
{
	mngstuff *mymng = (mngstuff *)mng_get_userdata(mng);
	// write it
	*iWritten = mymng->file->Write (pBuf, 1, iSize);
	return MNG_TRUE;
}
Ejemplo n.º 6
0
static mng_ptr MNG_DECL my_getcanvasline(mng_handle handle, mng_uint32 linenr)
{
	Mng *mng;

	mng = (Mng *)mng_get_userdata(handle);
	return mng->buffer + linenr * mng->surface->w * 3;
}
Ejemplo n.º 7
0
static mng_bool fb_mng_settimer(mng_handle handle, mng_uint32 msecs)
{
	mng_anim *mng = mng_get_userdata(handle);

	mng->wait_msecs = msecs;
	return MNG_TRUE;
}
Ejemplo n.º 8
0
////////////////////////////////////////////////////////////////////////////////
// feed data to the decoder
static mng_bool mymngreadstream(mng_handle mng, mng_ptr buffer, mng_uint32 size, mng_uint32 *bytesread)
{
	mngstuff *mymng = (mngstuff *)mng_get_userdata(mng);
	// read the requested amount of data from the file
	*bytesread = mymng->file->Read( buffer, sizeof(BYTE), size);
	return MNG_TRUE;
}
Ejemplo n.º 9
0
static mng_bool MNG_DECL my_settimer(mng_handle handle, mng_uint32 msecs)
{
	Mng *mng = (Mng *)mng_get_userdata(handle);
	mng->ticks = GetTicks() + msecs;

	return MNG_TRUE;
}
Ejemplo n.º 10
0
static mng_bool fb_mng_closestream(mng_handle handle)
{
	mng_anim *mng = mng_get_userdata(handle);

	mng->open = 0;
	return MNG_TRUE;
}
Ejemplo n.º 11
0
static mng_bool MNGPLG_CALLBACK callback_refresh (mng_handle mng, mng_uint32 iLeft, mng_uint32 iTop,
                       mng_uint32 iRight, mng_uint32 iBottom)
{
	PluginInstance *This;
	RECT rect;

	This = (PluginInstance*) mng_get_userdata(mng);

	if(This->loadstate<STATE_VALIDFRAME) {
		This->loadstate=STATE_VALIDFRAME;
	}

	if(This->fhWnd) {
		if(This->paintedyet) {
			rect.left= iLeft      - This->xscrollpos;
			rect.top= iTop        - This->yscrollpos;
			rect.right= iLeft+iRight;
			rect.bottom= iTop+iBottom;

			InvalidateRect(This->fhWnd,&rect,FALSE);
		}
		else {
			// Make sure the first paint clears the whole plugin window
			InvalidateRect(This->fhWnd,NULL,TRUE);
			This->paintedyet=1;
		}
		UpdateWindow(This->fhWnd);
	}
	return MNG_TRUE;
}
Ejemplo n.º 12
0
/**
 * \brief MNG library callback: Get how many milliseconds have passed.
 * \param[in] h_mng MNG library image handle
 * \return global time in milliseconds
 */
static mng_uint32 demux_mng_gettickcount(mng_handle h_mng)
{
    mng_priv_t * mng_priv = mng_get_userdata(h_mng);

    // return current global time
    return mng_priv->global_time_ms;
}
Ejemplo n.º 13
0
mng_bool MNG_DECL
CMNGAnimation::CB_SetTimer(mng_handle handle, mng_uint32 msecs)
{
  CMNGAnimation* This = (CMNGAnimation*)mng_get_userdata(handle);
  This->m_delay = msecs;
  return MNG_TRUE;
}
Ejemplo n.º 14
0
mng_bool MNG_DECL
CMNGAnimation::CB_ReadData(mng_handle handle, mng_ptr buf, mng_uint32 len, mng_uint32p read)
{
  CMNGAnimation* This = (CMNGAnimation*)mng_get_userdata(handle);
  *read = This->m_file->Read(buf, len);
  return MNG_TRUE;
}
Ejemplo n.º 15
0
static mng_bool MNG_DECL my_processheader(mng_handle handle, mng_uint32 width,
	mng_uint32 height)
{
	Uint32 Rmask;
	Uint32 Gmask;
	Uint32 Bmask;
	mng_imgtype type;
	Mng *mng;
#ifdef USE_OPENGL
	unsigned w;
	unsigned h;
#endif

	type = mng_get_sigtype(handle);
	if (type != mng_it_mng) {
		return TRUE;
	}

	mng = (Mng *)mng_get_userdata(handle);

#ifdef USE_OPENGL
	for (w = 1; w < width; w <<= 1) {
	}
	for (h = 1; h < height; h <<= 1) {
	}
	mng->texture_width = (float)width / w;
	mng->texture_height = (float)height / h;
	glGenTextures(1, &mng->texture_name);
	glBindTexture(GL_TEXTURE_2D, mng->texture_name);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
#endif

	// Allocate the SDL surface to hold the image
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
	Rmask = 0x000000FF;
	Gmask = 0x0000FF00;
	Bmask = 0x00FF0000;
#else
	Rmask = 0xFF000000 >> 8;
	Gmask = 0x00FF0000 >> 8;
	Bmask = 0x0000FF00 >> 8;
#endif

	mng->buffer = new unsigned char[width * height * 3];
	memset(mng->buffer, width * height * 3, sizeof(unsigned char));

	mng->surface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height,
		8 * 3, Rmask, Gmask, Bmask, 0);
	if (mng->surface == NULL) {
		fprintf(stderr, "Out of memory");
		ExitFatal(1);
	}

	return MNG_TRUE;
}
Ejemplo n.º 16
0
static mng_bool MNG_DECL my_processmend(mng_handle handle, mng_uint32 iterationsdone,
										mng_uint32)
{
	Mng *mng = (Mng *)mng_get_userdata(handle);
	mng->iteration = iterationsdone;

	return MNG_TRUE;
}
Ejemplo n.º 17
0
mng_bool ImageJngFile::cb_settimer (mng_handle hHandle, mng_uint32 iMsecs)
{
  ImageJngFile *this_ = (ImageJngFile *)mng_get_userdata (hHandle);

  this_->timer = iMsecs;

  return MNG_TRUE;
}
Ejemplo n.º 18
0
mng_ptr ImageJngFile::cb_getcanvasline (mng_handle hHandle, mng_uint32 iLineNr)
{
  ImageJngFile *this_;

  this_ = (ImageJngFile *)mng_get_userdata (hHandle);

  return this_->NewImage + (iLineNr * this_->Width * 4);
}
Ejemplo n.º 19
0
static mng_bool MNGPLG_CALLBACK callback_closestream (mng_handle mng)
{
	PluginInstance *This;
	This = (PluginInstance*) mng_get_userdata(mng);
	This->loadstate = STATE_LOADED;  // this is probably redundant

	return MNG_TRUE;
}
Ejemplo n.º 20
0
mng_bool
mymngreadstream(mng_handle mng, mng_ptr buffer, mng_uint32 size, mng_uint32 *bytesread) {
	mngstuff *mymng = (mngstuff *)mng_get_userdata(mng);

	*bytesread = mymng->io->read_proc(buffer, 1, size, mymng->file);

	return MNG_TRUE;
}
Ejemplo n.º 21
0
mng_ptr csJNGImageIO::cb_getcanvasline(mng_handle hHandle, mng_uint32 iLinenr)
{
  csJNGImageIO *this_;

  this_ = (csJNGImageIO *)mng_get_userdata (hHandle);

  return (csRGBpixel*)this_->imgRGBA->GetImageData()+(iLinenr*this_->imgRGBA->GetWidth());
}
Ejemplo n.º 22
0
static mng_ptr MNGPLG_CALLBACK callback_getcanvasline (mng_handle mng, mng_uint32 iLinenr)
{
	unsigned char *pp;

	PluginInstance *This;
	This = (PluginInstance*) mng_get_userdata(mng);
	pp = (&This->lpdibbits[(This->lpdibinfo->biHeight-1-iLinenr)*This->diblinesize]);
	return (mng_ptr) pp;
}
Ejemplo n.º 23
0
/**
 * \brief MNG library callback: Please call again after some milliseconds.
 * \param[in] h_mng MNG library image handle
 * \param[in] msecs number of milliseconds after which to call again
 * \return \p MNG_TRUE on success, \p MNG_FALSE on error (never happens)
 */
static mng_bool demux_mng_settimer(mng_handle h_mng, mng_uint32 msecs)
{
    mng_priv_t * mng_priv = mng_get_userdata(h_mng);

    // Save number of milliseconds after which to call the MNG library again
    // in private data.
    mng_priv->timer_ms = msecs;
    return MNG_TRUE;
}
Ejemplo n.º 24
0
/**
 * @brief libmng callback: write libmng data to the open stream
 * @param[in] mng libmng handle
 * @param[in] *buf pointer to data to write
 * @param[in] size size of data to write
 * @param[out] *written size of data written
 * @return if data was written successfully
 */
static mng_bool vomng_writedata(mng_handle mng, mng_ptr buf,
                                mng_uint32 size, mng_uint32 *written)
{
    FILE *file = mng_get_userdata(mng);
    *written = fwrite(buf, 1, size, file);
    /* according to the example in libmng documentation, true is always
       returned here, short writes can be detected by libmng via *written */
    return MNG_TRUE;
}
Ejemplo n.º 25
0
static mng_bool MNG_DECL my_readdata(mng_handle handle, mng_ptr buf, mng_uint32 buflen,
	mng_uint32p read)
{
	Mng *mng;

	mng = (Mng *)mng_get_userdata(handle);
	*read = fread(buf, 1, buflen, mng->fd);
	return MNG_TRUE;
}
Ejemplo n.º 26
0
static mng_bool mngProcessHeaderFn(mng_handle mng, mng_uint32 width, mng_uint32 height)
{
   mngstuff *mymng = (mngstuff *)mng_get_userdata(mng);

   GFXFormat format;
   mng_uint8 colorType = mng_get_colortype(mng);
   mng_uint8 alphaDepth = mng_get_alphadepth(mng);
   switch(colorType)
   {
      case MNG_COLORTYPE_GRAY:
      case MNG_COLORTYPE_JPEGGRAY:
         format = GFXFormatR8G8B8;
         mng_set_canvasstyle(mng, MNG_CANVAS_RGB8);
         break;

      case MNG_COLORTYPE_INDEXED:
         if(alphaDepth >= 1)
         {
            format = GFXFormatR8G8B8A8;
            mng_set_canvasstyle(mng, MNG_CANVAS_RGBA8);
         }
         else
         {
            format = GFXFormatR8G8B8;
            mng_set_canvasstyle(mng, MNG_CANVAS_RGB8);
         }

      case MNG_COLORTYPE_RGB:
      case MNG_COLORTYPE_JPEGCOLOR:
         if(alphaDepth >= 1)
         {
            format = GFXFormatR8G8B8A8;
            mng_set_canvasstyle(mng, MNG_CANVAS_RGBA8);
         }
         else
         {
            format = GFXFormatR8G8B8;
            mng_set_canvasstyle(mng, MNG_CANVAS_RGB8);
         }
         break;

      case MNG_COLORTYPE_RGBA:
      case MNG_COLORTYPE_JPEGCOLORA:
         format = GFXFormatR8G8B8A8;
         mng_set_canvasstyle(mng, MNG_CANVAS_RGBA8);
         break;

      default:
         // This case should never get hit, however it resolves a compiler
         // warning
         format = GFXFormat_FIRST;
         AssertISV( false, "Unknown color format in bitmap MNG Loading" );
   }

   mymng->image->allocateBitmap(width, height, false, format);
   return MNG_TRUE;
}
Ejemplo n.º 27
0
/**
 * \brief MNG library callback: Get access to a canvas line.
 * \param[in] h_mng MNG library image handle
 * \param[in] line y coordinate of line to access
 * \return pointer to line on success, \p MNG_NULL on error
 */
static mng_ptr demux_mng_getcanvasline(mng_handle h_mng, mng_uint32 line)
{
    mng_priv_t * mng_priv = mng_get_userdata(h_mng);

    // return pointer to canvas line
    if (line < mng_priv->height && mng_priv->canvas)
        return (mng_ptr)(mng_priv->canvas + line * mng_priv->width * 4);
    else
        return (mng_ptr)MNG_NULL;
}
Ejemplo n.º 28
0
/**
 * \brief MNG library callback: Open MNG stream.
 * \param[in] h_mng MNG library image handle
 * \return \p MNG_TRUE on success, \p MNG_FALSE on error (never happens)
 */
static mng_bool demux_mng_openstream(mng_handle h_mng)
{
    mng_priv_t * mng_priv = mng_get_userdata(h_mng);
    stream_t * stream = mng_priv->stream;

    // rewind stream to the beginning
    stream_seek(stream, stream->start_pos);

    return MNG_TRUE;
}
Ejemplo n.º 29
0
static mng_bool MNG_DECL my_errorproc(mng_handle handle, mng_int32,
									  mng_int8, mng_chunkid, mng_uint32, mng_int32, mng_int32, mng_pchar errortext)
{
	Mng *mng = (Mng *)mng_get_userdata(handle);
	mng->iteration = 0x7fffffff;
	if (errortext) {
		DebugPrint("MNG error: %s\n" _C_ errortext);
	}
	return TRUE;
}
Ejemplo n.º 30
0
static mng_bool MNG_DECL my_closestream(mng_handle handle)
{
	Mng *mng;

	mng = (Mng *)mng_get_userdata(handle);
	if (mng->fd) {
		fclose(mng->fd);
	}
	return MNG_TRUE;
}