forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

EXPORT_IMAGE@
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8283
Location: Salford, UK

PostPosted: Fri Mar 29, 2013 4:14 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message AIM Address
jalih



Joined: 30 Jul 2012
Posts: 196

PostPosted: Fri Mar 29, 2013 7:39 pm    Post subject: Re: Reply with quote

PaulLaidler wrote:
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.

Code:

##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
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8283
Location: Salford, UK

PostPosted: Sat Mar 30, 2013 8:57 am    Post subject: Reply with quote

Thanks. This mirrors what I am aiming to do within ClearWin+.
Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8283
Location: Salford, UK

PostPosted: Mon Apr 01, 2013 12:00 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message AIM Address
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2428
Location: Yateley, Hants, UK

PostPosted: Mon Apr 01, 2013 2:52 pm    Post subject: Reply with quote

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

Eddie
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8283
Location: Salford, UK

PostPosted: Tue Apr 02, 2013 7:59 am    Post subject: Reply with quote

I will put it on the wish list but if you would like us to provide transparency on the screen then that would require a complete reworking of the code.
Back to top
View user's profile Send private message AIM Address
JohnCampbell



Joined: 16 Feb 2006
Posts: 2623
Location: Sydney

PostPosted: Tue Apr 02, 2013 8:32 am    Post subject: Reply with quote

Paul,

Thanks very much for this. I will give it a try soon and report back.
This could solve my colour palette problem and provide a concise dump file format.
Thanks also for the Beta version.

John
Back to top
View user's profile Send private message
dpannhorst



Joined: 29 Aug 2005
Posts: 165
Location: Berlin, Germany

PostPosted: Tue Apr 02, 2013 9:04 am    Post subject: Reply with quote

Paul,

thanks again for your work! Png export is working without any probemes!

Detlef
Back to top
View user's profile Send private message Visit poster's website
jalih



Joined: 30 Jul 2012
Posts: 196

PostPosted: Tue Apr 02, 2013 9:20 am    Post subject: Re: Reply with quote

PaulLaidler wrote:
I will put it on the wish list but if you would like us to provide transparency on the screen then that would require a complete reworking of the code.

How does the owner draw box format %dw work?

Could this be used as easy method for supporting image transparency? I mean, you could use GDI+ Graphics object and it's drawing functions.

Here is a quick sample written in MiniBASIC for creating a Graphics object from the DC handle and then loading and drawing the image.

Code:

##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 GdipCreateFromHDC(uint hDC, pointer pGraphics),int
@API GdipDeleteGraphics(int Graphics),int
@API GdipCreateBitmapFromGdiDib(pointer GdiBitmapInfo, pointer gdiBitmapData, pointer pBitmap),int
@API GdipLoadImageFromFile(wstring filename, pointer pImage),int
@API GdipSaveImageToFile(pointer GpImage, wstring filename, pointer clsidEncoder, pointer encoderParams),int
@API GdipDrawImageI(pointer pGraphics, pointer pImage, int x, int y),int
@API GdipDisposeImage(int image)


export import_image
func import_image(uint hDC, string filename, int x, int y)
   int result
   pointer pImage
   pointer pToken
   pointer pGraphics
   GdiplusStartupInput gsi

   gsi.GdiplusVersion = 1
   gsi.DebugEventCallback = NULL
   gsi.SuppressBackgroundThread = FALSE
   gsi.SuppressExternalCodecs = FALSE
   GdiplusStartup(&pToken,gsi,NULL)

   result=GdipLoadImageFromFile(a2w(filename),&pImage)
   result=GdipCreateFromHDC(hDC,&pGraphics)
   GdipDrawImageI(pGraphics,pImage,x,y)

   GdipDisposeImage(pImage)
   GdipDeleteGraphics(pGraphics)
   GdiplusShutdown(pToken)
endf
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8283
Location: Salford, UK

PostPosted: Tue Apr 02, 2013 11:15 am    Post subject: Reply with quote

I don't have a quick answer about %dw.
I will put this on this list of things to look at.
Back to top
View user's profile Send private message AIM Address
jalih



Joined: 30 Jul 2012
Posts: 196

PostPosted: Tue Apr 02, 2013 2:17 pm    Post subject: Re: Reply with quote

PaulLaidler wrote:
I don't have a quick answer about %dw.
I will put this on this list of things to look at.


Just tested, my idea seems to work fine...

Edit: I updated the sample project. It includes a DLL-file with two procedures for drawing images with tranparency into the %dw.

procedures are:

import_image(uint hDC, string filename, int x, int y)

- Imports image from graphic file into %dw on desired position.

import_imageRect(uint hDC, string filename, int x, int y, int w, int h)

- Same as import_image, except you can also specify desired widht and height for the image.

sample project
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2428
Location: Yateley, Hants, UK

PostPosted: Wed Apr 03, 2013 10:51 pm    Post subject: Reply with quote

Jalih,

Why did you choose %dw? I found it rather limited, and only ever made progress with Clearwin+ after I shifted over to using %gr - and I don't understand the difference between them.

Eddie
Back to top
View user's profile Send private message
jalih



Joined: 30 Jul 2012
Posts: 196

PostPosted: Thu Apr 04, 2013 6:15 am    Post subject: Re: Reply with quote

LitusSaxonicum wrote:

Why did you choose %dw?
Eddie

I don't know how %gr works internally. By using %dw allowed me to get the DC handle and use native GDI and GDI+ routines directly.

You can do some neat stuff with images, like alpha blending and transforms.
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2428
Location: Yateley, Hants, UK

PostPosted: Thu Apr 04, 2013 11:38 am    Post subject: Reply with quote

That explains a lot. When I tried to use it, it was in the belief that it would allow me to use the pre-Clearwin graphics routines with a minimum of fuss. I was wrong! I don't think %gr even existed back at the launch of Clearwin (I went to a seminar at Salford Software when it was launched).

I have to steer clear of trying to read too much Microsoft stuff, as it seems to me to be written in an alien language (Klingon?). Of course, this would be no obstacle for a native Klingon speaker!

Can't you get the DC handle for a %gr region? Paul will know.

Probably the person most interested in applying your discoveries would be Dan. I've got relatively simple needs.

Eddie
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8283
Location: Salford, UK

PostPosted: Thu Apr 04, 2013 5:14 pm    Post subject: Reply with quote

According to the help file you can use "GRAPHICS_HDC" in CLEARWIN_INFO@
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group