Home > Software engineering >  The poor quality of VB6.0 by use of GDI saved JPG image problem
The poor quality of VB6.0 by use of GDI saved JPG image problem

Time:09-24

I'm doing a image processing software, involved in image compression, format conversion, etc.,
The development environment, WinXP + VB6.0 by use of the use of GDI
Users in WinXP environment, everything is normal,

Above the Windows 7 system, the development in VB6.0 by use of compiler (including full compilation), everything is ok still,
But after production exe file, when the image is saved as a JPG image quality becomes poor, such as the appended drawings,
But do not have this problem when saved as a BMP,

I understand is where the operating system, influence the process of JPG save,
Save as JPG function function is as follows:

 
'* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
'* * letter of several: funSaveImgToFile
'* * entered: PIC (StdPicture) - image handle
'* * : FileName (String) - save the path
'* * : Quality (Byte) - JPG image Quality
'* * : TIFF_ColorDepth (Long) - the color depth of the vera.ttf format
'* * : TIFF_Compression (Long) - the vera.ttf format compression ratio
'* * output: success
'* * function description: the image saved as JPG, TIFF, PNG, GIF, BMP format
'* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
The Public Function funSaveImgToFile (ByVal Pict As StdPicture, ByVal FileName As String, ByVal PicType As String, _
Optional ByVal Quality As Byte=100, _
Optional ByVal TIFF_ColorDepth As Long=24, _
Optional ByVal TIFF_Compression As Long As Boolean=6)
Dim tSI As GdiplusStartupInput
Dim lRes As Long
Dim lGDIP As Long
Dim lBitmap As Long
Dim aEncParams () As Byte

'initialize GDI +
TSI. GdiplusVersion=1
LRes=GdiplusStartup (lGDIP, tSI, 0)
If lRes=0 Then 'clauses handle create an image of the GDI +
LRes=GdipCreateBitmapFromHBITMAP (Pict. Handle, 0, lBitmap)
If lRes=0 Then
Dim tJpgEncoder As GUID
Dim tParams As EncoderParameters' initialize decoder GUID identifier
Select Case LCase (PicType) 'to prevent the file format is the lowercase to uppercase, if it is to small to write
Case "JPG"
CLSIDFromString StrPtr (" {a04 cf401 557-1-11 d3-9 - a73-0000 f81ef32e} "), tJpgEncoder
TParams. Count=1 'set the decoder parameter
With tParams. Parameter 'Quality
CLSIDFromString StrPtr (" {1 d5be4b5 FA4A CDD - 452 - d - 9-5 db35105e7eb} "), GUID identifier of the GUID 'Quality parameter
. NumberOfValues=1

type=4Value=https://bbs.csdn.net/topics/VarPtr (Quality)
End With
ReDim aEncParams (1 To Len (tParams))
Call CopyMemory (aEncParams (1), tParams, Len (tParams))
Case "PNG"
CLSIDFromString StrPtr (" {a04 cf406 557-1-11 d3-9 - a73-0000 f81ef32e} "), tJpgEncoder
ReDim aEncParams (1 To Len (tParams))
Case "GIF"
CLSIDFromString StrPtr (" {a04 cf402 557-1-11 d3-9 - a73-0000 f81ef32e} "), tJpgEncoder
ReDim aEncParams (1 To Len (tParams))
Case "tiff"
CLSIDFromString StrPtr (" {a04 cf405 557-1-11 d3-9 - a73-0000 f81ef32e} "), tJpgEncoder
TParams. Count=2
ReDim aEncParams (1 To Len (tParams) + Len (tParams. Parameter))
With tParams. The Parameter
. NumberOfValues=1

type=4CLSIDFromString StrPtr (" {E09D739D - ee CCD4-44-8 eba - 3 fbf8be4fc58} "), GUID identifier of the GUID 'ColorDepth parameter
Value=https://bbs.csdn.net/topics/VarPtr (TIFF_Compression)
End With
Call CopyMemory (aEncParams (1), tParams, Len (tParams))
With tParams. The Parameter
. NumberOfValues=1

type=4CLSIDFromString StrPtr (" {66087055 - c7c AD66-4-9 a18-38 a2310b8337} "), the GUID 'get the parameters of Compression will GUID identifier
Value=https://bbs.csdn.net/topics/VarPtr (TIFF_ColorDepth)
End With
Call CopyMemory (aEncParams (Len (tParams) + 1), tParams. Parameter, Len (tParams. Parameter))
End the Select
LRes=GdipSaveImageToFile (lBitmap, StrPtr (FileName), tJpgEncoder, aEncParams (1)) 'save image
GdipDisposeImage lBitmap 'destruction of GDI + image
End the If
GdiplusShutdown lGDIP 'destruction of GDI +
End the If
Erase aEncParams
If lRes Then
FunSaveImgToFile=False
The Else
FunSaveImgToFile=True
End the If
The Exit Function
End the Function


Processing: picture


Pray god help,, send all scores,

CodePudding user response:

Why in the development environment and running is no problem?????? Hurry!

CodePudding user response:

This code, I run the IDE, compiled to run, there is no problem,
I preach "quality" for 80, conversion feel good, under 10, begin to produce "splash" phenomenon,
The original poster is what code is a little problem, compiled the "quality" of the parameter value is too low?

My running environment is: Win10 pro 64, VB6/SP6 simplified Chinese enterprise edition,

CodePudding user response:

Thank you support, upstairs parameter values we are 100 by default,
Yesterday I in accordance with the "" "" P code form output exe, there is no this problem,

CodePudding user response:

reference cnewerPlus reply: 3/f
thank you for your support, upstairs parameter values we are all the default 100,
Yesterday I in accordance with the "" "" P code form output exe, there is no this problem,

I compile to machine code,
You can compile to machine code, and run on another computer to try and see if your system have what problem,
Wen to death system, there are some wonderful work problem is's hard to say why,

CodePudding user response:

I think splash version of image art more hazy,

CodePudding user response:

reference 5 floor zhao4zhong1 reply:
I think splash version of image art more hazy,

We talk about technology, you give us a talk about art, too tall...

CodePudding user response:

refer to 6th floor cnewerPlus response:
Quote: refer to the fifth floor zhao4zhong1 reply:

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  •  Tags:  
  • API
  • Related