Author Topic: RawToTexture  (Read 3636 times)

0 Members and 1 Guest are viewing this topic.

Peter

  • Guest
RawToTexture
« on: May 13, 2011, 08:50:54 AM »
Deleted
« Last Edit: April 11, 2015, 09:13:17 AM by Peter »

Charles Pegge

  • Guest
Re: RawToTexture
« Reply #1 on: May 13, 2011, 04:18:38 PM »

Hi Peter,

You can only use simple equates at present.

I have not hooked up the evaluator for doing arithmetic on dim sizes. I will try to get this set up for the next release.

Charles

Charles Pegge

  • Guest
Re: RawToTexture
« Reply #2 on: May 14, 2011, 02:47:09 PM »
Peter,

I have now implemented evaluation of equates for arrays. So you should now be able to specify:

% width 640
% height 480
% pixelbytes 4
...
dim as byte [width*height*pixelbytes]


I have just posted the update (Oxygen in-progress version)

Charles
« Last Edit: May 14, 2011, 03:00:10 PM by Charles Pegge »

kryton9

  • Guest
Re: RawToTexture
« Reply #3 on: May 15, 2011, 01:38:07 AM »
I like the evaluation of equates in arrays Charles, nice addition.

Peter,  raw files are simple to load but are usually not the preferred format as they are not compressed.
You might want to start using jpgs or if you want alpha channels also then png formats.

Charles has examples where he uses gdi+ for image loading, I have not tinkered or gotten that far yet in my studies of oxygen,
but you might want to look at those.

Charles Pegge

  • Guest
Re: RawToTexture
« Reply #4 on: May 15, 2011, 02:18:29 AM »

Hi Kent,

I would say in favour of BMP and RAW files, if they have significant areas of flat color, they will zip very efficently even if they eat up your disk space uncompressed :)

One problem with RAW files is hat every digital camera maker in the world has their own unique specification. RAW has no standard at all.

Charles

Charles Pegge

  • Guest
Re: RawToTexture
« Reply #5 on: May 15, 2011, 12:59:15 PM »
I'm porting some BMP stuff - this info is useful for loading BMP textures directly or creating BMP files directly without going through GDI.

Charles

Code: [Select]

 '===============
 'bmp file loader
 '===============

 type BmpMapHeader
   short bfType
   long  bfSize
   short bfReserved1
   short bfReserved2
   long  bfOffBits
   long  biSize
   long  biWidth
   long  biHeight
   short biPlanes
   short biBitCount
   long  biCompression
   long  biSizeImage
   long  biXPelsPerMeter
   long  biYPelsPerMeter
   long  biClrUsed
   long  biClrImportant
 end type
   

  string bmpfile="t.bmp" 'choose your file
  string bmpdata=""
  getfile bmpfile,bmpdata
  sys le=len bmpdata
  if le=0 then print "no data" : jmp fwd done
  '
  BmpMapHeader *d : @d = *bmpdata

  '---------------------
  'DISPLAY HEADER VALUES
  '=====================
  '
  #if 1 '0/1 excl/incl
  '
  'capture signature to string
  '---------------------------
  '
  string n="    "
  **n=?d
  n=left n,2
  '
  string cr=chr(13)+chr(10)
  string tab=chr(9)
  string pr="BMP HEADER DATA FOR " bmpfile cr cr
  def    p pr=pr+ %1 tab %2 cr
   '
 '------------------------------------------
  p  "Signature:        "  n
  p  "File Size:        "  d.bfSize
  p  "Bit data offset : "  d.bfOffBits
  p  "Header size:      "  d.bisize
  p  "Image Width:      "  d.biWidth
  p  "Image Height:     "  d.biHeight
  p  "Bit planes:       "  d.biPlanes
  p  "Bits per pixel:   "  d.biBitCount
  p  "Compression:      "  d.biCompression
  p  "Size of Image:    "  d.biSizeImage
  p  "Xpixels per metre:"  d.biXPelsPerMeter
  p  "Ypixels per metre:"  d.biYPelsPerMeter
  p  "Colours used:     "  d.biClrUsed
  p  "Colours important:"  d.biClrImportant
  '------------------------------------------

  print pr
  '
  #endif 'display header values


  '----------------
  'ACCESS TO PIXELS
  '================

  type  pixel byte r,g,b
  pixel *pix : @pix = *BmpData + d.bfOffBits

  'print pix[1].r

  '-------------
  'SAVE BMP FILE
  '=============

  'putfile "s.bmp",BmpData


  '====
  done:
  '====

  BmpData=""


'=====
'NOTES
'=====

'----------------------------------------------------------------------------------------------------------
' BMP file formats
'
' The BITMAPFILEHEADER:
'----------------------------------------------------------------------------------------------------------
'start size name         stdvalue purpose
'----------------------------------------------------------------------------------------------------------
'1     2    bfType       19778    must always be set to 'BM' to declare that this is a .bmp-file.
'3     4    bfSize          ??    the size of the file in bytes.
'7     2    bfReserved1      0    must always be set to zero.
'9     2    bfReserved2      0    must always be set to zero.
'11    4    bfOffBits     1078    specifies the offset from the beginning of the file to the bitmap data.
'----------------------------------------------------------------------------------------------------------
'
'
' The BITMAPINFOHEADER:
'----------------------------------------------------------------------------------------------------------
'start size name     stdvalue purpose
'----------------------------------------------------------------------------------------------------------
'15    4    biSize         40 size of the BITMAPINFOHEADER structure, in bytes.
'19    4    biWidth       100 width of the image, in pixels.
'23    4    biHeight      100 height of the image, in pixels.
'27    2    biPlanes        0 number of planes of the target device, must be set to zero.
'29    2    biBitCount      8 number of bits per pixel.
'31    4    biCompression   0 type of compression, usually set to zero (no compression).
'35    4    biSizeImage     0 size of the image data, in bytes. If there is no compression, it is valid to set this member to zero.
'39    4    biXPelsPerMeter 0 horizontal pixels per meter on the designated targer device, usually set to zero.
'43    4    biYPelsPerMeter 0 vertical pixels per meter on the designated targer device, usually set to zero.
'47    4    biClrUsed       0 number of colors used in the bitmap, if set to zero the number of colors is calculated using the biBitCount member.
'51    4    biClrImportant  0 number of color that are 'important' for the bitmap, if set to zero, all colors are important.
'----------------------------------------------------------------------------------------------------------
 
« Last Edit: May 15, 2011, 09:56:34 PM by Charles Pegge »

kryton9

  • Guest
Re: RawToTexture
« Reply #6 on: May 16, 2011, 10:42:21 PM »
I was wondering, did you guys... Charles and Peter find something wrong with using GDI+ ?  I was just curious.

If you want to port over more types, here is a great site for all file formats:
http://www.wotsit.org/list.asp?fc=1

Charles Pegge

  • Guest
Re: RawToTexture
« Reply #7 on: May 16, 2011, 11:29:36 PM »

GDI+ is really a sub-system intended for additional layers of abstraction in the MS scheme of things. It also uses GUIDs to access image codecs - a bit like COM. This makes it quite cumbersome to use directly. One is expect to use classes on the next layer up. But It is not as challenging as setting up Opengl :)

Charles