Author |
Topic: JPG image data in memory (Read 520 times) |
|
chas99
New Member
member is offline


Posts: 2
|
 |
JPG image data in memory
« Thread started on: Jun 28th, 2017, 4:54pm » |
|
Richard I'm trying to get (your) FNloadimagegdip2 to point to an area of memory which contains jpg image data - rather than pointing to a file on disc. (Ideally this would be a dimmed in bbc4w area of memory) Is this possible? In particular can the API "GdipLoadImageFromStreamICM" be used instead of "GdipLoadImageFromFile" If so what parameters would this API take? At present I have to strip the jpg data from a (multi) jpg file, save it to disc and then use FNloadimagegdip2(file$, etc). (Sorry if I've overlooked this in your help and other documents)
|
| « Last Edit: Jun 28th, 2017, 5:19pm by chas99 » |
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 803
|
 |
Re: JPG image data in memory
« Reply #1 on: Jun 28th, 2017, 9:27pm » |
|
on Jun 28th, 2017, 4:54pm, chas99 wrote:| Is this possible? In particular can the API "GdipLoadImageFromStreamICM" be used instead of "GdipLoadImageFromFile"? If so what parameters would this API take? |
|
It's not something I have tried to do myself so my comments are no more than (intelligent?) guesswork. It seems likely that you can indeed use GdipLoadImageFromStream for the task, with the source stream created using CreateStreamOnHGlobal. The only 'gotcha' I can see from the documentation is that the latter call requires the memory containing the JPG image to have been allocated with GlobalAlloc, so you wouldn't be able to use a DIMmed area of memory*
As far as the details of the parameters are concerned, I can only refer you to the information at MSDN. I have added embedded links in the above paragraph so you can simply click on the function names to find the information.
Richard.
*Edit Reading the notes accompanying the function description, it looks like you might be able to use SHCreateMemStream instead, which should allow the use of DIMmed memory, but only on Windows Vista onwards unless you call it by ordinal.
|
|
|
|
chas99
New Member
member is offline


Posts: 2
|
 |
Re: JPG image data in memory
« Reply #2 on: Jun 29th, 2017, 10:40pm » |
|
Richard
Many thanks. I'll give the suggestions a go. I suspect a brute force approach may be needed as I have much trouble interpreting microsoft literature.
Chris.
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 803
|
 |
Re: JPG image data in memory
« Reply #3 on: Jun 30th, 2017, 09:32am » |
|
on Jun 29th, 2017, 10:40pm, chas99 wrote:| I suspect a brute force approach may be needed as I have much trouble interpreting microsoft literature. |
|
You shouldn't have any trouble with the particular APIs you need, they have very straightforward interfaces. If you had needed to call any of the COM APIs directly (such as the IStream methods) then definitely the translation would be far from trivial, but I don't think you will.
If the requirement to load JPGs from memory is more general (I've never needed to do it, but that's not to say nobody else has) I can consider adding it to the Wiki.
Richard.
|
|
Logged
|
|
|
|
KenDown
New Member
member is offline


Posts: 49
|
 |
Re: JPG image data in memory
« Reply #4 on: Feb 15th, 2018, 8:59pm » |
|
I've only just noticed this. Assuming that access from memory would be faster than access from disk, I would find that very useful. At present I use the rendering routine in the BB4W help files to scroll a picture across the screen by rendering it 4 pixels to the left (or right) each time. If that process can be speeded up ...
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 803
|
 |
Re: JPG image data in memory
« Reply #5 on: Feb 16th, 2018, 02:44am » |
|
on Feb 15th, 2018, 8:59pm, KenDown wrote:| I would find that very useful. |
|
Why are you saying "would": does the method I describe not work? As I said to the OP, the API functions look easy enough to call from BBC BASIC, although I've not had any need to try it myself.
Richard.
|
|
Logged
|
|
|
|
KenDown
New Member
member is offline


Posts: 49
|
 |
Re: JPG image data in memory
« Reply #6 on: Feb 16th, 2018, 03:36am » |
|
As I said, I've only just noticed this topic, so haven't had a chance to try anything. You said that "if the requirement ... is more general", so I'm indicating that I, for one, would find it useful. That makes two of us; whether that is sufficient interest to justify adding anything to the Wiki is for you to judge, but if no one indicates interest then the Wiki entry will never appear.
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 803
|
 |
Re: JPG image data in memory
« Reply #7 on: Feb 16th, 2018, 11:21am » |
|
on Feb 16th, 2018, 03:36am, KenDown wrote:| if no one indicates interest then the Wiki entry will never appear. |
|
I've only very rarely, if ever, created a wiki article simply because somebody "indicates interest". Rather, my contributions have been as a result of things I've needed to do myself and for which I've done the necessary research and coding.
The general idea of the wiki is that if somebody discovers how to do something that they think may be of general interest, they can create an article describing it. So if you work out how to load a JPG from memory, for example using the hints I provided in this thread, do please contribute an article for everybody's benefit.
It's unlikely that I will do so myself unless the situation arises when I need to do it in one of my own programs. To date, loading from file has always been plenty fast enough.
Richard.
|
|
Logged
|
|
|
|
|