Total members 11894 |It is currently Mon Nov 25, 2024 2:30 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Example on how to load and display animated GIF and BMP Files. Read GIF in C++
cpp code
// ****************************************************************************
//
// GIFVIEW.CPP
//
// This sample file demonstrates how to load an animated GIF and a BMP file
// in Windows using the Winimage library.
//
// You should compile & link this file together with:
// WINIMAGE.CPP: Generic classes for raster images (MSWindows specialization)
//
// ----------------------------------------------------------------------------
//
// Copyright © 2000, Juan Soulie <[email protected]>
//
// Permission to use, copy, modify, distribute and sell this software or any
// part thereof and/or its documentation for any purpose is granted without fee
// provided that the above copyright notice and this permission notice appear
// in all copies.
//
// This software is provided "as is" without express or implied warranty of
// any kind. The author shall have no liability with respect to the
// infringement of copyrights or patents that any modification to the content
// of this file or this file itself may incur.
//
// ****************************************************************************

#include <windows.h>
#include "winimage.h"

char szAppName[]="GIF/BMP Loader Example";

LRESULT CALLBACK WndProc (HWND,UINT,WPARAM,LPARAM);

// WinMain (Windows application main function)
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
HWND hwnd;
MSG msg;
WNDCLASSEX wndclass;

// Register the Main Window Class:
wndclass.cbSize=sizeof (wndclass);
wndclass.style=CS_HREDRAW|CS_VREDRAW;
wndclass.lpfnWndProc=WndProc;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance=hInstance;
wndclass.hIcon=LoadIcon (NULL,IDI_APPLICATION);
wndclass.hCursor=LoadCursor (NULL,IDC_ARROW);
wndclass.hbrBackground=(HBRUSH) (COLOR_WINDOW);
wndclass.lpszMenuName=NULL;
wndclass.lpszClassName=szAppName;
wndclass.hIconSm=LoadIcon (NULL,IDI_APPLICATION);

RegisterClassEx (&wndclass);

// Create and Show the Main Window
hwnd=CreateWindow (szAppName,szAppName,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,CW_USEDEFAULT,
CW_USEDEFAULT,CW_USEDEFAULT,
NULL,NULL,hInstance,NULL);
ShowWindow (hwnd,iCmdShow);
UpdateWindow (hwnd);

// Message Loop
while (GetMessage (&msg,NULL,0,0))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}

// End Application
return msg.wParam;
}

// WndProc (Main window procedure - Message Processor)
LRESULT CALLBACK WndProc (HWND hwnd,UINT iMsg,WPARAM wParam,LPARAM lParam)
{
static C_Image img;
static C_ImageSet imgset;
static C_AnimationWindow anim, anim2, anim3;
switch (iMsg)
{
case WM_CREATE:
// Load Image files
img.LoadBMP ("logo.bmp");
imgset.LoadGIF ("sample.gif");
// Create 3 Animation Child Windows of the same C_ImageSet object:
// Notice how each one uses its own thread and can be
// paused independently (left-clicking)
anim.Create (hwnd,(HMENU)1000,&imgset);
anim2.Create (hwnd,(HMENU)1001,&imgset);
anim3.Create (hwnd,(HMENU)1002,&imgset);

return 0;
case WM_SIZE:
// Display and Set position of Animation Child Windows (GIF file):
anim.Display (10,10);
anim2.Display (110,10);
anim3.Display (210,10);
return 0;
case WM_PAINT:
// Paint the img object (BMP file):
HDC hdc;
PAINTSTRUCT ps;
hdc=BeginPaint (hwnd,&ps);
img.GDIPaint (hdc,10,100);
EndPaint (hwnd,&ps);
return 0;
case WM_DESTROY:
PostQuitMessage (0);
return 0;
}
return DefWindowProc (hwnd,iMsg,wParam,lParam);
}





Attachments:
File comment: source code ,
wingif.zip [80.08 KiB]
Downloaded 2970 times

_________________
Please recommend my post if you found it helpful
Author:
Beginner
User avatar Posts: 95
Have thanks: 2 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : view GIF in C++
 J2ME web cam view in my cell phone     -  
 J2ME web cam view in my cell phone(may b bluetooth or ir)     -  



Topic Tags

C++ Files and I/O






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com