WritePixel Issue

Started by Hardcoal, December 11, 2019, 20:05:33

Previous topic - Next topic

Hardcoal

Can anyone explain me why do i get an error when I created a large pixmap (3840,500)

WritePixel(PixMap,X + ImageCounter * Image.width, Y, PixelValue)

what im trying to do is write a series of  Pixmaps onto a Single big Pixmap to create an Image Strip..

I only manage to write the first Image and than I get an Error..

Local Image:TImage = LoadGif("GifToLoad.Gif")
Local PixMap:TPixmap = CreatePixmap(image.width * (Image.pixmaps.Length - 1), image.height, PF_RGBA8888)

Local S, J, K

For S = 0 To Image.pixmaps.Length - 1

For J = 0 To Image.width
For K = 0 To Image.height
Local Pixel = ReadPixel(Image.pixmaps[S], J, K)
WritePixel(PixMap, J + S * Image.width, K, Pixel)
Next
Next

Next

SavePixmapPNG(PixMap, "Test.png")




* Another thing that puzzels me that is unrelated..
This guy who wrote this LoadGif Code didnt use Strict State.

so in his code you see this..

dib=GIFLoad(filename$) 'Load the next frame
  If dib=0 'Avoid errors
   'FreeImage graphic 'Free the graphic''hierX
   ResetGlobals()
   Return image 'Return the image
  EndIf
  bpp=PeekShort(dib,14) 'biBitCount
  bits=40+(PeekInt(dib,32)*4) 'biSize+(biClrUsed*4)


the variable dib starts as an int, and than used as a TBank on the command PeekShort..
how come something that began as an Int suddenly can be used as a Tbank without an Error?



Code

Hardcoal

Ok, While writing this question ive managed to solve the write pixel Issue..
I just needed to add -1 to the length and the height.. on the write pixel process..

Whats weird is.. that I remember trying it, and now suddenly it works..  ::)
Code

Derron

I saw your code - and I saw odd filenames - make sure that passed "filename" and actual filename are exactly the same  - once you moved on from Xors3D you might want to compile for Mac and Linux and this will result in issues if you mixup "myFILE.gIF" and "myfile.gif"


Also it can help to write more superstrict code (your variables "Local S, J, K" would become "Local S:Int, J:Int, K:Int").

This would then lead to some more insights on what happens with your "dib" (It is surely passing back a Byte Ptr ...). Where are these GIF-functions defined, and how?


bye
Ron

Hardcoal

Like Ive said.. Its not my code.
I would never write code without Strict..
About Super Strict.. I find no use for it, Ive concidered it as an over doing.
I dont like Variables that has the same name but with uppser case diffrences..
Ive always found that rather stupid Since we have enough Words to use..
But.. Maybe in a more professional Level, Super strict is essential, I dont know..

I was forced to work without Strict because when I put Strict on this guy code it producess Errors..
Thats why I asked about the how come an Integer can also be used as a TBank..

Anyway.. All Going better now, Im managin to achieve my Goal with all the difficulties.
Code

Derron

QuoteI dont like Variables that has the same name but with uppser case diffrences..

SuperStrict does not allow multiple variables just differing by case differences. BlitzMax is case insensitive.
What  was talking about is that Linux/Mac can have multiple files in a directory:
file.txt
File.txt
filE.tXT

while for Windows they are all the same. So when loading a file on Linux or Mac with "LoadImage()" you need to write the filename exactly how it is in the directory.


@ SuperStrict
Read more about this: https://blitzmax.org/docs/en/language/basic_compatibility/

If adding "strict" created errors then you might be using variables which you did not plan to use (eg you spelled them incorrectly). So "strict" at least makes sure you cannot do that. If SuperStrict creates errors for you, then you most probably mix up "Int" and "Byte Ptr".


bye
Ron

Hardcoal

Im not using Mac or Linux.
I told you Derron, I added strict to a code that is not mine.
I didnt mix anything. I tried to Edit a code that isnt mine, in addition, adding my own code.

Thanks for the explantions btw about the linux and mac File reading Issue. I didnt know

About Typos.. Well I do have lots of Typos.. if my speller doesnt work properly, as english is not my language.
Code

iWasAdam

strict is good, but SuperStrict is even better :) But only at the start of a project. adding it later would be a nightmare

Derron

#7
I am not talking about spelling issues in comments or variable names.

I do not care if you have a variable "eneeemies:TList". The problem is pretty simple - and explained in the link I gave above. Without strict you can write this:


Framework Brl.StandardIO

Type TEnemy
  Field id:int
End Type

For local personsIndex:Int = 0 until 5
  local enemy:TEnemy = new TEnemy
  enemy.id = personIndex + 1
  print enemy.id
Next


So what do you think is printed?

1
1
1
1
1

This is because you did not pay attention and added a little spelling mistake (there is an "s" missing). With "strict" it would blame that "personIndex" is undefined. Such mistakes can and most probably will lead to serious issues.


bye
Ron

Hardcoal

#8
Lol. Nice example ..
That's why im using strict!
I had to fix this guy code last night..
It was horrible..
But i made it!

Strict is good enough for Me
I don't need super duper strict
Code

Steve Elliott

Jees what a mess, Mark should never have made variable type definition optional, then compounded the problem with varying degrees of definition.
Win11 64Gb 12th Gen Intel i9 12900K 3.2Ghz Nvidia RTX 3070Ti 8Gb
Win11 16Gb 12th Gen Intel i5 12450H 2Ghz Nvidia RTX 2050 8Gb
Win11  Pro 8Gb Celeron Intel UHD Graphics 600
Win10/Linux Mint 16Gb 4th Gen Intel i5 4570 3.2GHz, Nvidia GeForce GTX 1050 2Gb
macOS 32Gb Apple M2Max
pi5 8Gb
Spectrum Next 2Mb

Hardcoal

#10
I agree..
Mark is a genius, but he had done some bad moves..
- For example, not promoting his blitzmax properly..
- Spreading into many engines instead of concentrating on one.

But I guess he is an Artist. Money is not his first priority, and I value it deeply.. :)
Code