Hi:
It seems that OLEPicture's #saveAsFile: method saves as bitmap. I'd like to load from hard disk GIF or JPEG files and save'em as GIF or JPEG, in other words keep the original file format all the way. What are my options to do it? Simply stream the bytes in and out? Zoli |
"Zoli" <[hidden email]> wrote in message
news:[hidden email]... > It seems that OLEPicture's #saveAsFile: method saves as bitmap. I'd > like to load from hard disk GIF or JPEG files and save'em as GIF or > JPEG, in other words keep the original file format all the way. What > are my options to do it? Simply stream the bytes in and out? There was some past discussion regarding this topic. I believe that GDI+ was the easiest way to do this. There is a GDI+ package that OA posted. I believe some people have made some enhancements to it. You can do a search for GDI+ in this group via goggle, or use the link bellow. http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&q=GDI%2B&meta=gr oup%3Dcomp.lang.smalltalk.dolphin Does someone have an enhanced version of the OA GDI+ package available on the web somewhere? As I recall there were some changes that needed to be made. Chris |
Hi Chris and Zoli,
There is indeed a Gdiplus package that several people (Blair, Andy, Steve Waring, Dan Antion, and me) have been working on, based on Blair originally wrapping all of the GDI+ API functions and adding methods for image loading and saving. Blair posted about the package and put it up on the web (in Nov 2002) but it has changed considerably, since then, in particular, refactored so the current hierarchy is quite different than it was in November. Since the package is copyrighted by OA, I'll defer the "posting it on the web" issue to Blair and Andy. I will add, however, that GDI+ is reaaaally neat - to see how GDI+ differs from GDI, take a look at http://msdn.microsoft.com/library/en-us/gdicpp/gdi+/aboutgdi+/whatsnewingdi+ /newfeatures.asp?frame=true -- Louis |
Well,
could I try out the new version? It would be great. Zoli "Louis Sumberg" <[hidden email]> wrote in message news:<b6sv1p$8sdl3$[hidden email]>... > Hi Chris and Zoli, > > There is indeed a Gdiplus package that several people (Blair, Andy, Steve > Waring, Dan Antion, and me) have been working on, based on Blair originally > wrapping all of the GDI+ API functions and adding methods for image loading > and saving. Blair posted about the package and put it up on the web (in Nov > 2002) but it has changed considerably, since then, in particular, refactored > so the current hierarchy is quite different than it was in November. Since > the package is copyrighted by OA, I'll defer the "posting it on the web" > issue to Blair and Andy. I will add, however, that GDI+ is reaaaally neat - > to see how GDI+ differs from GDI, take a look at > http://msdn.microsoft.com/library/en-us/gdicpp/gdi+/aboutgdi+/whatsnewingdi+ > /newfeatures.asp?frame=true > > -- Louis |
In reply to this post by Louis Sumberg-2
GDI+ has indeed nice features. I checked out the old one, evaluated
the code of its package comment, and experienced a repaint problem: the picture inside the image view is not always completely repainted when the window is resized - definitely not after a "minimize then maximize" operation. Did anyone have the same experience? Zoli "Louis Sumberg" <[hidden email]> wrote in message news:<b6sv1p$8sdl3$[hidden email]>... > Hi Chris and Zoli, > > There is indeed a Gdiplus package that several people (Blair, Andy, Steve > Waring, Dan Antion, and me) have been working on, based on Blair originally > wrapping all of the GDI+ API functions and adding methods for image loading > and saving. Blair posted about the package and put it up on the web (in Nov > 2002) but it has changed considerably, since then, in particular, refactored > so the current hierarchy is quite different than it was in November. Since > the package is copyrighted by OA, I'll defer the "posting it on the web" > issue to Blair and Andy. I will add, however, that GDI+ is reaaaally neat - > to see how GDI+ differs from GDI, take a look at > http://msdn.microsoft.com/library/en-us/gdicpp/gdi+/aboutgdi+/whatsnewingdi+ > /newfeatures.asp?frame=true > > -- Louis |
In reply to this post by Louis Sumberg-2
Louis
You wrote in message news:b6sv1p$8sdl3$[hidden email]... > Hi Chris and Zoli, > > There is indeed a Gdiplus package that several people (Blair, Andy, Steve > Waring, Dan Antion, and me) have been working on, based on Blair originally > wrapping all of the GDI+ API functions and adding methods for image loading > and saving. Blair posted about the package and put it up on the web (in Nov > 2002) but it has changed considerably, since then, in particular, refactored > so the current hierarchy is quite different than it was in November. Since > the package is copyrighted by OA, I'll defer the "posting it on the web" > issue to Blair and Andy. I will add, however, that GDI+ is reaaaally neat - > to see how GDI+ differs from GDI, take a look at > http://msdn.microsoft.com/library/en-us/gdicpp/gdi+/aboutgdi+/whatsnewingdi+ > /newfeatures.asp?frame=true Assuming that others who have worked on the GDIPlus package (and of course most of the work, with the exception of the initial wrapping, is by others and not by us) are happy for it to be generally distributed, then we have no problem with it being distributed as you see fit. Regards Blair |
In reply to this post by Zoli
Hi Zoli,
> the picture inside the image view is not always completely repainted > when the window is resized - definitely not after a "minimize then > maximize" operation. I loaded the original package and it worked fine for me. I assume the comment portion you evaluated was: file := (FileOpenDialog new) fileTypes: (Array with: #('Pictures (*.jpg)' '*.jpg') with: FileDialog allFilesType); showModal. img := GdiplusImage fromFile: file. ImagePresenter show: 'Basic image' on: img. You might try it in a fresh image. Also, I don't know if it'll work with a pre-D5 version, if that's what you have, though I think it would. For some flavors of Windows (like Win98, which I have) you have to download a Microsoft runtime dll, but I assume that's not the problem, else I don't think you would've gotten as far as you did. Sorry I can't be more helpful on this. As for distribution of the new version, per Blair's post, I'm certain we can get something out within a few days - there are some more changes in the pipeline right now. There'll be a post in the newsgroup. -- Louis |
Hi Louis:
Thanks for your concern. I got D5.0.1 and W2K. A fresh image didn't help. Maybe it's my hardware, but that's just a guess - I'm not an expert, all I do is experiments to see what's doable then write final code. An oldie from the DSDN archive, Ian's code, works for me: ===== bitmap := Bitmap fromFile: 'c:\logo.sys'. working := DIBSection width: bitmap extent x height: bitmap extent y. bitmap drawOn: working canvas. working canvas setBkMode: 1; text: 'Hello' at: 10@10. ImagePresenter show: 'Basic image' on: working. ===== Just for the record, I don't spend time with it any more: "ImagePresenter show: 'Basic image' on: bitmap" has the strange behaviour I cannot explain, namely: when I resize the image view with the mouse by dragging the window corners, the lower corners work fine, an upper corner resize is followed by a partial repaint or no repaint. Plus, a "minimize then maximize" operation is followed by a partial repaint. Cheers, Zoli "Louis Sumberg" <[hidden email]> wrote in message news:<b7d5f2$cqpqo$[hidden email]>... > Hi Zoli, > > > the picture inside the image view is not always completely repainted > > when the window is resized - definitely not after a "minimize then > > maximize" operation. > > I loaded the original package and it worked fine for me. I assume the > comment portion you evaluated was: > > file := (FileOpenDialog new) > fileTypes: (Array with: #('Pictures (*.jpg)' '*.jpg') with: FileDialog > allFilesType); > showModal. > img := GdiplusImage fromFile: file. > ImagePresenter show: 'Basic image' on: img. > > You might try it in a fresh image. Also, I don't know if it'll work with a > pre-D5 version, if that's what you have, though I think it would. For some > flavors of Windows (like Win98, which I have) you have to download a > Microsoft runtime dll, but I assume that's not the problem, else I don't > think you would've gotten as far as you did. Sorry I can't be more helpful > on this. > > As for distribution of the new version, per Blair's post, I'm certain we can > get something out within a few days - there are some more changes in the > pipeline right now. There'll be a post in the newsgroup. > > -- Louis |
Hi Zoli,
I personally had the same need in developing my working environment, in order to load those .jpg or .gif picture files. The way that I worked around is below, which borrowed much from previous posts from Steve and Ian etc. 1). The load the picture file as anIStream: NeuroPictShell>>istreamLoad | filename o extent i canvas s| filename := (FileOpenDialog new) fileTypes: self class libraryFileTypes; showModal. filename isNil ifTrue: [^nil]. Cursor wait showWhile: [ o := OLEPicture fromFile: filename. extent := o extent. i := DIBSection width: extent x height: extent y. canvas := i canvas. s := IStream onHGLOBAL. o picture saveAsFile: s fSaveMemCopy: true. s reset. o := OLEIPicture onPicture: (IPicture readFromIStream: s ). o drawOn: canvas at: Point zero extent: extent. image view viewMode: #scaleToFit. image value: o.]. ^s. ==> then I can let: myPictListPresenter model add: ( s reset; contents). Afterall, I can save as modal the IStream "s" content freely in my OmniBase file and it worked well in every OmniBase trasaction to reload the value to the imagePresenter while I select it from myPictListPresenter as the method below shown, so is to save the value of the imagePresenter as an image file. 2). The load it, anIStream to an ImagePresenter: NeuroPictShell>>showImage: anIStrem | stream o i canvas extent| anIStrem isEmpty ifTrue: [^self ]. stream := self byteToIStream: anIStrem. o := OLEIPicture onPicture: (IPicture readFromIStream: stream ). stream close. extent := o extent. i := DIBSection width: extent x height: extent y. canvas := i canvas. o drawOn: canvas at: Point zero extent: extent. imagePresenter view viewMode: #scaleToFit. imagePresenter value: o. I used it well but cann't sure is it a good implementation or not ( sorry, for my limited experience in programming, nor any experience in refactoring ( I don't known exactly how to use it in D5), just only to fullfil my own requirement. ) Best Regards. kuo. http://tgkuo.dyndns.org |
Hi Kuo,
thanks for sharing your code. This is how far I got on my own: ========== bitmap := GdiplusBitmap fromFile: 'c:\dolphin.jpe'. dib := DIBSection width: bitmap extent x height: bitmap extent y. bitmap drawOn: dib canvas. ImagePresenter showOn: dib. bmp := GdiplusBitmap fromBitmap: dib. bmp saveToFile: 'c:\test.abc' mimeType: 'image/png'. ========== Works with D5.0.1 and requires the "Gdiplus" posted on this newsgroup. Unfortunately on D5.1 it causes a walkback window. Best, Zoli |
Free forum by Nabble | Edit this page |