Creating a Picture

In the Documentation, I read:

Can be used only for pictures created by the [Picture](https://documentation.xojo.com/api/graphics/picture.html) constructor with no pixel depth or a depth of only 16 or 32.

How can I create a Picture with a depth of 16 ?

I think the documentation might be out of date.

From my own tests I think all pictures end up being 32 bit on macOS and either 24 bit or 32 bit of MS-Windows.

Xojo removed the ability to use anything but 32 bit depth years ago.
(There is another thread talking about this now.)

How can I create a Picture with a depth of 16 ?

Why do you feel you need to?
I personally would love to create a 1 bit depth… only need black and white for some things.
But if you are working in color, how does restricting the available shades help you in your work?

I think it is more to do with the operating system’s support for different picture depths rather than Xojo removing functionality.

What about GIF files?
This from the Adobe website…

GIF stands for Graphics Interchange Format. GIF is a raster file format designed for relatively basic images that appear mainly on the internet. Each file can support up to 8 bits per pixel and can contain 256 indexed colors. GIF files also allow images or frames to be combined, creating basic animations.
These files use the .gif extension and can be opened in a wide range of programs.

So the GIFPictureMBS plugin option may be useful, but it still needs to be converted to a Xojo picture for display

GIFPictureMBS.PaletteDepth as Integer

Function: The depth of the palette of this GIFPictureMBS.
Notes:
Value should be 2, 4, 16 or 256.
(Read and Write property)

The MBS PictureMBS or Einhuger RawBitmap classes would be better than GIFPictureMBS.

I do not needed it, just curious to read that in the documentation.

And in the Constructor, there is nothing related to depth. Depth is set to Read Only.

At last, Color Palette is named differently in Xojo (if I can say that… check Map()).

Well, what is the goal?

If you need to store a picture with a file size limit, you may do some tricks.
Like we once had to fit a signature picture in 1500 bytes.

So we tried various ways and came to try grayscale JPEG with a quality low enough to come below the limit.

Doesn’t specifying 24 bits give you a picture with no alpha channel?

Doesn’t specifying 24 bits
Well, yes, but it still uses 24 bits for each color.

Its Emile asking, (and he doesn’t actually need it anyway), so the post is kinda pointless.
I have a use for lower depths, but it isn’t going to happen in Xojo. I’ll go plugin if it gets critical
:wink:

Yes, there is. You are mis-reading the documentation. The 3rd parameter to the contructor specifies the depth. At this time, there are really only 3 pertinent versions.

  • New Picture(x, y, 32) // a picture with 32 bit depth and no transparency - use a Mask
  • New Picture(x, y) // a picture with 32 bit depth and transparency
  • New Picture(x, y, 0) // a vector image with no Graphics or RGBSurface

24 used to work on MS-Windows - not sure if it does now though.

I think you are referring to a deprecated constructor.
Both the old and new docs do not reference depth in the constructors

https://docs.xojo.com/Picture.Constructor(width_as_Integer,_height_as_Integer)

https://documentation.xojo.com/api/graphics/picture.html

Pretty sure that is not the case. In my API2 application I have just typed:

var a as New Picture(tab

and it actually comes up with 4 constructors:

var a as New Picture()
var a as New Picture(width As Integer, height As Integer)
var a as New Picture(width As Integer, height As Integer, bitmaps() As Picture)
var a as New Picture(width As Integer, height As Integer, depth As Integer)

I don’t have the “show deprecated items” setting turned on. The new documentation is not always very accurate, especially on constructors.

I learn something from almost every discussion on this forum, regardless of whether it seems “pointless” or “goes on too long” for some people’s taste :slight_smile:

5 Likes

The docs are ambiguous about this. They don’t specifially define a constructor that takes a depth parameter, but they do refer to it in a couple of places. And it is the only way to create a vector image and is specifically mentioned/demonstrated in that section.

If I remember correctly, I brought this up to @Geoff_Perlman at one point around the time the new docs were being worked on. The depth constructor had been marked as deprecated, and I think he said that wasn’t intentional. There are uses for Picture objects of different depths, and I’d hope the documentation would be fixed.

1 Like

I do not think it ever actually supported different depts.

It was just Picture with mask, instead of picture with alpha channel you get from it.

Actually, the reason this was missing is that it wasn’t in the old docs. I’ve just added it. It should appear in the next build. If you ever find a class member missing from the documentation, please create a bug report. We fix those fairly quickly.

2 Likes

I @'d you about it two weeks ago, I wasn’t in the mood to add another ignored bug report at the time…

1 Like