Save PCX file

Discussions on GFL SDK, the graphic library for reading and writing graphic files

Moderators: XnTriq, xnview

rigalr
Posts: 4
Joined: Mon May 14, 2007 6:03 pm

Save PCX file

Post 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
User avatar
xnview
Author of XnView
Posts: 36866
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Re: Save PCX file

Post 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?
Pierre.
rigalr
Posts: 4
Joined: Mon May 14, 2007 6:03 pm

Post 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
User avatar
xnview
Author of XnView
Posts: 36866
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Post 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?
Pierre.
rigalr
Posts: 4
Joined: Mon May 14, 2007 6:03 pm

Post 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
User avatar
xnview
Author of XnView
Posts: 36866
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Post by xnview »

rigalr wrote: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.
Ok, they need RLE, so use params.Compression = GFL_RLE;
Pierre.
rigalr
Posts: 4
Joined: Mon May 14, 2007 6:03 pm

Post by rigalr »

THANK YOU !!!!

It works !!!

:D :D