Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

png resources

Posted on 2007-11-18
10
2,717 Views
Last Modified: 2012-06-27
Hi all.
It's me again.
I'm wondering if there is possible to add .png files to .res and use them from that resource file. I will aspect an example for each ideea. Thanks
0
Comment
Question by:A. Cristian Csiki
  • 6
  • 4
10 Comments
 
LVL 28

Expert Comment

by:2266180
ID: 20309277
I will be below your expectations as I don't have time to give eberybody a complete solution with full examples.

I myself expect askers to collaborate in the idea that I provide the expertise and they provide their time. In my opinion this benefits everybody: you get a fast solution, spend a little time implementing, and I'll help out with whatever smal issues come around. and you're done. on the other hand, if I'll have to spend time for everybody, that goes out from my free time or not free time. so my alternative would be either not to help you (you meaning you askers) or help just a few of you. but from my experience here, people preffer that I give them whatever expertiese I have since they can get the job done faster thn waiting for somebody to spend time on making demos ;)

too much talk, so, solution:
- you need something that can deal with png. for example http://pngdelphi.sourceforge.net/
- you then save the png to the resource as you would do any other data (create a rc file and compile it to res then include it in the unit)
- for loading, you create a resourcestream and load the png with the component using loadfromstream

OR you can use LoadFromResourceName or LoadFromResourceID of the png component. which ever method you preffer.

for any other questions or problems, I'm here, so do ask ;)
if you have problems with the code, post your code and error so that I can assist on your problem directly.
0
 
LVL 11

Author Comment

by:A. Cristian Csiki
ID: 20310842
Hi ciuly.
The thing u told about ex. is fair. The 2nd thing: i tried adding the pngs in rc file and compile with the brcc32. It works fine. Still i'm in doubt which ext should i add in rc file for pngs (ex: webcam png webcam.png or webcam rcdata webcam.png) The first ex works. So i think that must be.

Second. I'm using pngs in Timage and Tpngspeedbutton from the delphi component mentioned by u above. The thing I'm stuck is the instance. Must be something very small.

png <pngspeedbutn>
png.pngimage.loadfromresourcename(hinstance,'data.res');
data.res must be my resource file....but the hinstance is wrong.

after that I read I can assign the picture to a Timage.

Thanks for help
Cheers ciuly
0
 
LVL 28

Accepted Solution

by:
2266180 earned 500 total points
ID: 20311047
you're not doing it right :)

I just woke up, the day is long so I've made a quick small demo: http://www.ciuly.com/delphi/multimedia/pngFromResource/index.html

you will have there a rc declaration (correct one) and a few lines of code on how to load it.

now, I don't install components/libraries I don't use (it just bloats my delphi installation plus it can make it unstable if teh component/.library conflicts with something), so what I did was to creat a png directory and as said by the readme from it, you will need to copy the conents of the delphipng inthere. the project has been modified to have the searchpath include that directory so it compiles fine. if you have already installed delphipng somewhere and set delphis search path than you don't need to copy those files to the png directory.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 11

Author Comment

by:A. Cristian Csiki
ID: 20311086
very good.
The example works very well. Thanks mite.

Have a nice day.
0
 
LVL 11

Author Closing Comment

by:A. Cristian Csiki
ID: 31409826
The sollution was the best I could get
0
 
LVL 11

Author Comment

by:A. Cristian Csiki
ID: 20314355
one more thing, if is not too late.
If I already got a pngobject on my project...in 2nd form i got a pngspeedbutton. Can I use the pngs from resource too?
0
 
LVL 28

Expert Comment

by:2266180
ID: 20314851
I don't understand your question.
jsut to cover some basics:
- you can load the same resource as many times as you want in as many objects as you want
- you can use the same object do display the same png in many places
- you can even use the same object to display different pngs in many places, but you'll have to take care of the "when" part (when you load the png, when you display it, etc).

I see that you leep referring to a pngspeedbutton. I never heard of it. google has some resources. Can you give me a pointer link to it so that I know what you are talking about? ;) a
and also, if you still have that question, explain it a little more explicitly
0
 
LVL 11

Author Comment

by:A. Cristian Csiki
ID: 20315449
well,
the png assigned to form1.image1 works fine.
if i add to assign png to form2.image1 i get:
Project Project1.exe raised exception class EAccessViolation with message 'Access violation at address 00471d38 in module 'Project1.exe'. Read of address 00000318

Same with a png component:
http://www.thany.org/article/32/PngComponents

Thanks for help.
Regards ciuly
0
 
LVL 28

Expert Comment

by:2266180
ID: 20315469
>> if i add to assign png to form2.image1 i get:

when? in form1.create? if so, that is a bad place since form2 is not yet created ;)

instead, in form2.create use the form1.image to assign to whatever you want to assign it to.
0
 
LVL 11

Author Comment

by:A. Cristian Csiki
ID: 20315568
like ussual u're wright =D>
Fix: in form2.create assign the png.
Thanks for many many times mate ;)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question