Board index » cppbuilder » Re: Access Violation and TJPEG..

Re: Access Violation and TJPEG..


2003-08-10 01:09:09 PM
cppbuilder87
u using timer ??
if yes, which part of the code is in the timer ??
-Dumboo
 
 

Re:Re: Access Violation and TJPEG..

Thanks Dumboo for your reply, yes I am using a timer and I am using the
whole code under the time event....
is there any problem or mistake I am making if using timer with this
code...thanks...
BTW how I can set the picture quality to 50% for example...when saving....
thanks
// All of the following code is under a timer event
HWND winHWND;
HDC winDC;
TRect Rect;
Graphics::TBitmap *FBitmap = new Graphics::TBitmap;
TJPEGImage *jp = new TJPEGImage();
winHWND = GetDesktopWindow();
winDC = GetDC(winHWND);
GetWindowRect(winHWND, &Rect);
FBitmap->Width = Rect.right - Rect.left;
FBitmap->Height = Rect.bottom - Rect.top;
BitBlt(FBitmap->Canvas->Handle, 0, 0, FBitmap->Width, FBitmap->Height,
winDC, Rect.left, Rect.top, SRCCOPY);
jp->Assign(FBitmap);
jp->Compress();
jp->SaveToFile("C:\\MySampleDir1"); ->>>>>>>it stop in this line
ReleaseDC(winHWND, winDC);
delete jp;
delete FBitmap;
"Dumboo" < XXXX@XXXXX.COM >wrote in message
Quote
u using timer ??

if yes, which part of the code is in the timer ??

-Dumboo


 

Re:Re: Access Violation and TJPEG..

your code looks alright to me, it run well no my machine
usually EOutOfMemory is thrown when an application attempts to allocate
dynamic memory, but there is not enough free memory in the system to meet
the request,
it looks as if the statement
Quote
jp->SaveToFile("C:\\MySampleDir1"); ->>>>>>>it stop in this line
is trying to allocate the memory internally(unsuccessfully)
//----------
try this alternative src code
TJPEGImage *jpg = new TJPEGImage;
Graphics::TBitmap *bmp = new Graphics::TBitmap;
HDC dc = GetDC(0);
Graphics::TCanvas *ScreenCanvas = new Graphics::TCanvas;
ScreenCanvas->Handle = dc;
bmp->Width = ScreenCanvas->Width;
bmp->Height = ScreenCanvas->Height;
ReleaseDC(NULL,dc);
jpg->Assign(bmp);
jpg->SaveToFile("myFile");
delete ScreenCanvas;
delete bmp;
delete jpg;
//----------
sorry.......cannot say anything more....8-|
Quote
BTW how I can set the picture quality to 50% for example...when saving....
use CompressionQuality, before calling Compress()
Hope this helps....
-Dumboo :-)
 

{smallsort}