• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

distorted image need help fixing

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Basically I'm a noob at coding and I want to put an image(image below)into an array named pixels from the gui class and then
transfer it to the game class pixels[] and then display the image using the BufferedImage and pixels[] over the whole window so
I can overlay buttons and other things any help would be appreciated



this is the image I want to display
http://imgur.com/B1Fwww9

and this is how it looks when i try to display the image
http://imgur.com/Vds2HFV







-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
(this is a separate class)



 
Bartender
Posts: 2911
150
Google Web Toolkit Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Salt ward, welcome to coderanch. I have added code tags to your code so that its more readable.
 
salvin francis
Bartender
Posts: 2911
150
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think your code above is incomplete.
Particularly, this method : gui.render() is missing from your implementation.




 
jake ward
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you for the help so far and thank you for sorting the coding out, I don't usually use forums and sorry for the confusion because I was meant to take that  gui.render(); line of code out before I posted  
 
jake ward
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it come up like image provided without the render method atm and i want it to appear in the pixels array in the main class so that it shows the image as a background in the pixels[] which I know how to do the overlay just not sure what I'm doing wrong to not getting it to show properly and not pix-elated
 
Marshal
Posts: 79177
377
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch again.
Why have you got a Thread running? Are you trying to access Swing components in that Thread? That is incorrect because Swing isn't thread‑safe.
I couldn't see any pixillation in the sceond link you showed. Try adding your image to a scroll pane. What may be happening is that the resolution of the original image is 3000×2000px or similar; since the screen is only 1386px wide, you can't even see half of the image on the screen, so you only see its top left corner.
 
Campbell Ritchie
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to our GUIs forum.
 
jake ward
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And again thank you for the help ill keep that info in mind as i said I'm new to programming and because I'm a noob i make dumb ass mistake like that lol thank you again for the help and will update on how it goes
 
jake ward
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
update on problem: I was right about me making noob mistakes all it was is that I didn't take scaling into consideration sooooooooo yeaaaahh :P but anyways thank you for all the help and  thank you for at least taking the time to help much appreciated
 
jake ward
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

jake ward wrote:update on problem: I was right about me making noob mistakes all it was is that I didn't take scaling into consideration sooooooooo yeaaaahh :P but anyways thank you for all the help and  thank you for at least taking the time to help much appreciated



image was 900x500 which the JFrame was scaled to 300 * 3 , 300 /16 * 9 so my image needed to be 1 third the size
 
Saloon Keeper
Posts: 10705
86
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are doing this with integer arithmetic which will truncate any fractional portion.
For a width of 300, height would be 162.
If you modify the formula to do the multiply first
then for a width of 300 your height would be 168.
 
reply
    Bookmark Topic Watch Topic
  • New Topic