Encapsulated Image in external File
Posted: Fri Jul 12, 2019 11:29 am
Hi all!
Long time no post.
I have been chugging through an app idea for painters that allows:
- An image to be loaded
- A grid to be laid on the image (3x3 etc. or vertical only, or horizontal only, or angled)
- Grid colour and transparency changes
- Copying the image and greyscaling it
- Showing only a section of it (i.e. crop, but retaining whole image, masked away)
- Colour picking of an area (actually a pixel) and displaying a colour swatch for paint matching
- scaling of the final image size so gridlines can be easily transferred to a canvas and image drawn at scale
- File menu with: New, Open, Save, Print and exit.
Just a little app!
I have managed some good features so far, and am just rounding out the file menu stuff and have come across an issue.
Basically, I need to save a custom file with:
1. The details of how the image is displayed (size, location)
2. The information to draw any gridlines (points, colour)
3. The information to place any measurements (location and details)
4. The image itself.
So... I am writing a custom file script that is saving perfectly well. It writes the above, in the same order, line-by line with text. This should encapsulate all of the information needed to resume any work wherever you left off. This is saving OK, showing everything I need in the place that I need it
On opening the file, I can extract the first 3 sections perfectly well, and can display the image size and location, and any gridlines and measurements perfectly.
The problem is coming with the image.
I am using this method to save: put cr & the imagedata of img "Imagename" after tWriteData (tWriteData then becomes the contents of the file.)
Effectively writing the imagedata at the end of the file to be recovered later.
On opening, I make sure the image is the same size as it was when the imagedata was copied (I have also tried the original unscaled image size) and then set the imagedata of a dummy image onscreen to the last section of the custom file (i.e. the imagedata that was copied upon saving).
When I do this, I get a wierd deinterlaced image (The image I saved, but with lines through it)- but ONLY when using a colour image. When I use a B&W image, it comes in perfectly!
Is there something I can do to get the colour imagedata copied into the custom file so I can recover it? I'd like to have colour and B&W capabilities.
My other option is the just use the filename, and effectively "reference" the image rather than encapsulate it in the file. This has the drawback of: if you move the image file, you lose the reference... so I don't want to do it. This method does, however, work with colour and B&W.
Thankyou in advance brainstrust!
Xero
Long time no post.
I have been chugging through an app idea for painters that allows:
- An image to be loaded
- A grid to be laid on the image (3x3 etc. or vertical only, or horizontal only, or angled)
- Grid colour and transparency changes
- Copying the image and greyscaling it
- Showing only a section of it (i.e. crop, but retaining whole image, masked away)
- Colour picking of an area (actually a pixel) and displaying a colour swatch for paint matching
- scaling of the final image size so gridlines can be easily transferred to a canvas and image drawn at scale
- File menu with: New, Open, Save, Print and exit.
Just a little app!
I have managed some good features so far, and am just rounding out the file menu stuff and have come across an issue.
Basically, I need to save a custom file with:
1. The details of how the image is displayed (size, location)
2. The information to draw any gridlines (points, colour)
3. The information to place any measurements (location and details)
4. The image itself.
So... I am writing a custom file script that is saving perfectly well. It writes the above, in the same order, line-by line with text. This should encapsulate all of the information needed to resume any work wherever you left off. This is saving OK, showing everything I need in the place that I need it
On opening the file, I can extract the first 3 sections perfectly well, and can display the image size and location, and any gridlines and measurements perfectly.
The problem is coming with the image.
I am using this method to save: put cr & the imagedata of img "Imagename" after tWriteData (tWriteData then becomes the contents of the file.)
Effectively writing the imagedata at the end of the file to be recovered later.
On opening, I make sure the image is the same size as it was when the imagedata was copied (I have also tried the original unscaled image size) and then set the imagedata of a dummy image onscreen to the last section of the custom file (i.e. the imagedata that was copied upon saving).
When I do this, I get a wierd deinterlaced image (The image I saved, but with lines through it)- but ONLY when using a colour image. When I use a B&W image, it comes in perfectly!
Is there something I can do to get the colour imagedata copied into the custom file so I can recover it? I'd like to have colour and B&W capabilities.
My other option is the just use the filename, and effectively "reference" the image rather than encapsulate it in the file. This has the drawback of: if you move the image file, you lose the reference... so I don't want to do it. This method does, however, work with colour and B&W.
Thankyou in advance brainstrust!
Xero