 |
|
|
 |
|
 |
void CPictureEx::OnPaint()
{
CPaintDC dc(this); // device context for painting
LONG nPaintWidth = m_PaintRect.right-m_PaintRect.left;
LONG nPaintHight = m_PaintRect.bottom-m_PaintRect.top;// add this line
SetWindowPos(NULL,0,0,nPaintWidth,nPaintHight,SWP_NOMOVE | SWP_NOZORDER);//add this line
if (nPaintWidth > 0)
{
LONG nPaintHeight = m_PaintRect.bottom - m_PaintRect.top;
::BitBlt(dc.m_hDC, 0, 0, nPaintWidth, nPaintHeight,
m_hMemDC, m_PaintRect.left, m_PaintRect.top, SRCCOPY);
}
else
{
::BitBlt(dc.m_hDC, 0, 0, m_PictureSize.cx, m_PictureSize.cy,
m_hMemDC, 0, 0, SRCCOPY);
}
}
|
|
|
|
 |
|
 |
void CPictureEx::OnPaint()
{
CPaintDC dc(this); // device context for painting
LONG nPaintWidth = m_PaintRect.right-m_PaintRect.left;
LONG nPaintHight = m_PaintRect.bottom-m_PaintRect.top;//
if(nPaintHight!=0&&nPaintWidth!=0)//
SetWindowPos(NULL,0,0,nPaintWidth,nPaintHight,SWP_NOMOVE | SWP_NOZORDER);//
if (nPaintWidth > 0)
{
LONG nPaintHeight = m_PaintRect.bottom - m_PaintRect.top;
::BitBlt(dc.m_hDC, 0, 0, nPaintWidth, nPaintHeight,
m_hMemDC, m_PaintRect.left, m_PaintRect.top, SRCCOPY);
}
else
{
::BitBlt(dc.m_hDC, 0, 0, m_PictureSize.cx, m_PictureSize.cy,
m_hMemDC, 0, 0, SRCCOPY);
}
}
|
|
|
|
 |
|
 |
Your example is display the gif-animation in a dialog, but I want to display it in a MFC view, and I use the following code:
m_picture.Create(NULL, SS_CENTER, rect, this, 100);
if (m_picture.Load(MAKEINTRESOURCE(IDR_GIF1),_T("GIF")))
m_picture.Draw();
but I found it didn't work, there is no gif display.why?
|
|
|
|
 |
|
 |
pPicture = new CPictureEx;
pPicture->Create(NULL, WS_CHILD|WS_VISIBLE|SS_CENTER, CRect(300,100,150,150), this);
if (pPicture->Load(picfilename))
{
pPicture->Draw();
}
|
|
|
|
 |
|
 |
If you want to have this in an CScrollView, first setscrollsizes(0,0)
and then use in onSize() ONLY SetWindowPos().
Do NOT use under any circumstances MoveWindow(),
it will create very difficult to diagnose redrawing problems.
I do not know why it is so, but this caused me to lose 1 day and a lot of neurons.
|
|
|
|
 |
|
 |
Hi great class,
In your comments you say that "If your parent window is not a dialog..." just call the CPictureExWnd::Create(). Stupid newbie question but what parameters should I pass to it?
Thanks
Chris
|
|
|
|
 |
|
|
 |
|
 |
I want to retrieve each frame from a GIF file and store them in CBitmaps. How can i do that? I`ve read your code but it`s a bit too complex for me and i heaven`t fully understood it ...Thanks in advance
|
|
|
|
 |
|
 |
Hi there!
I was tring to use this control in a "please wait" dialog. The dialog is modeless, so I can show it, do some processing and then destroy it.
The problem, is that if I use some very slow API or function call that does not processes the windows message pool, it seems to hang, even if the animation thread is running.
I don't know why, but the control never gets to be updated/painted, so the animation stops.
Do you have any suggestion on how to solve this problem?
Thanks for you time.
ALMC
|
|
|
|
 |
|
 |
I wanted to just play the .gif once, so I #if'ed out the old code and added a couple of lines to the end of ThreadAnimation(): m_nCurrFrame++; if (m_nCurrFrame == m_arrFrames.size()) #if 0 m_nCurrFrame = 0; // init the screen for the first frame, HBRUSH hBrush = CreateSolidBrush(m_clrBackground); if (hBrush) { RECT rect = {0,0,m_PictureSize.cx,m_PictureSize.cy}; FillRect(m_hMemDC,&rect,hBrush); DeleteObject(hBrush); }; // done restarting #else m_nCurrFrame--; // reset to last frame Stop(); #endif
|
|
|
|
 |
|
 |
Have tried multiple things to embed animated gif into resource - import resource, get message back: " is not a valid GIF file" and does not add. Could someone give me some additional instruction on this? Thanks
Dave Galligher
Director of Product Development
Cougar Mountain Software
davegalligher@cougarmtn.com
Voice: 208.375.4455 x180
Fax: 208.375.4460
|
|
|
|
 |
|
 |
In resource view clicked resource ,then Insert ,choose custom, you can name your resource type, then you can import the gif resources to your custom resource.
|
|
|
|
 |
|
 |
This took me a while to figure out. Whatever you name the resource "Type" in the resources, needs to be the "Type" you send in the Load() call. When adding an animated GIF as type GIF, VS doesn't let you. You can get around this by changing the file name to something else. The author of CompleteActiveX does a good job of explaining this.
|
|
|
|
 |
|
 |
I’m working in an activex control, and I want to display a gif file on its surface, so i added your class to my project and did the following.
I added a property named GIFPicture of type CString to hold the path of the gif file, and in the OnGIFPictureChange handler I added code to embed the gif file in the memory as the following(as u did in Load(CString) function):
CFile GIFPictureFile(m_cstrGIFPicture, CFile::modeRead | CFile::typeBinary);
DWORD dFileSize = GIFPictureFile.GetLength();
HGLOBAL hgGIFPicture = GlobalAlloc(GMEM_MOVEABLE | GMEM_NODISCARD, m_dwFileSize + sizeof(ULONG));
the problem occur when i want to display a GIF file with one frame, in this function:
OleLoadPicture(pStream, dFileSize, FALSE, IID_IPicture, (LPVOID *)& pPicture);
it doesn’t return a valid value, and the pPicture stay empty.
i want to ask why this happened, and how to fix it ?
Thanks for help
ken san
|
|
|
|
 |
|
 |
I was trying to use this in my WinCE
Dialog based application,
but it is giving error
not found
Can u suggest a solution.
Thanks
|
|
|
|
 |
|
 |
Thank you for your code,But there is a small problem that I meet is,after load the GIF file,I've found it is to big on the window's dialog,Is there any way to fix it to fit proper size ?? thank you.
KW-Rix
|
|
|
|
 |
|
 |
hello,
to let the gif file fit to the dialog, just do the following:
-when create the CStatic window let it start from the top left point (0,0)
-now open the PictureEx.cpp to modify the following functions:
1- Load(HGLOBAL hGlobal, DWORD dwSize):
find the following lines
// store the picture's size
m_PictureSize.cx = m_pGIFLSDescriptor->m_wWidth;
m_PictureSize.cy = m_pGIFLSDescriptor->m_wHeight;
now change there valuse to your dialog width and height or any values u want as the following:
m_PictureSize.cx = 200;
m_PictureSize.cy = 150;
2- GetNextGraphicBlock(UINT *pBlockLen,
UINT *pDelay, SIZE *pBlockSize, SIZE *pBlockOffset,
UINT *pDisposal)
find the following lines
pBlockSize->cx = pImage->m_wWidth;
pBlockSize->cy = pImage->m_wHeight;
now u have to set there values to the same values above, as the following:
pBlockSize->cx = 200;
pBlockSize->cy = 150;
ken san
|
|
|
|
 |
|
 |
Your explanation is so nice!
Thanks for your help.
|
|
|
|
 |
|
 |
Hi,
If you want to scale the loaded image to fit an arbitrary size at runtime, heres a small function you can add in PictureEx.cpp that does the job:
BOOL CPictureEx::Scale(UINT Width, UINT Height)
{
m_PictureSize.cx = Width;
m_PictureSize.cy = Height;
return PrepareDC(Width, Height);
}
To use it, first call Load(), then Scale() then Draw().
Cheers
Brett
|
|
|
|
 |
|
 |
Hi
I think that this is a great class!
I would like to draw using the mouse, and write on top of the loaded GIF (in a SDI application).
I have tried:
dc.TextOut(10,10,"Test");
in the View OnPaint(), and it does not work.
Can someone please tell me how to do this?
Thank you.
Alex
|
|
|
|
 |
|
 |
Hi,
Thank you for your CPictureEx class. It has made my
life much easier
But I have 1 problem:
Some pictures (gif/jpeg compression) are slow to
download on slow computers. So I would like to create
a progress window. But OleLoadPicture does not seem to
provide much help.
I see that you read all bytes into a file in Load(..)
and I could read 1 byte per time and create progress
bar. But I think reading file is not most slow. I
think most slow is the decompression of data.
I am thinking of handling progress bar, by:
typedef struct _NMPROGRESS
{
NMHDR hdr;
INT min;
INT max;
INT pos;
} NMPROGRESSS;
#define NM_PROGRESS 0xF0000001
NMPROGRESSS nmp; // my own struct
nmp.hdr.hwndFrom = GetSafeHwnd();
nmp.hdr.idFrom = GetDlgCtrlID();
nmp.hdr.code = NM_PROGRESS;
nmp.min = 0;
nmp.max = 100;
CWnd* pParent = GetParent();
while(...)
{
nmp.pos = xxx;
pParent->SendMessage(WM_NOTIFY, GetDlgCtrlID(),
&nmp);
}
But how do I get xxx ?
Is it possible?
|
|
|
|
 |
|
 |
I have the same problem, on old comps (PII-400) animated GIF download takes up to 2 seconds... One frame decoding (160x300) takes 100 ms. This is very strange, because other programs (having internal LZW decoder) do this 100 times faster. Is it possible to improve situation? I can't ask all users to bye new comps
Tk
|
|
|
|
 |
|
 |
Hello!
I would like to use you code to replace a CAnimateCtrl, but I've found one problem.
I have a dialog that is shown when the app is doing something very slow. The idea is to make the user not to think that the app has hangged, so I play a GIF or a AVI.
The problem, is that in the thread that does the drawing, the dialog never gets the update message to redraw the new image.
Do you know how to make it work as an CAnumateCtrl, that plays the image, by it self?
Many thanks!
António Carvalho
|
|
|
|
 |
|
 |
under following conditions the program hangs:
( (m_pGIFLSDescriptor->GetPackedValuw(LSD_PACKED_CRESOLUTION) > 5) &&
(m_pGIFLSDescriptor->m_cBkIndex == 0) &&
m_clrBackground == 0x0)
reason: the function call to
OleLoadPicture(pStream,nBlockLen,FALSE,IID_IPicture,reinterpret_cast(&frame.m_pPicture))
will never return.
is there a solution known to this windows (?!) bug?
christian
info@chri.at
|
|
|
|
 |