 |
|
|
 |
|
|
 |
|
|
 |
|
 |
when quality is 100 ,that is allmost no compression(is all right?).
but the output jpg file is still smaller than the old one,and the quality seems not changed!!
a amazing situation is :if the source pic has a red block, for example this pic:
http://img.11wap.com/downl/cxm/0239.jpg[^]
,the color of this red block will become deeper and other color(block) is remain no change.
It make me crazy! (i test c# and mfc code, they also cause this bug! Is it a bug of Window basic logic??)
some one know why?
please email to me,topreap#126.com(please replace # with @)
thanks very much!
to be expert!
|
|
|
|
 |
|
 |
That is because jpg compression is LOSSY, which means that the algorithm sacrifizes some information for smaller file size.
Hope that helps explaining your question.
|
|
|
|
 |
|
 |
thanks reply!
I know jpg compression is LOSSY.
but the quality is 100 and the source pic is another jpgfile.
and why other color remain no change ,and only the red color change,this this the point of the question.
I think there is something that make sense ,that make this "bug"
----the os is :winxp sp2 ,vs.net 20
to be expert!
|
|
|
|
 |
|
|
 |
|
 |
In my opinion, this happens because JPEG compression is lossy, and therefore different compression algorithms exist. So the result may differ if it's a worse encoder. PNG is lossless and always uses the same compression algorithm. Quality should be always the same (except for conversion from PNG-24 to PNG-8).
|
|
|
|
 |
|
|
 |
|
 |
Hi Amer. This is what i've searched for! Some people on the AutoIt-Forum looked for a way to compress images in memory and send them over the network with > AutoIt-Scripting <. "AutoIt is a freeware Windows automation language. It can be used to script most simple Windows-based tasks (great for PC rollouts or home automation)."
There doesn't seem to be a function (IStream or similar) to do the same with AutoIt (what a pitty ). Thats the reason why I/we ask for a DLL. We would be appreciated if you could help us!
AutoIt-Forum: > ScreenShot ready to send via TCPSend <
|
|
|
|
 |
|
 |
I am not familiar with AutoIt-Scripting, but if the script can utilize COM, then it should be able to utilize IStream object. I am not really sure that rewriting the application to be a DLL would solve your problem. Possibly, the best solution would be to provide COM capabilities to the scripting language.
Sorry I could not be of more help!
|
|
|
|
 |
|
 |
AutoIt supports COM, but I dont know how to use, 'cause I'm not familiar with AutoIt-Scripting like you (web design is one of my hobbies - PHP, CSS, JS, MySQL). Afaik there are no pointers in AutoIt, could that be a problem?
from the documentation: COM Extensions to AutoIt
(PDF, ~80 KB)
Thank you for your quick answer and this nice work!
|
|
|
|
 |
|
 |
I never used Auto-It ... not really familiar with it. The fact that it does not support pointers does not matter. I would love to help but at this point it is not feasable because my software contracts are picking up.
I'll let you know if it changes!
|
|
|
|
 |
|
 |
i would like to be able to upload images and save them using this code as it will save space on my server. how can i get this code converted to a DLL so i can use it in my asp.net webpage.
thanks,
jason
|
|
|
|
 |
|
 |
I would suggest for you to investigate .NET library, because I believe that this feature is already built into .NET under GDI+ (graphics) namespace. Unfortunately, I cannot point out to you where it is and how is it used because I do not use .NET that often. However, there might be solution somewhere else (check out other forums).
Hope it helps.
|
|
|
|
 |
|
 |
:(I'm facing the same problem as you. In MFC application, it's OK when using GDI+ to mix a picture(.bmp) with a transparent background PNG picture. But in Win32 Dll, GDI+ codes such as
Graphics graphics(m_DC); Rect rectf;
int res1 = graphics.GetVisibleClipBounds(&rectf); //
return value res1 = 2, denotes InvalidParameter
I don't know why?
|
|
|
|
 |
|
 |
i am using GDI+ for bitmap image compression .
I have used this code. but when i complie it...error occurs as follow
gdiplus.lib(imagingguds.obj) : fatal error LNK1103: debugging information corrupt; recompile module
I am getting the reason since i am new to GDI+
Please help me
|
|
|
|
 |
|
 |
I believe you should reinstall gdiplus library. However, just to be safe, I would look at LNK1103 in MSDN. In addition, try to delete all compiled modules from your project.
I hope one of these ideas helps.
|
|
|
|
 |
|
 |
Thanks for ur comment. i have got solution
But i have one querry..facing one problem..
i am developing one scanning application which scan a image and store it in HGLOBAL hDIBImage. image info will be saved in TW_IMAGEINFO * pInfo.
now i want to create jpeg file ..please suggest how to do .
i have tried but failed to do it...code as follow...please tell where is wrong .....
bool CMainFrame::OnCopyImage(HGLOBAL hDIBImage, TW_IMAGEINFO * pInfo, long nImageIndex)
{
CTwainDoc * pDoc = CreateNewDocument();
ASSERT(pDoc);
Status SaveStatus ;
IStream* pIStream = NULL;
if(CreateStreamOnHGlobal(hDIBImage, TRUE, (LPSTREAM*)&pIStream) != S_OK)
{
AfxMessageBox(_T("Failed to create stream on global memory!"));
return FALSE;
}
Image *pImage = Image::FromStream(pStream);
SaveStatus = pImage->GetLastStatus();
if(SaveStatus != Ok)
{
AfxMessageBox(_T("Failed to create Iamge !"));
return FALSE;
}
// Get encoder class id for jpg compression
CLSID pngClsid;
GetEncoderClsid(L"image/jpeg", &pngClsid);
// Setup encoder parameters
EncoderParameters encoderParameters;
encoderParameters.Count = 1;
encoderParameters.Parameter[0].Guid = EncoderQuality;
encoderParameters.Parameter[0].Type = EncoderParameterValueTypeLong;
encoderParameters.Parameter[0].NumberOfValues = 1;
// setup compression level
ULONG quality = 50;
encoderParameters.Parameter[0].Value = &quality;
// Save the image to the stream
SaveStatus = pImage->Save(L"D:\\ScanResult\\WebBook00141\\pic_images\\Hi_preview\\0001.jpg", &pngClsid, &encoderParameters);
if(SaveStatus != Ok)
{
pIStream->Release();
AfxMessageBox(_T("Failed to save to Image!"));
return FALSE;
}
return true; // Continue with another picture, if any;
}
|
|
|
|
 |
|
 |
Continue with above thread........
Image *pImage = Image::FromStream(pStream);
SaveStatus = pImage->GetLastStatus();
if(SaveStatus != Ok)
{
AfxMessageBox(_T("Failed to create Iamge !"));
return FALSE;
}
Error :SaveStatus = InvalidParameter ......
what the reason ?
|
|
|
|
 |
|
 |
As the error points out, you have some parameters wrong i.e paramters for the encoder type that you want to use are not matching. I am not really expert in GDI and don't use it daily so that I do not have instant answer to parameter settings for each encoder type. However, I am sure that MSDN has paramter structure and maybe some samples on how to save image to jpeg. I don't believe it is a serious issue, but simply matter of looking in MSDN documentation (which could be accessed online) and entering correct (maybe additional) parameters for the encoder.
Hope it helps!
|
|
|
|
 |
|
 |
Hi Amer,
Thanks . But i am getting the where is the actaul problem. I am new to GDI+.
------------
Error point is at the time of creation of Image pointer . it gives the status as InvalidParameter...
But its working fine when i crete the pointer using FromFile..
Image *pImage = Image::FromStream(pStream);
SaveStatus = pImage->GetLastStatus();
---------------
u mean to say that while creating the Stream pointer , i have to add additional paramter......
|
|
|
|
 |
|
 |
First thing that comes to my mind would be to check if your stream object is not NULL.
|
|
|
|
 |
|
 |
Hi,
Thanks for this useful code, I hope to use this idea to save Windows BITMAPs to a CArchive in compressed format
1 - Create Bitmap object using Bitmap::FromBITMAPINFO
2 - Write this Bitmap object to an IStream, using JPEG encoder
3 - Use GetHGlobalFrom to get the memory block
4 - Use CArchive::Write to store this memory block in the MFC archive
It wasn't easy finding information on how to do this, so thanks a lot for the help.
Regards,
Alan
|
|
|
|
 |
|
|
 |