I am taking a JPEG produced by a basic image program (Serif Photoplus) and trying to use it within XOJO. It is significantly changed (at least in my book.
Here is the small image
I have tried the following things.
- I opened the picture and SaveAsJPEG without any changes to the picture. The new JPEG is smaller and has significantly different colors from the original when I compared the two in Photoplus.
- I opened the picture myPic. Then I created a new white picture, myPic2, in XOJO and copied the colors from mypic to mypic2 using myPic2.Graphics.pixel(x,y)=RGB(c.red,c.green,c.blue,255). Outcome is the same when I do this.
- The original 46x36 pixel picture starts with 1540 bytes at the start. Open and Save in Xojo and size goes to 1148 bytes. Rename file in Windows Explorer. Repeat XOJO program and size to 1143>>>1144>>1140.
The code is below
[code] Dim x, y,xmax,ymax as integer
Dim f1,f2 As FolderItem
Dim d1 as OpenDialog
Dim myPic as Picture
Dim length as integer
Dim newname, newname2 as string
Dim c as color
d1=New OpenDialog
f1=d1.ShowModal()
If f1<>nil then
myPic=Picture.Open(f1)
end if
'myPic.save(f1,151) 'saved as original name, should be the same 1540 pixels, but went to 1148
Dim myPic2 as new Picture(myPic.Width,myPic.Height,32) 'created white picture
xmax=myPic.width-1
ymax=myPic.height-1
'copy colors before save
For x=0 to xmax
For y=0 to ymax
c=mypic.Graphics.Pixel(x,y)
myPic2.Graphics.pixel(x,y)=RGB(c.red,c.green,c.blue,255)
Next
Next
length=len(f1.absolutepath)
newname2=left(f1.absolutepath,length-4)+" saved after colors copied.jpg"
f2=GetFolderItem(newname3)
myPic2.save(f2,Picture.SaveAsJPEG)
[/code]