Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: saving Images

  1. #11

    Re: saving Images

    I think we need to see more of your source. What does TPack look like?
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  2. #12

    Re: saving Images

    Btw will this write the picture to the file ?(in case of large pictures as well.. )
    It dosent works like that, you cant save to disk any class variable passing just the pointer and using sizeof(); it will save just garbage; it is not a continues block of memory, there are pointers everywhere.

    So, you wish to load severals images with loadfromfile() and then save all of then in your own custom resource file?, then these are my advices:

    Mainly there are two techniques you can use, one is packing in one file several files in his native format, example, you have severals JPgs file ( pic01.jpg, pic02.jpg, pic03.jpg etc), you open and read each one using file read procedures (binary files, file stream etc), and write all bytes to your pack file in consecutive blocks. You need to prepare your pack file writing first a header wich tells how much files are empacked and the size in bytes of each one so you can later extract every file.

    Later when you need the image you extract the block bytes from the resource (to a temp file for example) and use procedures like loadfrom() for get the images in memory. That is why some people already advice you to check a ZIP or ZLIb library which does just that, empack several files in just one resource and then allow you to extract desired files, some libs even allow you to use procedures like loadfromfile() to open teh file directly from resource with not need to use temp files.

    The other technique is similar, pack in one resource several images but you just save the pixels, that way is easier to read back in memory the images with not need to use temp files. You open each image with procedures like loadfromfile() then you use class methods to access the image pixels and save the data in your resource file; yet you need to save the info about image dimensions so you can build back the image.

    In this method i recomend to uniform the image to same picture format for all images in your resource, for example uncompressed 32 bit color; use tbitmap class to convert whatever format you open with tpicture using the draw method, and access the pixels using scanline method.

    good luck.


  3. #13

    Re: saving Images

    Sorry for the late reply but I was bussy with school .. you really helped me out!
    Thnx for all the help !

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •