 |
forums.silverfrost.com Welcome to the Silverfrost forums
|
| View previous topic :: View next topic |
| Author |
Message |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8283 Location: Salford, UK
|
Posted: Fri Mar 29, 2013 4:14 pm Post subject: |
|
|
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 |
|
 |
jalih
Joined: 30 Jul 2012 Posts: 196
|
Posted: Fri Mar 29, 2013 7:39 pm Post subject: Re: |
|
|
| 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 |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8283 Location: Salford, UK
|
Posted: Sat Mar 30, 2013 8:57 am Post subject: |
|
|
| Thanks. This mirrors what I am aiming to do within ClearWin+. |
|
| Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8283 Location: Salford, UK
|
Posted: Mon Apr 01, 2013 12:00 pm Post subject: |
|
|
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 |
|
 |
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2428 Location: Yateley, Hants, UK
|
Posted: Mon Apr 01, 2013 2:52 pm Post subject: |
|
|
Is there going to be a matching IMPORT_IMAGE@ - and if so, can it support transparency (alpha channel) please?
Eddie |
|
| Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8283 Location: Salford, UK
|
Posted: Tue Apr 02, 2013 7:59 am Post subject: |
|
|
| 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 |
|
 |
JohnCampbell
Joined: 16 Feb 2006 Posts: 2623 Location: Sydney
|
Posted: Tue Apr 02, 2013 8:32 am Post subject: |
|
|
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 |
|
 |
dpannhorst
Joined: 29 Aug 2005 Posts: 165 Location: Berlin, Germany
|
Posted: Tue Apr 02, 2013 9:04 am Post subject: |
|
|
Paul,
thanks again for your work! Png export is working without any probemes!
Detlef |
|
| Back to top |
|
 |
jalih
Joined: 30 Jul 2012 Posts: 196
|
Posted: Tue Apr 02, 2013 9:20 am Post subject: Re: |
|
|
| 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 |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8283 Location: Salford, UK
|
Posted: Tue Apr 02, 2013 11:15 am Post subject: |
|
|
I don't have a quick answer about %dw.
I will put this on this list of things to look at. |
|
| Back to top |
|
 |
jalih
Joined: 30 Jul 2012 Posts: 196
|
Posted: Tue Apr 02, 2013 2:17 pm Post subject: Re: |
|
|
| 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 |
|
 |
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2428 Location: Yateley, Hants, UK
|
Posted: Wed Apr 03, 2013 10:51 pm Post subject: |
|
|
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 |
|
 |
jalih
Joined: 30 Jul 2012 Posts: 196
|
Posted: Thu Apr 04, 2013 6:15 am Post subject: Re: |
|
|
| 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 |
|
 |
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2428 Location: Yateley, Hants, UK
|
Posted: Thu Apr 04, 2013 11:38 am Post subject: |
|
|
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 |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8283 Location: Salford, UK
|
Posted: Thu Apr 04, 2013 5:14 pm Post subject: |
|
|
| According to the help file you can use "GRAPHICS_HDC" in CLEARWIN_INFO@ |
|
| Back to top |
|
 |
|
|
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
|