Silverfrost Forums

Welcome to our forums

EXPORT_IMAGE@

11 Mar 2013 10:22 #11709

I am using the EXPORT_IMAGE@ function for exporting my graphics to the different types of image files.

Everything is working fine except the file type .emf. The function returns a zero value for non-successful execution and no .emf file is created. What might be the problem?

By the way: it would be nice, if EXPORT_IMAGE@ could also support the file type .png.

Detlef Pannhorst

13 Mar 2013 7:43 #11732

Since there is no answer yet, I repeat my question:

Is the file type .emf supported, as described in the FTN95 help?

Detlef Pannhorst

13 Mar 2013 8:22 #11733

Sorry I missed your first post.

For me the function creates the file but returns zero. Also in my sample the background colour of the resulting image is white when it should be black.

What do you get if you ignore the returned zero?

I will log this for further investigation.

13 Mar 2013 9:01 #11737

Return code is zero and no emf file is created. All other types are working correctly.

13 Mar 2013 9:52 #11738

Detlef, perhaps you can use WMF instead of EMF. You can export graphics as WMF to the clipboard using something like this:

      j = open_printer1@(7)
      if (j .eq. 1) then
        j = open_metafile@(7)
        if (j .eq. 1) then
c
c         display your graphics to screen
c
          j = metafile_to_clipboard@()
        end if
        j = close_metafile@(7)
        j = close_printer_only@(7)
      end if

Regards - Wilfried

13 Mar 2013 10:51 #11741

Wilfried,

thanks for your suggestion. I have an own routine for writing WMF or EMF files already. But I'm also using EXPORT_GRAPHIC@ for the other file formats and it would have been nice and easier if the emf type export would work.

Regards, Detlef

13 Mar 2013 10:53 #11742

Sorry, the function is named of cause EXPORT_IMAGE@ (not EXPORT_GRAPHIC@).

13 Mar 2013 10:54 #11743

Paul,

what do you think about my suggestion for the support of file type png?

Detlef

20 Mar 2013 4:57 #11847

I have had a brief look at export_graphics@.

Writing to a file requires an open metafile. A quick and nasty way to get some output is illustrated here...

    winapp
    program gr3
      integer ctrl,i,h
      include <clearwin.ins>
      i=winio@('%gr[rgb_colours]%lw',320,200,ctrl)
      i=open_metafile@(0)
      call draw_filled_rectangle@(0,0,320,200,0)
      call draw_line_between@(0,0,320,200,RGB@(255,0,0))
      call draw_line_between@(0,200,320,0,RGB@(0,255,0))
      call draw_ellipse@(160,100,50,30,RGB@(0,0,255))
      i=export_image@('file.emf')
      i=close_metafile@(0)      
    end

There are at least two problems with this.

  1. The background filling does not appear in the file.
  2. An internal call to the Windows API function PlayEnhMetaFile fails for some unknown reason.

If you can manage without the background and can tolerate the error code then the result may be useful in some situations.

In theory there is support for bmp, pcx, emf, gif and jpg files. I can not see anything for png files and I have no idea how much work this would involve.

20 Mar 2013 5:40 #11848

Paul,

I will check your proposal for generating metafiles.

The Portable Network Graphics png is a modern replacement for the gif format.

More information you can find in Wikipedia:

http://en.wikipedia.org/wiki/Portable_Network_Graphics

Maybe you can add this feature for the next release?

Regards,

Detlef

20 Mar 2013 11:29 #11850

The main improvement from .gif to .png is the improved colour palette. Robert has helped me with trying to adapt the .gif 256 colour pallette.

A much better solution would be a .png format. I would expect that implementation of a .png file format is not a trivial exercise. It would be a very welcome addition. If someone wants to try, by first exporting the graphics image to a DIB_Block, it can be supplied as a utility outside clearwin+.

John

21 Mar 2013 7:26 #11851

I have had an initial look at what would be required to export to a .png file and it looks quite hopeful.

27 Mar 2013 5:34 #11901

I have fixed two problems regarding export_image@ for .emf files.

The background is now drawn and a false error code has been suppressed.

I have uploaded a beta version of salflibc.dll to http://www.silverfrost.com/beta/salflibc.exe

This is a self-extracting archive and this DLL supersedes the latest release.

28 Mar 2013 8:54 #11904

It's working fine now! Thanks for your help!

29 Mar 2013 12:56 #11907

Quoted from PaulLaidler I have had an initial look at what would be required to export to a .png file and it looks quite hopeful.

How about using GDI+ for this one?

I guess, you just need these functions:

GdiplusStartup() GdipCreateBitmapFromGdiDib() GdipSaveImageToFile() GdipDisposeImage() GdiplusShutdown()

You will also need this info: image/png CLSID : {557cf406-1a04-11d3-9a73-0000f81ef32e}

If you or someone else provides a little information, how ClearWin+ handles DIB's, then I can probably post something working...

29 Mar 2013 3:14 #11908

Thanks for this. It looks like this may be the easiest way to go. However, I have to work within the limits of the SCC compiler so by the time I have an answer to your question I will probably have a full solution.

29 Mar 2013 6:39 #11911

Quoted from PaulLaidler Thanks for this. It looks like this may be the easiest way to go. However, I have to work within the limits of the SCC compiler so by the time I have an answer to your question I will probably have a full solution.

Here is a code for the C-callable DLL written in MiniBASIC. Function export_dib2png takes pointer to BITMAPINFO structure, pointer to an array of pixel data, and output filename for the PNG-file as parameters. Function returns TRUE for success and FALSE for failure.

##NOCONSOLE
##MAKEDLL
##USES 'gdiplus.lib'

type GdiplusStartupInput
	int GdiplusVersion
	int DebugEventCallback
	int SuppressBackgroundThread
	int SuppressExternalCodecs
endtype

@API GdiplusStartup(pointer pToken, pointer GdiplusStartupInput, int GdiplusStartupOutput),int
@API GdiplusShutdown(int token)
@API GdipCreateBitmapFromGdiDib(pointer GdiBitmapInfo, pointer gdiBitmapData, pointer pBitmap),int
@API GdipSaveImageToFile(pointer GpImage, wstring FileName, pointer clsidEncoder, pointer encoderParams),int
@API GdipDisposeImage(int image)

GUID pngClsid
DEFINE_GUID(pngClsid, 0x557cf406,0x1a04,0x11d3,0x9a,0x73,0x00,0x00,0xf8,0x1e,0xf3,0x2e)


export export_dib2png
func export_dib2png(pointer GdiBitmapInfo, pointer gdiBitmapData, string outname),int
	int result
	pointer pBitmap = NULL
	pointer pToken = NULL
	GdiplusStartupInput gsi
	
	gsi.GdiplusVersion = 1
	gsi.DebugEventCallback = NULL
	gsi.SuppressBackgroundThread = FALSE
	gsi.SuppressExternalCodecs = FALSE
	GdiplusStartup(&pToken,gsi,NULL)

	result = GdipCreateBitmapFromGdiDib(GdiBitmapInfo, gdiBitmapData, &pBitmap)
	if result <> 0
		GdiplusShutdown(pToken)
		return FALSE
	endif
	result = GdipSaveImageToFile(pBitmap, A2W(outname), &pngClsid, NULL)
	GdipDisposeImage(pBitmap)
	GdiplusShutdown(pToken)
	if result <> 0 then return FALSE
	return TRUE
endf
30 Mar 2013 7:57 #11913

Thanks. This mirrors what I am aiming to do within ClearWin+.

1 Apr 2013 11:00 #11920

I have added the .png file type to export_image@.

You can download a beta trial of this from

http://www.silverfrost.com/beta/salflibc.exe

This is a self-extracting archive that requires the path to be supplied and may require Administrator privileges.

1 Apr 2013 1:52 #11922

Is there going to be a matching IMPORT_IMAGE@ - and if so, can it support transparency (alpha channel) please?

Eddie

Please login to reply.