Page 1 of 1
					
				Save PCX file
				Posted: Mon May 14, 2007 6:06 pm
				by rigalr
				Hello,
I'm using visual basic 6.0 with the SDK.
I try to load a BMP file, and save it in PCX fileformat (2 colors). 
I've tried with 2.2 and 2.67 gflsdk.dll
The file is created, but unreadable (not a valid file format).
If I try to export JPEG, GIF, TIFF, ... it works.
any idea ?
Best regards,
Régis
			 
			
					
				Re: Save PCX file
				Posted: Tue May 15, 2007 6:30 am
				by xnview
				rigalr wrote:Hello,
I'm using visual basic 6.0 with the SDK.
I try to load a BMP file, and save it in PCX fileformat (2 colors). 
I've tried with 2.2 and 2.67 gflsdk.dll
The file is created, but unreadable (not a valid file format).
If I try to export JPEG, GIF, TIFF, ... it works.
any idea ?
Best regards,
Régis
Unreadable by xnview?
 
			
					
				
				Posted: Tue May 15, 2007 9:27 am
				by rigalr
				Hello,
I can 
open and read the 
file with xnview, but Paint shop pro, or photoshop can't read the 
file.
Maybe some parameters are wrong when I save the 
file ?
In fact, I have to send the PCX 1 bit 
file in a specific thermal printer (via COM port), and the printer don't accept the logo. 
If I try to save the logo with Paint shop pro, it works.
Here is the source code:
Code: Select all
    gflLibraryInit 'Initialize the library
    gflGetDefaultLoadParams GflLoadParams 'Gets default parameters for loading
    gflEnableLZW False 'Activate the LZW compression
    
    With GflLoadParams
        .Flags = GFL_LOAD_SKIP_ALPHA Or GFL_LOAD_BY_EXTENSION_ONLY
        .Origin = GFL_BOTTOM_LEFT 'Origin is bottom-left
        .ColorModel = GFL_BGR 'Component order like DIB
        .LinePadding = 4 'Line padding on 4 bytes (32bits)
    End With
    
    File = szfilenameBMP
    FileDest = szFileNamePCX
    
    maform.AutoRedraw = True 'Form must be refreshed
    Error = gflLoadBitmap(File, PtrBitmap, GflLoadParams, GflInfo) 'Load picture
    If Error = GFL_NO_ERROR Then 'If no error
        extGetGflBitmapFromPtr PtrBitmap, GflBitmap 'Get the data
            extShowBitmapOnDc GflBitmap, maform.hdc 'Draw the bitmap (optional)
            
            Error = gflChangeColorDepth(GflBitmap, PtrBitmap, GFL_MODE_TO_BINARY, GFL_MODE_PATTERN_DITHER)        'Change color depth of the picture
            If Error = GFL_NO_ERROR Then 'Si aucune erreur
                extGetGflBitmapFromPtr PtrBitmap, GflBitmap 'Get the picture data
                
                gflGetDefaultSaveParams GflSaveParams 'Gets default parameters for saving
                With GflSaveParams
                    .Flags = GFL_SAVE_ANYWAY
                    .FormatIndex = gflGetFormatIndexByName("pcx")  'Get the index of PCX format
                End With
                
                Error = gflSaveBitmap(FileDest, GflBitmap, GflSaveParams) 'Save the picture
                
                gflFreeBitmapData GflBitmap 'Free bitmap
            End If
    End If
    If Error <> GFL_NO_ERROR Then MsgBox extGetStr(gflGetErrorString(Error)) 'Display a message box
    gflLibraryExit 'Quit the library
 
			
					
				
				Posted: Tue May 15, 2007 9:30 am
				by xnview
				rigalr wrote:Hello,
I can open and read the file with xnview, but Paint shop pro, or photoshop can't read the file.
Maybe some parameters are wrong when I save the file ?
In fact, I have to send the PCX 1 bit file in a specific thermal printer (via COM port), and the printer don't accept the logo. 
If I try to save the logo with Paint shop pro, it works.
Could you send the 
file saved by GFL and saved by PSP?
 
			
					
				
				Posted: Tue May 15, 2007 11:04 am
				by rigalr
				Here are the files:
PaintShopPro 
file: (exported with PCX version 0 option)
http://www.rodrigue.fr/temp/psp.pcx
GFL SDK 
File
http://www.rodrigue.fr/temp/gfl.pcx
Original 
file
http://www.rodrigue.fr/temp/logo.bmp
Maybe there is a compression level to define in the source code, but I don't have sample.
Best regards,
Régis
 
			
					
				
				Posted: Tue May 15, 2007 1:13 pm
				by xnview
				
Ok, they need RLE, so use params.Compression = GFL_RLE;
 
			
					
				
				Posted: Tue May 15, 2007 5:28 pm
				by rigalr
				THANK YOU !!!!
It works !!!
 
 
  