I am trying to increase / decrease brightness of a picture using RGBSurface.Transform
When Supports Hi-DPI is turned off Shared Build Settings, the code works fine,
but if Supports Hi-DPI is turned on then an UnsupportedOperationException error occurs.
I received a help asking me to try out using picture.open(folderitem) instead of openasvectorpicture.
But it does not work.
Any help ?
This is the code I use
photo = photofolder.OpenAsVectorPicture
surf = photo.RGBSurface
br = 1 + (bright.Value/100)
for i = 0 to 255
if ibr < 255 Then
mapb.Append ibr
else
mapb.Append 255
end
next
surf.Transform mapb
drawphoto
Since HiDPI some graphics operations are pretty weird. Here is a routine that I got from the forum:
Protected Function MakeDarker(original as Picture, amount as double) as Picture
Dim n As Integer=original.ImageCount
If n=0 Then
Return MakeDarkerInner(original, amount)
Else
Dim pp() As Picture
n=n-1
for i as integer=0 to n
pp.AddRow MakeDarkerInner(original.ImageAt(i), amount)
Next
Return new Picture(original.Width, original.Height, pp)
End If
End Function
And the inner function:
[code]Private Function MakeDarkerInner(OriginalPicture as Picture, theAmount as Double) as Picture
'change the value (lighter or darker) for the Original Picture
Dim OriginalHeight As Integer = OriginalPicture.height
Dim OriginalWidth As Integer = OriginalPicture.width
Dim OriginalRGBS As RGBSurface = OriginalPicture.RGBSurface
//If you want, you can use the new constructor (without mask object)
dim ResultPicture as new Picture(OriginalPicture.Width, OriginalPicture.Height, 32)
'Dim ResultPicture As New Picture(OriginalPicture.Width, OriginalPicture.Height)
dim ResultRGBS as RGBSurface = ResultPicture.RGBSurface
for currentX as Integer = 0 to OriginalWidth
for currentY as Integer = 0 to OriginalHeight
dim theColor as Color = OriginalRGBS.Pixel(currentX, currentY)
ResultRGBS.Pixel(currentX, CurrentY) = HSV(theColor.Hue, theColor.Saturation, theColor.Value * theAmount)
next
next
If OriginalPicture.Mask=Nil Then
//if you use the ,32 constructor set the mask
//ResultPicture.Mask=OriginalPicture.CopyMask
//otherwise apply it
ResultPicture.ApplyMask OriginalPicture.CopyMask
Else
//if you use the ,32 constructor set the mask ResultPicture.Mask = OriginalPicture.mask
//otherwise apply it
ResultPicture.ApplyMask OriginalPicture.Mask
End If
Return ResultPicture
End Function[/code]
HTH